Example usage for org.hibernate.dialect.function StandardSQLFunction StandardSQLFunction

List of usage examples for org.hibernate.dialect.function StandardSQLFunction StandardSQLFunction

Introduction

In this page you can find the example usage for org.hibernate.dialect.function StandardSQLFunction StandardSQLFunction.

Prototype

public StandardSQLFunction(String name, Type registeredType) 

Source Link

Document

Construct a standard SQL function definition with a static return type.

Usage

From source file:org.openbravo.advpaymentmngt.utility.APRMApplicationInitializer.java

License:Open Source License

@Override
public void initialize() {
    OBDal.getInstance().registerSQLFunction("ad_message_get2",
            new StandardSQLFunction("ad_message_get2", StandardBasicTypes.STRING));
    OBDal.getInstance().registerSQLFunction("hqlagg",
            new SQLFunctionTemplate(StandardBasicTypes.STRING, getAggregationSQL()));
    OBDal.getInstance().registerSQLFunction("get_uuid",
            new StandardSQLFunction("get_uuid", StandardBasicTypes.STRING));
}

From source file:org.openbravo.base.session.OBOracle10gDialect.java

License:Open Source License

public OBOracle10gDialect() {
    super();/*w  w  w . j  a va  2 s  .  c o  m*/

    registerHibernateType(Types.NUMERIC, StandardBasicTypes.LONG.getName());
    registerHibernateType(Types.NVARCHAR, StandardBasicTypes.STRING.getName());
    registerHibernateType(Types.NCHAR, StandardBasicTypes.STRING.getName());

    registerColumnType(Types.VARCHAR, 4000, "nvarchar2($l)");
    registerColumnType(Types.VARCHAR, 100, "varchar2($l)");
    registerColumnType(Types.VARCHAR, 5, "char($l)");
    registerFunction("to_number", new StandardSQLFunction("to_number", StandardBasicTypes.BIG_DECIMAL));

    log.debug("Created Openbravo specific Oracle DIalect");
}

From source file:org.openbravo.client.kernel.KernelApplicationInitializer.java

License:Open Source License

private void registerSQLFunctions() {
    OBDal.getInstance().registerSQLFunction("ad_org_getcalendarowner",
            new StandardSQLFunction("ad_org_getcalendarowner", new StringType()));
    OBDal.getInstance().registerSQLFunction("ad_org_getperiodcontrolallow",
            new StandardSQLFunction("ad_org_getperiodcontrolallow", new StringType()));
    OBDal.getInstance().registerSQLFunction("m_isparent_ch_value",
            new StandardSQLFunction("m_isparent_ch_value", new StringType()));
}

From source file:org.openbravo.costing.CostingMigrationProcess.java

License:Open Source License

@Override
public void execute(ProcessBundle bundle) throws Exception {

    logger = bundle.getLogger();/*from   w  w  w.ja va2s .  c  o  m*/
    OBError msg = new OBError();
    msg.setType("Success");
    msg.setTitle(OBMessageUtils.messageBD("Success"));
    try {
        OBContext.setAdminMode(false);

        if (CostingStatus.getInstance().isMigrated()) {
            throw new OBException("@CostMigratedInstance@");
        }

        // FIXME: Remove when HQL based inserts are removed.
        OBDal.getInstance().registerSQLFunction("get_uuid",
                new StandardSQLFunction("get_uuid", new StringType()));
        OBDal.getInstance().registerSQLFunction("now", new StandardSQLFunction("now", new DateType()));

        if (!isMigrationFirstPhaseCompleted()) {
            doChecks();

            updateLegacyCosts();
            createRules();
            createMigrationFirstPhaseCompletedPreference();
        } else {
            checkAllInventoriesAreProcessed();
            for (CostingRule rule : getRules()) {
                rule.setValidated(true);
                OBDal.getInstance().save(rule);
            }
            deleteAlertRule();
            updateReportRoles();
            CostingStatus.getInstance().setMigrated();
            deleteMigrationFirstPhaseCompletedPreference();

        }
    } catch (final OBException e) {
        OBDal.getInstance().rollbackAndClose();
        String resultMsg = OBMessageUtils.parseTranslation(e.getMessage());
        logger.log(resultMsg);
        log4j.error(e);
        msg.setType("Error");
        msg.setTitle(OBMessageUtils.messageBD("Error"));
        msg.setMessage(resultMsg);
        bundle.setResult(msg);

    } catch (final Exception e) {
        OBDal.getInstance().rollbackAndClose();
        String message = DbUtility.getUnderlyingSQLException(e).getMessage();
        logger.log(message);
        log4j.error(message, e);
        msg.setType("Error");
        msg.setTitle(OBMessageUtils.messageBD("Error"));
        msg.setMessage(message);
        bundle.setResult(msg);
    } finally {
        OBContext.restorePreviousMode();
    }
    bundle.setResult(msg);

}

From source file:org.openbravo.test.dal.IssuesTest.java

License:Open Source License

/**
   * https://issues.openbravo.com/view.php?id=18688
   *///from   w ww .  j  av  a 2s.  com
  @Test
  public void test18688() {
      final Session session = OBDal.getInstance().getSession();
      OBDal.getInstance().registerSQLFunction("ad_column_identifier_std",
              new StandardSQLFunction("ad_column_identifier_std", StandardBasicTypes.STRING));
      final String qryStr = "select bc.id, ad_column_identifier_std('C_BP_Group', bc.id) from "
              + Category.ENTITY_NAME + " bc";
      final Query qry = session.createQuery(qryStr);
      for (Object o : qry.list()) {
          final Object[] os = (Object[]) o;
          assertTrue(os[1] instanceof String && os[1].toString().length() > 0);
      }
  }

From source file:org.postgis.hibernate.PostGISDialect.java

License:Open Source License

public PostGISDialect() {
    super();/*from  ww w  .  jav a2  s . c o  m*/
    registerColumnType(Types.BLOB, "geometry");
    registerFunction(PostGISDialect.NAMESPACE + "dimension",
            new StandardSQLFunction("dimension", Hibernate.INTEGER));
    registerFunction(PostGISDialect.NAMESPACE + "geometrytype",
            new StandardSQLFunction("geometrytype", Hibernate.STRING));
    registerFunction(PostGISDialect.NAMESPACE + "srid", new StandardSQLFunction("srid", Hibernate.INTEGER));
    registerFunction(PostGISDialect.NAMESPACE + "envelope",
            new StandardSQLFunction("envelope", Hibernate.custom(GeometryType.class)));
    registerFunction(PostGISDialect.NAMESPACE + "astext", new StandardSQLFunction("astext", Hibernate.STRING));
    registerFunction(PostGISDialect.NAMESPACE + "asbinary",
            new StandardSQLFunction("asbinary", Hibernate.BINARY));
    registerFunction(PostGISDialect.NAMESPACE + "isempty",
            new StandardSQLFunction("isempty", Hibernate.STRING));
    registerFunction(PostGISDialect.NAMESPACE + "issimple",
            new StandardSQLFunction("issimple", Hibernate.STRING));
    registerFunction(PostGISDialect.NAMESPACE + "boundary",
            new StandardSQLFunction("boundary", Hibernate.custom(GeometryType.class)));
    registerFunction(PostGISDialect.NAMESPACE + "equals", new StandardSQLFunction("equals", Hibernate.STRING));
    registerFunction(PostGISDialect.NAMESPACE + "disjoint",
            new StandardSQLFunction("disjoint", Hibernate.STRING));
    registerFunction(PostGISDialect.NAMESPACE + "intersects",
            new StandardSQLFunction("intersects", Hibernate.STRING));
    registerFunction(PostGISDialect.NAMESPACE + "touches",
            new StandardSQLFunction("touches", Hibernate.STRING));
    registerFunction(PostGISDialect.NAMESPACE + "crosses",
            new StandardSQLFunction("crosses", Hibernate.STRING));
    registerFunction(PostGISDialect.NAMESPACE + "within", new StandardSQLFunction("within", Hibernate.BOOLEAN));
    registerFunction(PostGISDialect.NAMESPACE + "contains",
            new StandardSQLFunction("contains", Hibernate.STRING));
    registerFunction(PostGISDialect.NAMESPACE + "overlaps",
            new StandardSQLFunction("overlaps", Hibernate.STRING));
    registerFunction(PostGISDialect.NAMESPACE + "relate", new StandardSQLFunction("relate", Hibernate.STRING));
    registerFunction(PostGISDialect.NAMESPACE + "distance",
            new StandardSQLFunction("distance", Hibernate.DOUBLE));
    registerFunction(PostGISDialect.NAMESPACE + "buffer",
            new StandardSQLFunction("buffer", Hibernate.custom(GeometryType.class)));
    registerFunction(PostGISDialect.NAMESPACE + "convexhull",
            new StandardSQLFunction("convexhull", Hibernate.custom(GeometryType.class)));
    registerFunction(PostGISDialect.NAMESPACE + "intersection",
            new StandardSQLFunction("intersection", Hibernate.custom(GeometryType.class)));
    registerFunction(PostGISDialect.NAMESPACE + "union",
            new StandardSQLFunction("geomunion", Hibernate.custom(GeometryType.class)));
    registerFunction(PostGISDialect.NAMESPACE + "difference",
            new StandardSQLFunction("difference", Hibernate.custom(GeometryType.class)));
    registerFunction(PostGISDialect.NAMESPACE + "symdifference",
            new StandardSQLFunction("symdifference", Hibernate.custom(GeometryType.class)));
    registerFunction(PostGISDialect.NAMESPACE + "numgeometries",
            new StandardSQLFunction("numgeometries", Hibernate.custom(GeometryType.class)));
    registerFunction(PostGISDialect.NAMESPACE + "geometryn",
            new StandardSQLFunction("geometryn", Hibernate.INTEGER));
    registerFunction(PostGISDialect.NAMESPACE + "x", new StandardSQLFunction("x", Hibernate.DOUBLE));
    registerFunction(PostGISDialect.NAMESPACE + "y", new StandardSQLFunction("y", Hibernate.DOUBLE));
    registerFunction(PostGISDialect.NAMESPACE + "geometryfromewtk",
            new StandardSQLFunction("geometryfromewtk", Hibernate.custom(GeometryType.class)));
}

From source file:org.sqlite.hibernate.SQLiteDialect.java

License:Open Source License

public SQLiteDialect() {
    super();/*from w w w .  ja v a  2 s.  c  o m*/
    registerColumnType(Types.BIT, "integer");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.INTEGER, "integer");
    registerColumnType(Types.BIGINT, "bigint");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.REAL, "real");
    registerColumnType(Types.DOUBLE, "double");
    registerColumnType(Types.NUMERIC, "numeric");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "timestamp");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    // registerColumnType(Types.NULL, "null");
    registerColumnType(Types.BLOB, "blob");
    registerColumnType(Types.CLOB, "clob");
    registerColumnType(Types.BOOLEAN, "integer");

    registerFunction("concat", new VarArgsSQLFunction(STRING, "", "||", ""));
    registerFunction("mod", new SQLFunctionTemplate(INTEGER, "?1 % ?2"));
    registerFunction("substr", new StandardSQLFunction("substr", STRING));
    registerFunction("substring", new StandardSQLFunction("substr", STRING));
}

From source file:org.teiid.dialect.TeiidDialect.java

License:Open Source License

public TeiidDialect() {
    // Register types
    registerColumnType(Types.CHAR, "char"); //$NON-NLS-1$
    registerColumnType(Types.VARCHAR, "string"); //$NON-NLS-1$

    registerColumnType(Types.BIT, "boolean"); //$NON-NLS-1$
    registerColumnType(Types.TINYINT, "byte"); //$NON-NLS-1$
    registerColumnType(Types.SMALLINT, "short"); //$NON-NLS-1$
    registerColumnType(Types.INTEGER, "integer"); //$NON-NLS-1$
    registerColumnType(Types.BIGINT, "long"); //$NON-NLS-1$

    registerColumnType(Types.REAL, "float"); //$NON-NLS-1$
    registerColumnType(Types.FLOAT, "float"); //$NON-NLS-1$
    registerColumnType(Types.DOUBLE, "double"); //$NON-NLS-1$
    registerColumnType(Types.NUMERIC, "bigdecimal"); //$NON-NLS-1$

    registerColumnType(Types.DATE, "date"); //$NON-NLS-1$
    registerColumnType(Types.TIME, "time"); //$NON-NLS-1$
    registerColumnType(Types.TIMESTAMP, "timestamp"); //$NON-NLS-1$

    registerColumnType(Types.BLOB, "blob"); //$NON-NLS-1$
    registerColumnType(Types.VARBINARY, "blob"); //$NON-NLS-1$
    registerColumnType(Types.CLOB, "clob"); //$NON-NLS-1$
    registerColumnType(Types.JAVA_OBJECT, "object"); //$NON-NLS-1$

    registerFunction("acos", new StandardSQLFunction("acos", DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("asin", new StandardSQLFunction("asin", DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("atan", new StandardSQLFunction("atan", DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("atan2", new StandardSQLFunction("atan2", DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("ceil", new StandardSQLFunction("ceiling")); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("cos", new StandardSQLFunction("cos", DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("cot", new StandardSQLFunction("cot", DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("degrees", new StandardSQLFunction("degrees", DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("exp", new StandardSQLFunction("exp", DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("floor", new StandardSQLFunction("floor")); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("formatbigdecimal", new StandardSQLFunction("formatbigdecimal", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("formatbiginteger", new StandardSQLFunction("formatbiginteger", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("formatdouble", new StandardSQLFunction("formatdouble", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("formatfloat", new StandardSQLFunction("formatfloat", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("formatinteger", new StandardSQLFunction("formatinteger", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("formatlong", new StandardSQLFunction("formatlong", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("log", new StandardSQLFunction("log", DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("mod", new StandardSQLFunction("mod")); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("parsebigdecimal", new StandardSQLFunction("parsebigdecimal", BIG_DECIMAL)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("parsebiginteger", new StandardSQLFunction("parsebiginteger", BIG_INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("parsedouble", new StandardSQLFunction("parsedouble", DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("parsefloat", new StandardSQLFunction("parsefloat", FLOAT)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("parseinteger", new StandardSQLFunction("parseinteger", INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("parselong", new StandardSQLFunction("parselong", LONG)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("pi", new StandardSQLFunction("pi", DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("power", new StandardSQLFunction("power", DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("radians", new StandardSQLFunction("radians", DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("round", new StandardSQLFunction("round")); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("sign", new StandardSQLFunction("sign", INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("sin", new StandardSQLFunction("sin", DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("tan", new StandardSQLFunction("tan", DOUBLE)); //$NON-NLS-1$ //$NON-NLS-2$

    registerFunction("ascii", new StandardSQLFunction("ascii", INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("chr", new StandardSQLFunction("chr", CHARACTER)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("char", new StandardSQLFunction("char", CHARACTER)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("concat", new VarArgsSQLFunction(STRING, "", "||", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    registerFunction("initcap", new StandardSQLFunction("initcap", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("insert", new StandardSQLFunction("insert", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("lcase", new StandardSQLFunction("lcase", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("left", new StandardSQLFunction("left", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("locate", new StandardSQLFunction("locate", INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("lpad", new StandardSQLFunction("lpad", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("ltrim", new StandardSQLFunction("ltrim", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("repeat", new StandardSQLFunction("repeat", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("replace", new StandardSQLFunction("replace", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("right", new StandardSQLFunction("right", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("rpad", new StandardSQLFunction("rpad", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("rtrim", new StandardSQLFunction("rtrim", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("substring", new StandardSQLFunction("substring", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("translate", new StandardSQLFunction("translate", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("ucase", new StandardSQLFunction("ucase", STRING)); //$NON-NLS-1$ //$NON-NLS-2$

    registerFunction("curdate", new NoArgSQLFunction("curdate", DATE)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("curtime", new NoArgSQLFunction("curtime", TIME)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("now", new NoArgSQLFunction("now", TIMESTAMP)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("dayname", new StandardSQLFunction("dayname", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth", INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("dayofweek", new StandardSQLFunction("dayofweek", INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("dayofyear", new StandardSQLFunction("dayofyear", INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("formatdate", new StandardSQLFunction("formatdate", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("formattime", new StandardSQLFunction("formattime", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("formattimestamp", new StandardSQLFunction("formattimestamp", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("hour", new StandardSQLFunction("hour", INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("minute", new StandardSQLFunction("minute", INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("monthname", new StandardSQLFunction("monthname", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("parsedate", new StandardSQLFunction("parsedate", DATE)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("parsetime", new StandardSQLFunction("parsetime", TIME)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("parsetimestamp", new StandardSQLFunction("parsetimestamp", TIMESTAMP)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("second", new StandardSQLFunction("second", INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("timestampcreate", new StandardSQLFunction("timestampcreate", TIMESTAMP)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("timestampAdd", new StandardSQLFunction("timestampAdd")); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("timestampDiff", new StandardSQLFunction("timestampDiff", LONG)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("week", new StandardSQLFunction("week", INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("year", new StandardSQLFunction("year", INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("modifytimezone", new StandardSQLFunction("modifytimezone", TIMESTAMP)); //$NON-NLS-1$ //$NON-NLS-2$

    registerFunction("convert", new StandardSQLFunction("convert")); //$NON-NLS-1$ //$NON-NLS-2$

    registerFunction("to_bytes", new StandardSQLFunction("to_bytes", BLOB)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("to_chars", new StandardSQLFunction("to_chars", CLOB)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("from_unittime", new StandardSQLFunction("from_unittime", TIMESTAMP)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("session_id", new StandardSQLFunction("session_id", STRING)); //$NON-NLS-1$ //$NON-NLS-2$

    registerFunction("uuid", new StandardSQLFunction("uuid", STRING)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("unescape", new StandardSQLFunction("unescape", STRING)); //$NON-NLS-1$ //$NON-NLS-2$

    registerFunction("array_get", new StandardSQLFunction("array_get", OBJECT)); //$NON-NLS-1$ //$NON-NLS-2$
    registerFunction("array_length", new StandardSQLFunction("array_length", INTEGER)); //$NON-NLS-1$ //$NON-NLS-2$
}

From source file:org.unitime.commons.hibernate.util.HibernateUtil.java

License:Open Source License

public static void addBitwiseOperationsToDialect() {
    SessionFactoryImplementor hibSessionFactory = (SessionFactoryImplementor) new _RootDAO().getSession()
            .getSessionFactory();//from   ww w.  ja  va2  s . c o m
    Dialect dialect = hibSessionFactory.getDialect();
    if (!dialect.getFunctions().containsKey("bit_and")) {
        if (isOracle())
            dialect.getFunctions().put("bit_and", new StandardSQLFunction("bitand", IntegerType.INSTANCE));
        else
            dialect.getFunctions().put("bit_and", new SQLFunctionTemplate(IntegerType.INSTANCE, "?1 & ?2"));
    }
}

From source file:sam_testclient.utilities.SQLiteDialect.java

public SQLiteDialect() {
    registerColumnType(Types.BIT, "integer");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.INTEGER, "integer");
    registerColumnType(Types.BIGINT, "bigint");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.REAL, "real");
    registerColumnType(Types.DOUBLE, "double");
    registerColumnType(Types.NUMERIC, "numeric");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "timestamp");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    // registerColumnType(Types.NULL, "null");
    registerColumnType(Types.BLOB, "blob");
    registerColumnType(Types.CLOB, "clob");
    registerColumnType(Types.BOOLEAN, "integer");

    registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", ""));
    registerFunction("mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "?1 % ?2"));
    registerFunction("substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING));
    registerFunction("substring", new StandardSQLFunction("substr", StandardBasicTypes.STRING));
}