private static Map<Type, GridType> createGridTypeConversionMap() { Map<Type, GridType> conversion = new HashMap<>(); conversion.put( StandardBasicTypes.CALENDAR, Iso8601StringCalendarType.DATE_TIME ); conversion.put( StandardBasicTypes.CALENDAR_DATE, Iso8601StringCalendarType.DATE ); conversion.put( StandardBasicTypes.DATE, Iso8601StringDateType.DATE ); conversion.put( StandardBasicTypes.TIME, Iso8601StringDateType.TIME ); conversion.put( StandardBasicTypes.TIMESTAMP, Iso8601StringDateType.DATE_TIME ); conversion.put( StandardBasicTypes.BYTE, RedisJsonByteType.INSTANCE ); conversion.put( StandardBasicTypes.INTEGER, RedisHashType.INTEGER ); conversion.put( StandardBasicTypes.SHORT, RedisHashType.SHORT ); conversion.put( StandardBasicTypes.LONG, RedisHashType.LONG ); conversion.put( StandardBasicTypes.DOUBLE, RedisHashType.DOUBLE ); conversion.put( StandardBasicTypes.FLOAT, RedisHashType.FLOAT ); conversion.put( StandardBasicTypes.BYTE, RedisHashType.BYTE ); conversion.put( BinaryType.INSTANCE, RedisJsonBlobType.INSTANCE ); conversion.put( MaterializedBlobType.INSTANCE, RedisJsonBlobType.INSTANCE ); conversion.put( StandardBasicTypes.SERIALIZABLE, RedisJsonBlobType.INSTANCE ); conversion.put( StandardBasicTypes.BOOLEAN, RedisHashType.BOOLEAN ); conversion.put( StandardBasicTypes.NUMERIC_BOOLEAN, RedisHashType.NUMERIC_BOOLEAN ); conversion.put( StandardBasicTypes.UUID_BINARY, RedisHashType.UUID_BINARY ); return conversion; }
public GridType overrideType(Type type) { if ( type == StandardBasicTypes.BIG_DECIMAL ) { return IgniteBigDecimalType.INSTANCE; } if ( type == StandardBasicTypes.BIG_INTEGER ) { return IgniteBigIntegerType.INSTANCE; } if ( type == StandardBasicTypes.CALENDAR ) { return IgniteCalendarType.INSTANCE; } if ( type == StandardBasicTypes.CALENDAR_DATE ) { return IgniteCalendarType.INSTANCE; } return null; }
@Override public List<Object[]> getList() { //create the session Session ses=null; //get the session ses=HibernateUtil.getSession(); //create the list of class object List<Object[]> list=null; //create the named parameterised the query SQLQuery query=ses.createSQLQuery("select PRODID,PRODNAME from PRODUCT where price>:price"); //pass the parameter to query query.setString("price", "500"); //add scalar to query query.addScalar("PRODID", StandardBasicTypes.INTEGER); query.addScalar("PRODNAME", StandardBasicTypes.STRING); //execute the query list=query.list(); //close the session HibernateUtil.closeSession(ses); //return the list return list; }
/** * Constructs a InterbaseDialect */ public InterbaseDialect() { super(); registerColumnType( Types.BIT, "smallint" ); registerColumnType( Types.BIGINT, "numeric(18,0)" ); registerColumnType( Types.SMALLINT, "smallint" ); registerColumnType( Types.TINYINT, "smallint" ); registerColumnType( Types.INTEGER, "integer" ); registerColumnType( Types.CHAR, "char(1)" ); registerColumnType( Types.VARCHAR, "varchar($l)" ); registerColumnType( Types.FLOAT, "float" ); registerColumnType( Types.DOUBLE, "double precision" ); registerColumnType( Types.DATE, "date" ); registerColumnType( Types.TIME, "time" ); registerColumnType( Types.TIMESTAMP, "timestamp" ); registerColumnType( Types.VARBINARY, "blob" ); registerColumnType( Types.NUMERIC, "numeric($p,$s)" ); registerColumnType( Types.BLOB, "blob" ); registerColumnType( Types.CLOB, "blob sub_type 1" ); registerColumnType( Types.BOOLEAN, "smallint" ); registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "(","||",")" ) ); registerFunction( "current_date", new NoArgSQLFunction( "current_date", StandardBasicTypes.DATE, false ) ); getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH ); }
@Override public Type getReturnType(Type columnType, Mapping mapping) throws QueryException { int[] sqlTypes; try { sqlTypes = columnType.sqlTypes( mapping ); } catch ( MappingException me ) { throw new QueryException( me ); } if ( sqlTypes.length != 1 ) { throw new QueryException( "multi-column type in avg()" ); } final int sqlType = sqlTypes[0]; if ( sqlType == Types.INTEGER || sqlType == Types.BIGINT || sqlType == Types.TINYINT ) { return StandardBasicTypes.FLOAT; } else { return columnType; } }
/** * Constructs a PostgresPlusDialect */ public PostgresPlusDialect() { super(); registerFunction( "ltrim", new StandardSQLFunction( "ltrim" ) ); registerFunction( "rtrim", new StandardSQLFunction( "rtrim" ) ); registerFunction( "soundex", new StandardSQLFunction( "soundex" ) ); registerFunction( "sysdate", new NoArgSQLFunction( "sysdate", StandardBasicTypes.DATE, false ) ); registerFunction( "rowid", new NoArgSQLFunction( "rowid", StandardBasicTypes.LONG, false ) ); registerFunction( "rownum", new NoArgSQLFunction( "rownum", StandardBasicTypes.LONG, false ) ); registerFunction( "instr", new StandardSQLFunction( "instr", StandardBasicTypes.INTEGER ) ); registerFunction( "lpad", new StandardSQLFunction( "lpad", StandardBasicTypes.STRING ) ); registerFunction( "replace", new StandardSQLFunction( "replace", StandardBasicTypes.STRING ) ); registerFunction( "rpad", new StandardSQLFunction( "rpad", StandardBasicTypes.STRING ) ); registerFunction( "translate", new StandardSQLFunction( "translate", StandardBasicTypes.STRING ) ); registerFunction( "substring", new StandardSQLFunction( "substr", StandardBasicTypes.STRING ) ); registerFunction( "coalesce", new NvlFunction() ); registerFunction( "atan2", new StandardSQLFunction( "atan2", StandardBasicTypes.FLOAT ) ); registerFunction( "mod", new StandardSQLFunction( "mod", StandardBasicTypes.INTEGER ) ); registerFunction( "nvl", new StandardSQLFunction( "nvl" ) ); registerFunction( "nvl2", new StandardSQLFunction( "nvl2" ) ); registerFunction( "power", new StandardSQLFunction( "power", StandardBasicTypes.FLOAT ) ); registerFunction( "add_months", new StandardSQLFunction( "add_months", StandardBasicTypes.DATE ) ); registerFunction( "months_between", new StandardSQLFunction( "months_between", StandardBasicTypes.FLOAT ) ); registerFunction( "next_day", new StandardSQLFunction( "next_day", StandardBasicTypes.DATE ) ); }
/** * Constructs a SQLServer2005Dialect */ public SQLServer2005Dialect() { // HHH-3965 fix // As per http://www.sql-server-helper.com/faq/sql-server-2005-varchar-max-p01.aspx // use varchar(max) and varbinary(max) instead of TEXT and IMAGE types registerColumnType( Types.BLOB, "varbinary(MAX)" ); registerColumnType( Types.VARBINARY, "varbinary(MAX)" ); registerColumnType( Types.VARBINARY, MAX_LENGTH, "varbinary($l)" ); registerColumnType( Types.LONGVARBINARY, "varbinary(MAX)" ); registerColumnType( Types.CLOB, "varchar(MAX)" ); registerColumnType( Types.LONGVARCHAR, "varchar(MAX)" ); registerColumnType( Types.VARCHAR, "varchar(MAX)" ); registerColumnType( Types.VARCHAR, MAX_LENGTH, "varchar($l)" ); registerColumnType( Types.BIGINT, "bigint" ); registerColumnType( Types.BIT, "bit" ); registerFunction( "row_number", new NoArgSQLFunction( "row_number", StandardBasicTypes.INTEGER, true ) ); }
private static Map<Type, AbstractGenericBasicType<?>> createGridTypeConversionMap() { Map<Type, AbstractGenericBasicType<? extends Object>> conversion = new HashMap<Type, AbstractGenericBasicType<? extends Object>>(); conversion.put( StandardBasicTypes.CALENDAR, Iso8601StringCalendarType.DATE_TIME ); conversion.put( StandardBasicTypes.CALENDAR_DATE, Iso8601StringCalendarType.DATE ); conversion.put( StandardBasicTypes.DATE, Iso8601StringDateType.DATE ); conversion.put( StandardBasicTypes.TIME, Iso8601StringDateType.TIME ); conversion.put( StandardBasicTypes.TIMESTAMP, Iso8601StringDateType.DATE_TIME ); conversion.put( StandardBasicTypes.BYTE, RedisJsonByteType.INSTANCE ); conversion.put( StandardBasicTypes.LONG, RedisJsonLongType.INSTANCE ); conversion.put( BinaryType.INSTANCE, RedisJsonBlobType.INSTANCE ); conversion.put( MaterializedBlobType.INSTANCE, RedisJsonBlobType.INSTANCE ); return conversion; }
public SQLServerDialect() { registerColumnType(Types.NVARCHAR, "nvarchar(MAX)"); registerColumnType(Types.NVARCHAR, 4000, "nvarchar($l)"); registerColumnType(Types.LONGNVARCHAR, "nvarchar(MAX)"); registerColumnType(Types.BIGINT, "numeric(19,0)"); registerColumnType(Types.BIT, "tinyint"); registerColumnType(Types.BOOLEAN, "tinyint"); registerHibernateType(Types.NVARCHAR, StandardBasicTypes.STRING.getName()); registerHibernateType(Types.NVARCHAR, 4000, StandardBasicTypes.STRING.getName()); registerHibernateType(Types.LONGNVARCHAR, StandardBasicTypes.STRING.getName()); StringBuilder sbuf = new StringBuilder(); try( InputStream inp = getClass().getResourceAsStream("dropconstraints.sql") ) { // Sonar whinges about the new InputStreamReader not being closed in // a finally block, but the existing finally block does that ...? BufferedReader bufReader = new BufferedReader(new InputStreamReader(inp, "UTF-8")); // NOSONAR String line = null; while( (line = bufReader.readLine()) != null ) { sbuf.append(line); sbuf.append('\n'); } dropConstraintsSQL = sbuf.toString(); } catch( Exception e ) { throw Throwables.propagate(e); } }
@Override @SuppressWarnings("unchecked") @Transactional(propagation = Propagation.MANDATORY) public List<Triple<Long, String, Boolean>> getMatchingExpressions(final List<String> values) { return getHibernateTemplate().executeFind(new HibernateCallback() { @Override public Object doInHibernate(Session session) { // NOTE THAT THIS IS NOT HQL!!! IT IS PRETTY MUCH SQL!!! String sql = "SELECT id, expression, dynamic FROM access_expression WHERE id IN" + " (SELECT access_expression_id FROM access_expression_expression_p" + " WHERE element IN (:values))"; SQLQuery query = session.createSQLQuery(sql); query.setParameterList("values", values); query.addScalar("id", StandardBasicTypes.LONG); query.addScalar("expression", StandardBasicTypes.STRING); query.addScalar("dynamic", StandardBasicTypes.BOOLEAN); query.setFetchSize(20); List<Pair<Long, String>> results = new ArrayList<Pair<Long, String>>(); List<Object[]> queryResults = query.list(); for( Object[] o : queryResults ) { results.add(new Triple<Long, String, Boolean>((Long) o[0], (String) o[1], (Boolean) o[2])); } return results; } }); }
@Override public String resolveHibernateTypeName(AnnotationInstance annotationInstance) { if ( annotationInstance == null ) { return null; } String type = null; if ( Clob.class.isAssignableFrom( mappedAttribute.getAttributeType() ) ) { type = StandardBasicTypes.CLOB.getName(); } else if ( Blob.class.isAssignableFrom( mappedAttribute.getAttributeType() ) ) { type = StandardBasicTypes.BLOB.getName(); } else if ( String.class.isAssignableFrom( mappedAttribute.getAttributeType() ) ) { type = StandardBasicTypes.MATERIALIZED_CLOB.getName(); } else if ( Character[].class.isAssignableFrom( mappedAttribute.getAttributeType() ) ) { type = CharacterArrayClobType.class.getName(); } else if ( char[].class.isAssignableFrom( mappedAttribute.getAttributeType() ) ) { type = PrimitiveCharacterArrayClobType.class.getName(); } else if ( Byte[].class.isAssignableFrom( mappedAttribute.getAttributeType() ) ) { type = WrappedMaterializedBlobType.class.getName(); } else if ( byte[].class.isAssignableFrom( mappedAttribute.getAttributeType() ) ) { type = StandardBasicTypes.MATERIALIZED_BLOB.getName(); } else if ( Serializable.class.isAssignableFrom( mappedAttribute.getAttributeType() ) ) { type = SerializableToBlobType.class.getName(); } else { type = "blob"; } return type; }
@Override public String resolveHibernateTypeName(AnnotationInstance temporalAnnotation) { if ( isTemporalType( mappedAttribute.getAttributeType() ) ) { if ( temporalAnnotation == null ) { //SPEC 11.1.47 The Temporal annotation must be specified for persistent fields or properties of type java.util.Date and java.util.Calendar. throw new AnnotationException( "Attribute " + mappedAttribute.getName() + " is a Temporal type, but no @Temporal annotation found." ); } TemporalType temporalType = JandexHelper.getEnumValue( temporalAnnotation, "value", TemporalType.class ); boolean isDate = Date.class.isAssignableFrom( mappedAttribute.getAttributeType() ); String type; switch ( temporalType ) { case DATE: type = isDate ? StandardBasicTypes.DATE.getName() : StandardBasicTypes.CALENDAR_DATE.getName(); break; case TIME: type = StandardBasicTypes.TIME.getName(); if ( !isDate ) { throw new NotYetImplementedException( "Calendar cannot persist TIME only" ); } break; case TIMESTAMP: type = isDate ? StandardBasicTypes.TIMESTAMP.getName() : StandardBasicTypes.CALENDAR.getName(); break; default: throw new AssertionFailure( "Unknown temporal type: " + temporalType ); } return type; } else { if ( temporalAnnotation != null ) { throw new AnnotationException( "@Temporal should only be set on a java.util.Date or java.util.Calendar property: " + mappedAttribute .getName() ); } } return null; }
public Type toType(String propertyName) throws QueryException { if ( propertyName.equals(CollectionPropertyNames.COLLECTION_ELEMENTS) ) { return memberPersister.getElementType(); } else if ( propertyName.equals(CollectionPropertyNames.COLLECTION_INDICES) ) { if ( !memberPersister.hasIndex() ) throw new QueryException("unindexed collection before indices()"); return memberPersister.getIndexType(); } else if ( propertyName.equals(CollectionPropertyNames.COLLECTION_SIZE) ) { return StandardBasicTypes.INTEGER; } else if ( propertyName.equals(CollectionPropertyNames.COLLECTION_MAX_INDEX) ) { return memberPersister.getIndexType(); } else if ( propertyName.equals(CollectionPropertyNames.COLLECTION_MIN_INDEX) ) { return memberPersister.getIndexType(); } else if ( propertyName.equals(CollectionPropertyNames.COLLECTION_MAX_ELEMENT) ) { return memberPersister.getElementType(); } else if ( propertyName.equals(CollectionPropertyNames.COLLECTION_MIN_ELEMENT) ) { return memberPersister.getElementType(); } else { //return memberPersister.getPropertyType(propertyName); throw new QueryException("illegal syntax near collection: " + propertyName); } }
public Query setParameter(int position, Object val) throws HibernateException { if (val == null) { setParameter( position, val, StandardBasicTypes.SERIALIZABLE ); } else { setParameter( position, val, determineType( position, val ) ); } return this; }
public Query setParameter(String name, Object val) throws HibernateException { if (val == null) { Type type = parameterMetadata.getNamedParameterExpectedType( name ); if ( type == null ) { type = StandardBasicTypes.SERIALIZABLE; } setParameter( name, val, type ); } else { setParameter( name, val, determineType( name, val ) ); } return this; }
public SQLServerDialect(){ super(); registerHibernateType(1, "string"); registerHibernateType(-9, "string"); registerHibernateType(-16, "string"); registerHibernateType(3, "double"); registerHibernateType(Types.CHAR, StandardBasicTypes.STRING.getName()); registerHibernateType(Types.NVARCHAR, StandardBasicTypes.STRING.getName()); registerHibernateType(Types.LONGNVARCHAR, StandardBasicTypes.STRING.getName()); registerHibernateType(Types.DECIMAL, StandardBasicTypes.DOUBLE.getName()); }
public Type getDataType() { if ( expectedType != null ) { return expectedType; } switch ( getType() ) { case NUM_INT: return StandardBasicTypes.INTEGER; case NUM_FLOAT: return StandardBasicTypes.FLOAT; case NUM_LONG: return StandardBasicTypes.LONG; case NUM_DOUBLE: return StandardBasicTypes.DOUBLE; case NUM_BIG_INTEGER: return StandardBasicTypes.BIG_INTEGER; case NUM_BIG_DECIMAL: return StandardBasicTypes.BIG_DECIMAL; case QUOTED_STRING: return StandardBasicTypes.STRING; case TRUE: case FALSE: return StandardBasicTypes.BOOLEAN; default: return null; } }
/** * 将field type 和 Hibernate的类型进行了对应。这里其实不是多余的,如果不进行一定的对应可能会有问题。 问题有两个: 1. * 在oracle中我们可能把一些字段设为NUMBER(%),而在Bean中的字段定的是long。那么查询时可能会报: * java.math.BeigDecimal不能转换成long等错误 2. * 如果不这样写的话,可能Bean中的field就得是大写的,如:name就得写成NAME,userCount就得写成USERCOUNT * 这样是不是很扯(V_V) * * @param <T> * @param sqlQuery * SQLQuery * @param clazz * T.class */ public static <T> void addSclar(SQLQuery sqlQuery, Class<T> clazz) { if (clazz == null) { throw new NullPointerException("[clazz] could not be null!"); } Field[] fields = clazz.getDeclaredFields(); for (Field field : fields) { if ((field.getType() == long.class) || (field.getType() == Long.class)) { sqlQuery.addScalar(field.getName(), StandardBasicTypes.LONG); } else if ((field.getType() == int.class) || (field.getType() == Integer.class)) { sqlQuery.addScalar(field.getName(), StandardBasicTypes.INTEGER); } else if ((field.getType() == char.class) || (field.getType() == Character.class)) { sqlQuery.addScalar(field.getName(), StandardBasicTypes.CHARACTER); } else if ((field.getType() == short.class) || (field.getType() == Short.class)) { sqlQuery.addScalar(field.getName(), StandardBasicTypes.SHORT); } else if ((field.getType() == double.class) || (field.getType() == Double.class)) { sqlQuery.addScalar(field.getName(), StandardBasicTypes.DOUBLE); } else if ((field.getType() == float.class) || (field.getType() == Float.class)) { sqlQuery.addScalar(field.getName(), StandardBasicTypes.FLOAT); } else if ((field.getType() == boolean.class) || (field.getType() == Boolean.class)) { sqlQuery.addScalar(field.getName(), StandardBasicTypes.BOOLEAN); } else if (field.getType() == String.class) { sqlQuery.addScalar(field.getName(), StandardBasicTypes.STRING); } else if (field.getType() == Date.class) { sqlQuery.addScalar(field.getName(), StandardBasicTypes.TIMESTAMP); } } sqlQuery.setResultTransformer(Transformers.aliasToBean(clazz)); }
/** * Constructs a Ingres9Dialect */ public Ingres9Dialect() { super(); registerDateTimeFunctions(); registerDateTimeColumnTypes(); registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "(", "||", ")" ) ); }
/** * Register functions current_time, current_timestamp, current_date */ protected void registerDateTimeFunctions() { registerFunction( "current_time", new NoArgSQLFunction( "current_time", StandardBasicTypes.TIME, false ) ); registerFunction( "current_timestamp", new NoArgSQLFunction( "current_timestamp", StandardBasicTypes.TIMESTAMP, false ) ); registerFunction( "current_date", new NoArgSQLFunction( "current_date", StandardBasicTypes.DATE, false ) ); }
/** * Constructs a SybaseASE157Dialect */ public SybaseASE157Dialect() { super(); registerFunction( "create_locator", new SQLFunctionTemplate( StandardBasicTypes.BINARY, "create_locator(?1, ?2)" ) ); registerFunction( "locator_literal", new SQLFunctionTemplate( StandardBasicTypes.BINARY, "locator_literal(?1, ?2)" ) ); registerFunction( "locator_valid", new SQLFunctionTemplate( StandardBasicTypes.BOOLEAN, "locator_valid(?1)" ) ); registerFunction( "return_lob", new SQLFunctionTemplate( StandardBasicTypes.BINARY, "return_lob(?1, ?2)" ) ); registerFunction( "setdata", new SQLFunctionTemplate( StandardBasicTypes.BOOLEAN, "setdata(?1, ?2, ?3)" ) ); registerFunction( "charindex", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "charindex(?1, ?2, ?3)" ) ); }
/** * Creates new <code>InformixDialect</code> instance. Sets up the JDBC / * Informix type mappings. */ public InformixDialect() { super(); registerColumnType( Types.BIGINT, "int8" ); registerColumnType( Types.BINARY, "byte" ); // Informix doesn't have a bit type registerColumnType( Types.BIT, "smallint" ); registerColumnType( Types.CHAR, "char($l)" ); registerColumnType( Types.DATE, "date" ); registerColumnType( Types.DECIMAL, "decimal" ); registerColumnType( Types.DOUBLE, "float" ); registerColumnType( Types.FLOAT, "smallfloat" ); registerColumnType( Types.INTEGER, "integer" ); // or BYTE registerColumnType( Types.LONGVARBINARY, "blob" ); // or TEXT? registerColumnType( Types.LONGVARCHAR, "clob" ); // or MONEY registerColumnType( Types.NUMERIC, "decimal" ); registerColumnType( Types.REAL, "smallfloat" ); registerColumnType( Types.SMALLINT, "smallint" ); registerColumnType( Types.TIMESTAMP, "datetime year to fraction(5)" ); registerColumnType( Types.TIME, "datetime hour to second" ); registerColumnType( Types.TINYINT, "smallint" ); registerColumnType( Types.VARBINARY, "byte" ); registerColumnType( Types.VARCHAR, "varchar($l)" ); registerColumnType( Types.VARCHAR, 255, "varchar($l)" ); registerColumnType( Types.VARCHAR, 32739, "lvarchar($l)" ); registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "(", "||", ")" ) ); uniqueDelegate = new InformixUniqueDelegate( this ); }
@Override public Object nullSafeGet(ResultSet resultSet, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { Object timestamp = StandardBasicTypes.TIMESTAMP.nullSafeGet(resultSet, names, session, owner); if (timestamp == null) { return null; } Date ts = (Date) timestamp; Instant instant = Instant.ofEpochMilli(ts.getTime()); return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); }
/** * Constructs a MckoiDialect */ public MckoiDialect() { super(); registerColumnType( Types.BIT, "bit" ); registerColumnType( Types.BIGINT, "bigint" ); registerColumnType( Types.SMALLINT, "smallint" ); registerColumnType( Types.TINYINT, "tinyint" ); registerColumnType( Types.INTEGER, "integer" ); registerColumnType( Types.CHAR, "char(1)" ); registerColumnType( Types.VARCHAR, "varchar($l)" ); registerColumnType( Types.FLOAT, "float" ); registerColumnType( Types.DOUBLE, "double" ); registerColumnType( Types.DATE, "date" ); registerColumnType( Types.TIME, "time" ); registerColumnType( Types.TIMESTAMP, "timestamp" ); registerColumnType( Types.VARBINARY, "varbinary" ); registerColumnType( Types.NUMERIC, "numeric" ); registerColumnType( Types.BLOB, "blob" ); registerColumnType( Types.CLOB, "clob" ); registerFunction( "upper", new StandardSQLFunction("upper") ); registerFunction( "lower", new StandardSQLFunction("lower") ); registerFunction( "sqrt", new StandardSQLFunction("sqrt", StandardBasicTypes.DOUBLE) ); registerFunction( "abs", new StandardSQLFunction("abs") ); registerFunction( "sign", new StandardSQLFunction( "sign", StandardBasicTypes.INTEGER ) ); registerFunction( "round", new StandardSQLFunction( "round", StandardBasicTypes.INTEGER ) ); registerFunction( "mod", new StandardSQLFunction( "mod", StandardBasicTypes.INTEGER ) ); registerFunction( "least", new StandardSQLFunction("least") ); registerFunction( "greatest", new StandardSQLFunction("greatest") ); registerFunction( "user", new StandardSQLFunction( "user", StandardBasicTypes.STRING ) ); registerFunction( "concat", new StandardSQLFunction( "concat", StandardBasicTypes.STRING ) ); getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH ); }
public SQLiteDialect() { registerColumnType(Types.BIT, "boolean"); 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($p, $s)"); registerColumnType(Types.DECIMAL, "decimal"); registerColumnType(Types.CHAR, "char"); registerColumnType(Types.VARCHAR, "varchar($l)"); registerColumnType(Types.LONGVARCHAR, "longvarchar"); registerColumnType(Types.DATE, "date"); registerColumnType(Types.TIME, "time"); registerColumnType(Types.TIMESTAMP, "datetime"); registerColumnType(Types.BINARY, "blob"); registerColumnType(Types.VARBINARY, "blob"); registerColumnType(Types.LONGVARBINARY, "blob"); registerColumnType(Types.BLOB, "blob"); registerColumnType(Types.CLOB, "clob"); registerColumnType(Types.BOOLEAN, "boolean"); registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", "")); registerFunction("mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "?1 % ?2")); registerFunction("quote", new StandardSQLFunction("quote", StandardBasicTypes.STRING)); registerFunction("random", new NoArgSQLFunction("random", StandardBasicTypes.INTEGER)); registerFunction("round", new StandardSQLFunction("round")); registerFunction("substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING)); registerFunction("trim", new AbstractAnsiTrimEmulationFunction() { protected SQLFunction resolveBothSpaceTrimFunction() { return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1)"); } protected SQLFunction resolveBothSpaceTrimFromFunction() { return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?2)"); } protected SQLFunction resolveLeadingSpaceTrimFunction() { return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1)"); } protected SQLFunction resolveTrailingSpaceTrimFunction() { return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1)"); } protected SQLFunction resolveBothTrimFunction() { return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1, ?2)"); } protected SQLFunction resolveLeadingTrimFunction() { return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1, ?2)"); } protected SQLFunction resolveTrailingTrimFunction() { return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1, ?2)"); } }); }
public ExtendedOracle10gDialect() { registerHibernateType(Types.CLOB, StandardBasicTypes.STRING.getName()); }
public ExtendedOracle9iDialect() { tenG = new ExtendedOracle10gDialect(); registerHibernateType(Types.CLOB, StandardBasicTypes.STRING.getName()); }
@Override public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { return new TypedValue[] { new TypedValue( StandardBasicTypes.INTEGER, size ) }; }
public Type getDiscriminatorType() { return StandardBasicTypes.INTEGER; }
public Query setString(int position, String val) { setParameter(position, val, StandardBasicTypes.STRING); return this; }
public Query setCharacter(int position, char val) { setParameter( position, Character.valueOf( val ), StandardBasicTypes.CHARACTER ); return this; }
public Query setBoolean(int position, boolean val) { Boolean valueToUse = val; Type typeToUse = determineType( position, valueToUse, StandardBasicTypes.BOOLEAN ); setParameter( position, valueToUse, typeToUse ); return this; }
public Query setByte(int position, byte val) { setParameter(position, val, StandardBasicTypes.BYTE); return this; }
public Query setShort(int position, short val) { setParameter(position, val, StandardBasicTypes.SHORT); return this; }
public Query setInteger(int position, int val) { setParameter(position, val, StandardBasicTypes.INTEGER); return this; }
public Query setLong(int position, long val) { setParameter(position, val, StandardBasicTypes.LONG); return this; }
public Query setFloat(int position, float val) { setParameter(position, val, StandardBasicTypes.FLOAT); return this; }
public Query setDouble(int position, double val) { setParameter(position, val, StandardBasicTypes.DOUBLE); return this; }
public Query setText(int position, String val) { setParameter(position, val, StandardBasicTypes.TEXT); return this; }
public Query setSerializable(int position, Serializable val) { setParameter(position, val, StandardBasicTypes.SERIALIZABLE); return this; }