HHH-5914 - Remove deprecated Hibernate type constants from org.hibernate.Hibernate and manuals
This commit is contained in:
parent
da028ee137
commit
303691c80e
|
@ -22,58 +22,18 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.bytecode.instrumentation.internal.FieldInterceptionHelper;
|
||||
import org.hibernate.bytecode.instrumentation.spi.FieldInterceptor;
|
||||
import org.hibernate.collection.PersistentCollection;
|
||||
import org.hibernate.engine.HibernateIterator;
|
||||
import org.hibernate.engine.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.engine.jdbc.LobCreationContext;
|
||||
import org.hibernate.engine.jdbc.LobCreator;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
import org.hibernate.proxy.LazyInitializer;
|
||||
import org.hibernate.type.AnyType;
|
||||
import org.hibernate.type.BigDecimalType;
|
||||
import org.hibernate.type.BigIntegerType;
|
||||
import org.hibernate.type.BinaryType;
|
||||
import org.hibernate.type.BlobType;
|
||||
import org.hibernate.type.BooleanType;
|
||||
import org.hibernate.type.ByteType;
|
||||
import org.hibernate.type.CalendarDateType;
|
||||
import org.hibernate.type.CalendarType;
|
||||
import org.hibernate.type.CharArrayType;
|
||||
import org.hibernate.type.CharacterArrayType;
|
||||
import org.hibernate.type.CharacterType;
|
||||
import org.hibernate.type.ClassType;
|
||||
import org.hibernate.type.ClobType;
|
||||
import org.hibernate.type.CurrencyType;
|
||||
import org.hibernate.type.DateType;
|
||||
import org.hibernate.type.DoubleType;
|
||||
import org.hibernate.type.FloatType;
|
||||
import org.hibernate.type.ImageType;
|
||||
import org.hibernate.type.IntegerType;
|
||||
import org.hibernate.type.LocaleType;
|
||||
import org.hibernate.type.LongType;
|
||||
import org.hibernate.type.ManyToOneType;
|
||||
import org.hibernate.type.MaterializedBlobType;
|
||||
import org.hibernate.type.MaterializedClobType;
|
||||
import org.hibernate.type.ObjectType;
|
||||
import org.hibernate.type.SerializableType;
|
||||
import org.hibernate.type.ShortType;
|
||||
import org.hibernate.type.StringType;
|
||||
import org.hibernate.type.TextType;
|
||||
import org.hibernate.type.TimeType;
|
||||
import org.hibernate.type.TimeZoneType;
|
||||
import org.hibernate.type.TimestampType;
|
||||
import org.hibernate.type.TrueFalseType;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.TypeFactory;
|
||||
import org.hibernate.type.WrapperBinaryType;
|
||||
import org.hibernate.type.YesNoType;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
|
||||
/**
|
||||
* <ul>
|
||||
|
@ -96,276 +56,8 @@ public final class Hibernate {
|
|||
private Hibernate() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
/**
|
||||
* Hibernate <tt>boolean</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#BOOLEAN} instead.
|
||||
*/
|
||||
public static final BooleanType BOOLEAN = BooleanType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>true_false</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#TRUE_FALSE} instead.
|
||||
*/
|
||||
public static final TrueFalseType TRUE_FALSE = TrueFalseType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>yes_no</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#YES_NO} instead.
|
||||
*/
|
||||
public static final YesNoType YES_NO = YesNoType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>byte</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#BYTE} instead.
|
||||
*/
|
||||
public static final ByteType BYTE = ByteType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>short</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#SHORT} instead.
|
||||
*/
|
||||
public static final ShortType SHORT = ShortType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>integer</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#INTEGER} instead.
|
||||
*/
|
||||
public static final IntegerType INTEGER = IntegerType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>long</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#LONG} instead.
|
||||
*/
|
||||
public static final LongType LONG = LongType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>float</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#FLOAT} instead.
|
||||
*/
|
||||
public static final FloatType FLOAT = FloatType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>double</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#DOUBLE} instead.
|
||||
*/
|
||||
public static final DoubleType DOUBLE = DoubleType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>big_integer</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#BIG_INTEGER} instead.
|
||||
*/
|
||||
public static final BigIntegerType BIG_INTEGER = BigIntegerType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>big_decimal</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#BIG_DECIMAL} instead.
|
||||
*/
|
||||
public static final BigDecimalType BIG_DECIMAL = BigDecimalType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>character</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#CHARACTER} instead.
|
||||
*/
|
||||
public static final CharacterType CHARACTER = CharacterType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>string</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#STRING} instead.
|
||||
*/
|
||||
public static final StringType STRING = StringType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>time</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#TIME} instead.
|
||||
*/
|
||||
public static final TimeType TIME = TimeType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>date</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#DATE} instead.
|
||||
*/
|
||||
public static final DateType DATE = DateType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>timestamp</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#TIMESTAMP} instead.
|
||||
*/
|
||||
public static final TimestampType TIMESTAMP = TimestampType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>binary</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#BINARY} instead.
|
||||
*/
|
||||
public static final BinaryType BINARY = BinaryType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>wrapper-binary</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#WRAPPER_BINARY} instead.
|
||||
*/
|
||||
public static final WrapperBinaryType WRAPPER_BINARY = WrapperBinaryType.INSTANCE;
|
||||
/**
|
||||
* Hibernate char[] type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#CHAR_ARRAY} instead.
|
||||
*/
|
||||
public static final CharArrayType CHAR_ARRAY = CharArrayType.INSTANCE;
|
||||
/**
|
||||
* Hibernate Character[] type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#CHARACTER_ARRAY} instead.
|
||||
*/
|
||||
public static final CharacterArrayType CHARACTER_ARRAY = CharacterArrayType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>image</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#IMAGE} instead.
|
||||
*/
|
||||
public static final ImageType IMAGE = ImageType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>text</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#TEXT} instead.
|
||||
*/
|
||||
public static final TextType TEXT = TextType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>materialized_blob</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#MATERIALIZED_BLOB} instead.
|
||||
*/
|
||||
public static final MaterializedBlobType MATERIALIZED_BLOB = MaterializedBlobType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>materialized_clob</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#MATERIALIZED_CLOB} instead.
|
||||
*/
|
||||
public static final MaterializedClobType MATERIALIZED_CLOB = MaterializedClobType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>blob</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#BLOB} instead.
|
||||
*/
|
||||
public static final BlobType BLOB = BlobType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>clob</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#CLOB} instead.
|
||||
*/
|
||||
public static final ClobType CLOB = ClobType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>calendar</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#CALENDAR} instead.
|
||||
*/
|
||||
public static final CalendarType CALENDAR = CalendarType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>calendar_date</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#CALENDAR_DATE} instead.
|
||||
*/
|
||||
public static final CalendarDateType CALENDAR_DATE = CalendarDateType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>locale</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#LOCALE} instead.
|
||||
*/
|
||||
public static final LocaleType LOCALE = LocaleType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>currency</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#CURRENCY} instead.
|
||||
*/
|
||||
public static final CurrencyType CURRENCY = CurrencyType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>timezone</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#TIMEZONE} instead.
|
||||
*/
|
||||
public static final TimeZoneType TIMEZONE = TimeZoneType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>class</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#CLASS} instead.
|
||||
*/
|
||||
public static final ClassType CLASS = ClassType.INSTANCE;
|
||||
/**
|
||||
* Hibernate <tt>serializable</tt> type.
|
||||
* @deprecated Use {@link org.hibernate.type.StandardBasicTypes#SERIALIZABLE} instead.
|
||||
*/
|
||||
public static final SerializableType SERIALIZABLE = SerializableType.INSTANCE;
|
||||
|
||||
|
||||
/**
|
||||
* Hibernate <tt>object</tt> type.
|
||||
* @deprecated Use {@link ObjectType#INSTANCE} instead.
|
||||
*/
|
||||
public static final ObjectType OBJECT = ObjectType.INSTANCE;
|
||||
|
||||
/**
|
||||
* A Hibernate <tt>serializable</tt> type.
|
||||
*
|
||||
* @param serializableClass The {@link java.io.Serializable} implementor class.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @deprecated Use {@link SerializableType#SerializableType} instead.
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public static Type serializable(Class serializableClass) {
|
||||
return new SerializableType( serializableClass );
|
||||
}
|
||||
|
||||
/**
|
||||
* DO NOT USE!
|
||||
*
|
||||
* @deprecated Use {@link TypeHelper#any} instead.
|
||||
*/
|
||||
@SuppressWarnings({ "JavaDoc", "UnusedDeclaration" })
|
||||
public static Type any(Type metaType, Type identifierType) {
|
||||
return new AnyType( metaType, identifierType );
|
||||
}
|
||||
|
||||
/**
|
||||
* DO NOT USE!
|
||||
*
|
||||
* @deprecated Use {@link TypeHelper#entity} instead; see http://opensource.atlassian.com/projects/hibernate/browse/HHH-5182
|
||||
*/
|
||||
@SuppressWarnings({ "JavaDoc", "UnusedDeclaration", "deprecation" })
|
||||
public static Type entity(Class persistentClass) {
|
||||
return entity( persistentClass.getName() );
|
||||
}
|
||||
|
||||
private static class NoScope implements TypeFactory.TypeScope {
|
||||
public static final NoScope INSTANCE = new NoScope();
|
||||
|
||||
public SessionFactoryImplementor resolveFactory() {
|
||||
throw new HibernateException( "Cannot access SessionFactory from here" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DO NOT USE!
|
||||
*
|
||||
* @deprecated Use {@link TypeHelper#entity} instead; see http://opensource.atlassian.com/projects/hibernate/browse/HHH-5182
|
||||
*/
|
||||
@SuppressWarnings({ "JavaDoc", "UnusedDeclaration" })
|
||||
public static Type entity(String entityName) {
|
||||
return new ManyToOneType( NoScope.INSTANCE, entityName );
|
||||
}
|
||||
|
||||
/**
|
||||
* DO NOT USE!
|
||||
*
|
||||
* @deprecated Use {@link TypeHelper#custom} instead; see http://opensource.atlassian.com/projects/hibernate/browse/HHH-5182
|
||||
*/
|
||||
@SuppressWarnings({ "JavaDoc", "UnusedDeclaration" })
|
||||
public static Type custom(Class userTypeClass) {
|
||||
return custom( userTypeClass, null );
|
||||
}
|
||||
|
||||
/**
|
||||
* DO NOT USE!
|
||||
*
|
||||
* @deprecated Use {@link TypeHelper#custom} instead; see http://opensource.atlassian.com/projects/hibernate/browse/HHH-5182
|
||||
*/
|
||||
@SuppressWarnings({ "JavaDoc", "UnusedDeclaration" })
|
||||
public static Type custom(Class userTypeClass, String[] parameterNames, String[] parameterValues) {
|
||||
return custom( userTypeClass, toProperties( parameterNames, parameterValues ) ); }
|
||||
|
||||
private static Properties toProperties(String[] parameterNames, String[] parameterValues) {
|
||||
if ( parameterNames == null || parameterNames.length == 0 ) {
|
||||
return null;
|
||||
}
|
||||
Properties parameters = new Properties();
|
||||
for ( int i = 0; i < parameterNames.length; i ++ ) {
|
||||
parameters.put( parameterNames[i], parameterValues[i] );
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* DO NOT USE!
|
||||
*
|
||||
* @deprecated Use {@link TypeHelper#custom} instead; see http://opensource.atlassian.com/projects/hibernate/browse/HHH-5182
|
||||
*/
|
||||
@SuppressWarnings({ "JavaDoc", "UnusedDeclaration", "unchecked" })
|
||||
public static Type custom(Class userTypeClass, Properties parameters) {
|
||||
if ( CompositeUserType.class.isAssignableFrom( userTypeClass ) ) {
|
||||
return TypeFactory.customComponent( userTypeClass, parameters, NoScope.INSTANCE );
|
||||
}
|
||||
else {
|
||||
return TypeFactory.custom( userTypeClass, parameters, NoScope.INSTANCE );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Force initialization of a proxy or persistent collection.
|
||||
* <p/>
|
||||
|
|
|
@ -23,21 +23,22 @@
|
|||
*/
|
||||
package org.hibernate.cfg.annotations;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Types;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.MapKeyEnumerated;
|
||||
import javax.persistence.MapKeyTemporal;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Types;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.annotations.Parameter;
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.hibernate.annotations.common.reflection.XClass;
|
||||
|
@ -49,6 +50,7 @@ import org.hibernate.cfg.Mappings;
|
|||
import org.hibernate.cfg.NotYetImplementedException;
|
||||
import org.hibernate.cfg.PkDrivenByDefaultMapsIdSecondPass;
|
||||
import org.hibernate.cfg.SetSimpleValueTypeSecondPass;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.mapping.SimpleValue;
|
||||
import org.hibernate.mapping.Table;
|
||||
|
@ -56,8 +58,8 @@ import org.hibernate.type.CharacterArrayClobType;
|
|||
import org.hibernate.type.EnumType;
|
||||
import org.hibernate.type.PrimitiveCharacterArrayClobType;
|
||||
import org.hibernate.type.SerializableToBlobType;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.WrappedMaterializedBlobType;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
|
@ -178,7 +180,7 @@ public class SimpleValueBinder {
|
|||
type = "blob";
|
||||
}
|
||||
else if ( mappings.getReflectionManager().equals( returnedClassOrElement, String.class ) ) {
|
||||
type = Hibernate.MATERIALIZED_CLOB.getName();
|
||||
type = StandardBasicTypes.MATERIALIZED_CLOB.getName();
|
||||
}
|
||||
else if ( mappings.getReflectionManager().equals( returnedClassOrElement, Character.class ) && isArray ) {
|
||||
type = CharacterArrayClobType.class.getName();
|
||||
|
@ -190,7 +192,7 @@ public class SimpleValueBinder {
|
|||
type = WrappedMaterializedBlobType.class.getName();
|
||||
}
|
||||
else if ( mappings.getReflectionManager().equals( returnedClassOrElement, byte.class ) && isArray ) {
|
||||
type = Hibernate.MATERIALIZED_BLOB.getName();
|
||||
type = StandardBasicTypes.MATERIALIZED_BLOB.getName();
|
||||
}
|
||||
else if ( mappings.getReflectionManager()
|
||||
.toXClass( Serializable.class )
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
||||
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
|
@ -20,17 +20,17 @@
|
|||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
package org.hibernate.criterion;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.TypedValue;
|
||||
import org.hibernate.persister.collection.QueryableCollection;
|
||||
import org.hibernate.persister.entity.Loadable;
|
||||
import org.hibernate.sql.ConditionFragment;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
/**
|
||||
* @author Gavin King
|
||||
|
@ -77,7 +77,7 @@ public class SizeExpression implements Criterion {
|
|||
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
|
||||
throws HibernateException {
|
||||
return new TypedValue[] {
|
||||
new TypedValue( Hibernate.INTEGER, new Integer(size), EntityMode.POJO )
|
||||
new TypedValue( StandardBasicTypes.INTEGER, size, EntityMode.POJO )
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,12 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.dialect;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.function.NoArgSQLFunction;
|
||||
|
@ -38,6 +39,7 @@ import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
|
|||
import org.hibernate.exception.ViolatedConstraintNameExtracter;
|
||||
import org.hibernate.id.SequenceGenerator;
|
||||
import org.hibernate.internal.util.JdbcExceptionHelper;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.descriptor.sql.BlobTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.ClobTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
@ -76,73 +78,73 @@ public class PostgreSQLDialect extends Dialect {
|
|||
registerColumnType( Types.OTHER, "uuid" );
|
||||
|
||||
registerFunction( "abs", new StandardSQLFunction("abs") );
|
||||
registerFunction( "sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
|
||||
registerFunction( "sign", new StandardSQLFunction("sign", StandardBasicTypes.INTEGER) );
|
||||
|
||||
registerFunction( "acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
|
||||
registerFunction( "asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
|
||||
registerFunction( "atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
|
||||
registerFunction( "cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
|
||||
registerFunction( "cot", new StandardSQLFunction("cot", Hibernate.DOUBLE) );
|
||||
registerFunction( "exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
|
||||
registerFunction( "ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
|
||||
registerFunction( "log", new StandardSQLFunction("log", Hibernate.DOUBLE) );
|
||||
registerFunction( "sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
|
||||
registerFunction( "sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
|
||||
registerFunction( "cbrt", new StandardSQLFunction("cbrt", Hibernate.DOUBLE) );
|
||||
registerFunction( "tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
|
||||
registerFunction( "radians", new StandardSQLFunction("radians", Hibernate.DOUBLE) );
|
||||
registerFunction( "degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE) );
|
||||
registerFunction( "acos", new StandardSQLFunction("acos", StandardBasicTypes.DOUBLE) );
|
||||
registerFunction( "asin", new StandardSQLFunction("asin", StandardBasicTypes.DOUBLE) );
|
||||
registerFunction( "atan", new StandardSQLFunction("atan", StandardBasicTypes.DOUBLE) );
|
||||
registerFunction( "cos", new StandardSQLFunction("cos", StandardBasicTypes.DOUBLE) );
|
||||
registerFunction( "cot", new StandardSQLFunction("cot", StandardBasicTypes.DOUBLE) );
|
||||
registerFunction( "exp", new StandardSQLFunction("exp", StandardBasicTypes.DOUBLE) );
|
||||
registerFunction( "ln", new StandardSQLFunction("ln", StandardBasicTypes.DOUBLE) );
|
||||
registerFunction( "log", new StandardSQLFunction("log", StandardBasicTypes.DOUBLE) );
|
||||
registerFunction( "sin", new StandardSQLFunction("sin", StandardBasicTypes.DOUBLE) );
|
||||
registerFunction( "sqrt", new StandardSQLFunction("sqrt", StandardBasicTypes.DOUBLE) );
|
||||
registerFunction( "cbrt", new StandardSQLFunction("cbrt", StandardBasicTypes.DOUBLE) );
|
||||
registerFunction( "tan", new StandardSQLFunction("tan", StandardBasicTypes.DOUBLE) );
|
||||
registerFunction( "radians", new StandardSQLFunction("radians", StandardBasicTypes.DOUBLE) );
|
||||
registerFunction( "degrees", new StandardSQLFunction("degrees", StandardBasicTypes.DOUBLE) );
|
||||
|
||||
registerFunction( "stddev", new StandardSQLFunction("stddev", Hibernate.DOUBLE) );
|
||||
registerFunction( "variance", new StandardSQLFunction("variance", Hibernate.DOUBLE) );
|
||||
registerFunction( "stddev", new StandardSQLFunction("stddev", StandardBasicTypes.DOUBLE) );
|
||||
registerFunction( "variance", new StandardSQLFunction("variance", StandardBasicTypes.DOUBLE) );
|
||||
|
||||
registerFunction( "random", new NoArgSQLFunction("random", Hibernate.DOUBLE) );
|
||||
registerFunction( "random", new NoArgSQLFunction("random", StandardBasicTypes.DOUBLE) );
|
||||
|
||||
registerFunction( "round", new StandardSQLFunction("round") );
|
||||
registerFunction( "trunc", new StandardSQLFunction("trunc") );
|
||||
registerFunction( "ceil", new StandardSQLFunction("ceil") );
|
||||
registerFunction( "floor", new StandardSQLFunction("floor") );
|
||||
|
||||
registerFunction( "chr", new StandardSQLFunction("chr", Hibernate.CHARACTER) );
|
||||
registerFunction( "chr", new StandardSQLFunction("chr", StandardBasicTypes.CHARACTER) );
|
||||
registerFunction( "lower", new StandardSQLFunction("lower") );
|
||||
registerFunction( "upper", new StandardSQLFunction("upper") );
|
||||
registerFunction( "substr", new StandardSQLFunction("substr", Hibernate.STRING) );
|
||||
registerFunction( "substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING) );
|
||||
registerFunction( "initcap", new StandardSQLFunction("initcap") );
|
||||
registerFunction( "to_ascii", new StandardSQLFunction("to_ascii") );
|
||||
registerFunction( "quote_ident", new StandardSQLFunction("quote_ident", Hibernate.STRING) );
|
||||
registerFunction( "quote_literal", new StandardSQLFunction("quote_literal", Hibernate.STRING) );
|
||||
registerFunction( "quote_ident", new StandardSQLFunction("quote_ident", StandardBasicTypes.STRING) );
|
||||
registerFunction( "quote_literal", new StandardSQLFunction("quote_literal", StandardBasicTypes.STRING) );
|
||||
registerFunction( "md5", new StandardSQLFunction("md5") );
|
||||
registerFunction( "ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
|
||||
registerFunction( "char_length", new StandardSQLFunction("char_length", Hibernate.LONG) );
|
||||
registerFunction( "bit_length", new StandardSQLFunction("bit_length", Hibernate.LONG) );
|
||||
registerFunction( "octet_length", new StandardSQLFunction("octet_length", Hibernate.LONG) );
|
||||
registerFunction( "ascii", new StandardSQLFunction("ascii", StandardBasicTypes.INTEGER) );
|
||||
registerFunction( "char_length", new StandardSQLFunction("char_length", StandardBasicTypes.LONG) );
|
||||
registerFunction( "bit_length", new StandardSQLFunction("bit_length", StandardBasicTypes.LONG) );
|
||||
registerFunction( "octet_length", new StandardSQLFunction("octet_length", StandardBasicTypes.LONG) );
|
||||
|
||||
registerFunction( "age", new StandardSQLFunction("age") );
|
||||
registerFunction( "current_date", new NoArgSQLFunction("current_date", Hibernate.DATE, false) );
|
||||
registerFunction( "current_time", new NoArgSQLFunction("current_time", Hibernate.TIME, false) );
|
||||
registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) );
|
||||
registerFunction( "date_trunc", new StandardSQLFunction( "date_trunc", Hibernate.TIMESTAMP ) );
|
||||
registerFunction( "localtime", new NoArgSQLFunction("localtime", Hibernate.TIME, false) );
|
||||
registerFunction( "localtimestamp", new NoArgSQLFunction("localtimestamp", Hibernate.TIMESTAMP, false) );
|
||||
registerFunction( "now", new NoArgSQLFunction("now", Hibernate.TIMESTAMP) );
|
||||
registerFunction( "timeofday", new NoArgSQLFunction("timeofday", Hibernate.STRING) );
|
||||
registerFunction( "current_date", new NoArgSQLFunction("current_date", StandardBasicTypes.DATE, false) );
|
||||
registerFunction( "current_time", new NoArgSQLFunction("current_time", StandardBasicTypes.TIME, false) );
|
||||
registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", StandardBasicTypes.TIMESTAMP, false) );
|
||||
registerFunction( "date_trunc", new StandardSQLFunction( "date_trunc", StandardBasicTypes.TIMESTAMP ) );
|
||||
registerFunction( "localtime", new NoArgSQLFunction("localtime", StandardBasicTypes.TIME, false) );
|
||||
registerFunction( "localtimestamp", new NoArgSQLFunction("localtimestamp", StandardBasicTypes.TIMESTAMP, false) );
|
||||
registerFunction( "now", new NoArgSQLFunction("now", StandardBasicTypes.TIMESTAMP) );
|
||||
registerFunction( "timeofday", new NoArgSQLFunction("timeofday", StandardBasicTypes.STRING) );
|
||||
|
||||
registerFunction( "current_user", new NoArgSQLFunction("current_user", Hibernate.STRING, false) );
|
||||
registerFunction( "session_user", new NoArgSQLFunction("session_user", Hibernate.STRING, false) );
|
||||
registerFunction( "user", new NoArgSQLFunction("user", Hibernate.STRING, false) );
|
||||
registerFunction( "current_database", new NoArgSQLFunction("current_database", Hibernate.STRING, true) );
|
||||
registerFunction( "current_schema", new NoArgSQLFunction("current_schema", Hibernate.STRING, true) );
|
||||
registerFunction( "current_user", new NoArgSQLFunction("current_user", StandardBasicTypes.STRING, false) );
|
||||
registerFunction( "session_user", new NoArgSQLFunction("session_user", StandardBasicTypes.STRING, false) );
|
||||
registerFunction( "user", new NoArgSQLFunction("user", StandardBasicTypes.STRING, false) );
|
||||
registerFunction( "current_database", new NoArgSQLFunction("current_database", StandardBasicTypes.STRING, true) );
|
||||
registerFunction( "current_schema", new NoArgSQLFunction("current_schema", StandardBasicTypes.STRING, true) );
|
||||
|
||||
registerFunction( "to_char", new StandardSQLFunction("to_char", Hibernate.STRING) );
|
||||
registerFunction( "to_date", new StandardSQLFunction("to_date", Hibernate.DATE) );
|
||||
registerFunction( "to_timestamp", new StandardSQLFunction("to_timestamp", Hibernate.TIMESTAMP) );
|
||||
registerFunction( "to_number", new StandardSQLFunction("to_number", Hibernate.BIG_DECIMAL) );
|
||||
registerFunction( "to_char", new StandardSQLFunction("to_char", StandardBasicTypes.STRING) );
|
||||
registerFunction( "to_date", new StandardSQLFunction("to_date", StandardBasicTypes.DATE) );
|
||||
registerFunction( "to_timestamp", new StandardSQLFunction("to_timestamp", StandardBasicTypes.TIMESTAMP) );
|
||||
registerFunction( "to_number", new StandardSQLFunction("to_number", StandardBasicTypes.BIG_DECIMAL) );
|
||||
|
||||
registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(","||",")" ) );
|
||||
registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "(","||",")" ) );
|
||||
|
||||
registerFunction( "locate", new PositionSubstringFunction() );
|
||||
|
||||
registerFunction( "str", new SQLFunctionTemplate(Hibernate.STRING, "cast(?1 as varchar)") );
|
||||
registerFunction( "str", new SQLFunctionTemplate(StandardBasicTypes.STRING, "cast(?1 as varchar)") );
|
||||
|
||||
getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
|
||||
getDefaultProperties().setProperty( Environment.NON_CONTEXTUAL_LOB_CREATION, "true" );
|
||||
|
@ -328,7 +330,7 @@ public class PostgreSQLDialect extends Dialect {
|
|||
}
|
||||
|
||||
/**
|
||||
* Constraint-name extractor for Postgres contraint violation exceptions.
|
||||
* Constraint-name extractor for Postgres constraint violation exceptions.
|
||||
* Orginally contributed by Denny Bartelt.
|
||||
*/
|
||||
private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
|
||||
|
|
|
@ -22,8 +22,9 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.dialect;
|
||||
|
||||
import java.sql.Types;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.function.NoArgSQLFunction;
|
||||
|
@ -39,6 +40,7 @@ import org.hibernate.dialect.lock.UpdateLockingStrategy;
|
|||
import org.hibernate.persister.entity.Lockable;
|
||||
import org.hibernate.sql.JoinFragment;
|
||||
import org.hibernate.sql.OracleJoinFragment;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
/**
|
||||
* A SQL dialect for TimesTen 5.1.
|
||||
|
@ -83,12 +85,12 @@ public class TimesTenDialect extends Dialect {
|
|||
registerFunction( "lower", new StandardSQLFunction("lower") );
|
||||
registerFunction( "upper", new StandardSQLFunction("upper") );
|
||||
registerFunction( "rtrim", new StandardSQLFunction("rtrim") );
|
||||
registerFunction( "concat", new StandardSQLFunction("concat", Hibernate.STRING) );
|
||||
registerFunction( "concat", new StandardSQLFunction("concat", StandardBasicTypes.STRING) );
|
||||
registerFunction( "mod", new StandardSQLFunction("mod") );
|
||||
registerFunction( "to_char", new StandardSQLFunction("to_char",Hibernate.STRING) );
|
||||
registerFunction( "to_date", new StandardSQLFunction("to_date",Hibernate.TIMESTAMP) );
|
||||
registerFunction( "sysdate", new NoArgSQLFunction("sysdate", Hibernate.TIMESTAMP, false) );
|
||||
registerFunction( "getdate", new NoArgSQLFunction("getdate", Hibernate.TIMESTAMP, false) );
|
||||
registerFunction( "to_char", new StandardSQLFunction("to_char",StandardBasicTypes.STRING) );
|
||||
registerFunction( "to_date", new StandardSQLFunction("to_date",StandardBasicTypes.TIMESTAMP) );
|
||||
registerFunction( "sysdate", new NoArgSQLFunction("sysdate", StandardBasicTypes.TIMESTAMP, false) );
|
||||
registerFunction( "getdate", new NoArgSQLFunction("getdate", StandardBasicTypes.TIMESTAMP, false) );
|
||||
registerFunction( "nvl", new StandardSQLFunction("nvl") );
|
||||
|
||||
}
|
||||
|
|
|
@ -22,12 +22,14 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.dialect.function;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import org.hibernate.QueryException;
|
||||
import org.hibernate.engine.Mapping;
|
||||
import org.hibernate.engine.SessionFactoryImplementor;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
|
@ -41,30 +43,22 @@ import org.hibernate.type.Type;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractAnsiTrimEmulationFunction implements SQLFunction {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public final boolean hasArguments() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public final boolean hasParenthesesIfNoArguments() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public final Type getReturnType(Type argumentType, Mapping mapping) throws QueryException {
|
||||
return Hibernate.STRING;
|
||||
return StandardBasicTypes.STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public final String render(Type argumentType, List args, SessionFactoryImplementor factory) throws QueryException {
|
||||
// According to both the ANSI-SQL and JPA specs, trim takes a variable number of parameters between 1 and 4.
|
||||
// at least one paramer (trimSource) is required. From the SQL spec:
|
||||
|
@ -137,7 +131,7 @@ public abstract class AbstractAnsiTrimEmulationFunction implements SQLFunction {
|
|||
}
|
||||
}
|
||||
|
||||
List argsToUse = new ArrayList();
|
||||
List<String> argsToUse = new ArrayList<String>();
|
||||
argsToUse.add( trimSource );
|
||||
argsToUse.add( trimCharacter );
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ public class DerbyConcatFunction implements SQLFunction {
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
* <p/>
|
||||
* Here we always return {@link Hibernate#STRING}.
|
||||
* Here we always return {@link StandardBasicTypes#STRING}.
|
||||
*/
|
||||
public Type getReturnType(Type argumentType, Mapping mapping) throws QueryException {
|
||||
return StandardBasicTypes.STRING;
|
||||
|
|
|
@ -22,19 +22,21 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.dialect.function;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.QueryException;
|
||||
import org.hibernate.engine.Mapping;
|
||||
import org.hibernate.engine.SessionFactoryImplementor;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
* TODO : javadoc
|
||||
* Centralized definition of standard ANSI SQL aggregation functions
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -46,7 +48,7 @@ public class StandardAnsiSqlAggregationFunctions {
|
|||
public static final CountFunction INSTANCE = new CountFunction();
|
||||
|
||||
public CountFunction() {
|
||||
super( "count", Hibernate.LONG );
|
||||
super( "count", StandardBasicTypes.LONG );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -82,7 +84,7 @@ public class StandardAnsiSqlAggregationFunctions {
|
|||
public static final AvgFunction INSTANCE = new AvgFunction();
|
||||
|
||||
public AvgFunction() {
|
||||
super( "avg", Hibernate.DOUBLE );
|
||||
super( "avg", StandardBasicTypes.DOUBLE );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -156,19 +158,19 @@ public class StandardAnsiSqlAggregationFunctions {
|
|||
|
||||
// First allow the actual type to control the return value; the underlying sqltype could
|
||||
// actually be different
|
||||
if ( firstArgumentType == Hibernate.BIG_INTEGER ) {
|
||||
return Hibernate.BIG_INTEGER;
|
||||
if ( firstArgumentType == StandardBasicTypes.BIG_INTEGER ) {
|
||||
return StandardBasicTypes.BIG_INTEGER;
|
||||
}
|
||||
else if ( firstArgumentType == Hibernate.BIG_DECIMAL ) {
|
||||
return Hibernate.BIG_DECIMAL;
|
||||
else if ( firstArgumentType == StandardBasicTypes.BIG_DECIMAL ) {
|
||||
return StandardBasicTypes.BIG_DECIMAL;
|
||||
}
|
||||
else if ( firstArgumentType == Hibernate.LONG
|
||||
|| firstArgumentType == Hibernate.SHORT
|
||||
|| firstArgumentType == Hibernate.INTEGER ) {
|
||||
return Hibernate.LONG;
|
||||
else if ( firstArgumentType == StandardBasicTypes.LONG
|
||||
|| firstArgumentType == StandardBasicTypes.SHORT
|
||||
|| firstArgumentType == StandardBasicTypes.INTEGER ) {
|
||||
return StandardBasicTypes.LONG;
|
||||
}
|
||||
else if ( firstArgumentType == Hibernate.FLOAT || firstArgumentType == Hibernate.DOUBLE) {
|
||||
return Hibernate.DOUBLE;
|
||||
else if ( firstArgumentType == StandardBasicTypes.FLOAT || firstArgumentType == StandardBasicTypes.DOUBLE) {
|
||||
return StandardBasicTypes.DOUBLE;
|
||||
}
|
||||
|
||||
// finally use the jdbcType if == on Hibernate types did not find a match.
|
||||
|
@ -179,13 +181,13 @@ public class StandardAnsiSqlAggregationFunctions {
|
|||
|| jdbcType == Types.DOUBLE
|
||||
|| jdbcType == Types.DECIMAL
|
||||
|| jdbcType == Types.REAL) {
|
||||
return Hibernate.DOUBLE;
|
||||
return StandardBasicTypes.DOUBLE;
|
||||
}
|
||||
else if ( jdbcType == Types.BIGINT
|
||||
|| jdbcType == Types.INTEGER
|
||||
|| jdbcType == Types.SMALLINT
|
||||
|| jdbcType == Types.TINYINT ) {
|
||||
return Hibernate.LONG;
|
||||
return StandardBasicTypes.LONG;
|
||||
}
|
||||
|
||||
// as a last resort, return the type of the first argument
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
||||
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
|
@ -20,15 +20,16 @@
|
|||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
package org.hibernate.hql.ast.tree;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
import antlr.SemanticException;
|
||||
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
* Contract for nodes representing logcial BETWEEN (ternary) operators.
|
||||
* Contract for nodes representing logical BETWEEN (ternary) operators.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -54,7 +55,7 @@ public class BetweenOperatorNode extends SqlNode implements OperatorNode {
|
|||
|
||||
public Type getDataType() {
|
||||
// logic operators by definition resolve to boolean.
|
||||
return Hibernate.BOOLEAN;
|
||||
return StandardBasicTypes.BOOLEAN;
|
||||
}
|
||||
|
||||
public Node getFixtureOperand() {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
||||
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
|
@ -20,14 +20,15 @@
|
|||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
package org.hibernate.hql.ast.tree;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import antlr.SemanticException;
|
||||
|
||||
import org.hibernate.hql.antlr.HqlSqlTokenTypes;
|
||||
import org.hibernate.hql.ast.util.ColumnHelper;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
import antlr.SemanticException;
|
||||
|
||||
/**
|
||||
* Nodes which represent binary arithmetic operators.
|
||||
|
@ -58,7 +59,7 @@ public class BinaryArithmeticOperatorNode extends AbstractSelectExpression imple
|
|||
// some datetime type
|
||||
// 2) if the operator is PLUS, the param needs to be of
|
||||
// some numeric type
|
||||
expectedType = getType() == HqlSqlTokenTypes.PLUS ? Hibernate.DOUBLE : rhType;
|
||||
expectedType = getType() == HqlSqlTokenTypes.PLUS ? StandardBasicTypes.DOUBLE : rhType;
|
||||
}
|
||||
else {
|
||||
expectedType = rhType;
|
||||
|
@ -76,7 +77,7 @@ public class BinaryArithmeticOperatorNode extends AbstractSelectExpression imple
|
|||
// 2) if the operator is PLUS, the param needs to be of
|
||||
// some numeric type
|
||||
if ( getType() == HqlSqlTokenTypes.PLUS ) {
|
||||
expectedType = Hibernate.DOUBLE;
|
||||
expectedType = StandardBasicTypes.DOUBLE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -113,7 +114,7 @@ public class BinaryArithmeticOperatorNode extends AbstractSelectExpression imple
|
|||
if ( lhType == null ) {
|
||||
if ( rhType == null ) {
|
||||
// we do not know either type
|
||||
return Hibernate.DOUBLE; //BLIND GUESS!
|
||||
return StandardBasicTypes.DOUBLE; //BLIND GUESS!
|
||||
}
|
||||
else {
|
||||
// we know only the rhs-hand type, so use that
|
||||
|
@ -126,12 +127,24 @@ public class BinaryArithmeticOperatorNode extends AbstractSelectExpression imple
|
|||
return lhType;
|
||||
}
|
||||
else {
|
||||
if ( lhType==Hibernate.DOUBLE || rhType==Hibernate.DOUBLE ) return Hibernate.DOUBLE;
|
||||
if ( lhType==Hibernate.FLOAT || rhType==Hibernate.FLOAT ) return Hibernate.FLOAT;
|
||||
if ( lhType==Hibernate.BIG_DECIMAL || rhType==Hibernate.BIG_DECIMAL ) return Hibernate.BIG_DECIMAL;
|
||||
if ( lhType==Hibernate.BIG_INTEGER || rhType==Hibernate.BIG_INTEGER ) return Hibernate.BIG_INTEGER;
|
||||
if ( lhType==Hibernate.LONG || rhType==Hibernate.LONG ) return Hibernate.LONG;
|
||||
if ( lhType==Hibernate.INTEGER || rhType==Hibernate.INTEGER ) return Hibernate.INTEGER;
|
||||
if ( lhType== StandardBasicTypes.DOUBLE || rhType==StandardBasicTypes.DOUBLE ) {
|
||||
return StandardBasicTypes.DOUBLE;
|
||||
}
|
||||
if ( lhType==StandardBasicTypes.FLOAT || rhType==StandardBasicTypes.FLOAT ) {
|
||||
return StandardBasicTypes.FLOAT;
|
||||
}
|
||||
if ( lhType==StandardBasicTypes.BIG_DECIMAL || rhType==StandardBasicTypes.BIG_DECIMAL ) {
|
||||
return StandardBasicTypes.BIG_DECIMAL;
|
||||
}
|
||||
if ( lhType==StandardBasicTypes.BIG_INTEGER || rhType==StandardBasicTypes.BIG_INTEGER ) {
|
||||
return StandardBasicTypes.BIG_INTEGER;
|
||||
}
|
||||
if ( lhType==StandardBasicTypes.LONG || rhType==StandardBasicTypes.LONG ) {
|
||||
return StandardBasicTypes.LONG;
|
||||
}
|
||||
if ( lhType==StandardBasicTypes.INTEGER || rhType==StandardBasicTypes.INTEGER ) {
|
||||
return StandardBasicTypes.INTEGER;
|
||||
}
|
||||
return lhType;
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +191,7 @@ public class BinaryArithmeticOperatorNode extends AbstractSelectExpression imple
|
|||
}
|
||||
// #2
|
||||
if ( lhsIsDateTime && rhsIsDateTime ) {
|
||||
return Hibernate.DOUBLE;
|
||||
return StandardBasicTypes.DOUBLE;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
||||
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
|
@ -23,7 +23,9 @@
|
|||
*/
|
||||
package org.hibernate.hql.ast.tree;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import antlr.SemanticException;
|
||||
import antlr.collections.AST;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.TypeMismatchException;
|
||||
import org.hibernate.engine.SessionFactoryImplementor;
|
||||
|
@ -31,9 +33,8 @@ import org.hibernate.hql.antlr.HqlSqlTokenTypes;
|
|||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.param.ParameterSpecification;
|
||||
import org.hibernate.type.OneToOneType;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
import antlr.SemanticException;
|
||||
import antlr.collections.AST;
|
||||
|
||||
/**
|
||||
* Contract for nodes representing binary operators.
|
||||
|
@ -141,9 +142,7 @@ public class BinaryLogicOperatorNode extends HqlSqlWalkerNode implements BinaryO
|
|||
lhsEmbeddedCompositeParameterSpecification,
|
||||
rhsEmbeddedCompositeParameterSpecification, this );
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
protected void translate( int valueElements, int comparisonType,
|
||||
String comparisonText, String[] lhsElementTexts,
|
||||
String[] rhsElementTexts,
|
||||
|
@ -240,7 +239,7 @@ public class BinaryLogicOperatorNode extends HqlSqlWalkerNode implements BinaryO
|
|||
@Override
|
||||
public Type getDataType() {
|
||||
// logic operators by definition resolve to booleans
|
||||
return Hibernate.BOOLEAN;
|
||||
return StandardBasicTypes.BOOLEAN;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,78 +1,73 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.hql.ast.tree;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.QueryException;
|
||||
import org.hibernate.engine.SessionFactoryImplementor;
|
||||
import org.hibernate.type.LiteralType;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
* Represents a boolean literal within a query.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class BooleanLiteralNode extends LiteralNode implements ExpectedTypeAwareNode {
|
||||
private Type expectedType;
|
||||
|
||||
public Type getDataType() {
|
||||
return expectedType == null ? Hibernate.BOOLEAN : expectedType;
|
||||
}
|
||||
|
||||
public Boolean getValue() {
|
||||
return getType() == TRUE ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setExpectedType(Type expectedType) {
|
||||
this.expectedType = expectedType;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Type getExpectedType() {
|
||||
return expectedType;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getRenderText(SessionFactoryImplementor sessionFactory) {
|
||||
try {
|
||||
return typeAsLiteralType().objectToSQLString( getValue(), sessionFactory.getDialect() );
|
||||
}
|
||||
catch( Throwable t ) {
|
||||
throw new QueryException( "Unable to render boolean literal value", t );
|
||||
}
|
||||
}
|
||||
|
||||
private LiteralType typeAsLiteralType() {
|
||||
return (LiteralType) getDataType();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
import org.hibernate.QueryException;
|
||||
import org.hibernate.engine.SessionFactoryImplementor;
|
||||
import org.hibernate.type.LiteralType;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
* Represents a boolean literal within a query.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class BooleanLiteralNode extends LiteralNode implements ExpectedTypeAwareNode {
|
||||
private Type expectedType;
|
||||
|
||||
public Type getDataType() {
|
||||
return expectedType == null ? StandardBasicTypes.BOOLEAN : expectedType;
|
||||
}
|
||||
|
||||
public Boolean getValue() {
|
||||
return getType() == TRUE ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpectedType(Type expectedType) {
|
||||
this.expectedType = expectedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getExpectedType() {
|
||||
return expectedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings( {"unchecked"})
|
||||
public String getRenderText(SessionFactoryImplementor sessionFactory) {
|
||||
try {
|
||||
return typeAsLiteralType().objectToSQLString( getValue(), sessionFactory.getDialect() );
|
||||
}
|
||||
catch( Throwable t ) {
|
||||
throw new QueryException( "Unable to render boolean literal value", t );
|
||||
}
|
||||
}
|
||||
|
||||
private LiteralType typeAsLiteralType() {
|
||||
return (LiteralType) getDataType();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
||||
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
|
@ -20,14 +20,15 @@
|
|||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
package org.hibernate.hql.ast.tree;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import antlr.SemanticException;
|
||||
|
||||
import org.hibernate.hql.antlr.HqlSqlTokenTypes;
|
||||
import org.hibernate.hql.ast.util.ColumnHelper;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
import antlr.SemanticException;
|
||||
|
||||
/**
|
||||
* Represents a literal.
|
||||
|
@ -43,22 +44,22 @@ public class LiteralNode extends AbstractSelectExpression implements HqlSqlToken
|
|||
public Type getDataType() {
|
||||
switch ( getType() ) {
|
||||
case NUM_INT:
|
||||
return Hibernate.INTEGER;
|
||||
return StandardBasicTypes.INTEGER;
|
||||
case NUM_FLOAT:
|
||||
return Hibernate.FLOAT;
|
||||
return StandardBasicTypes.FLOAT;
|
||||
case NUM_LONG:
|
||||
return Hibernate.LONG;
|
||||
return StandardBasicTypes.LONG;
|
||||
case NUM_DOUBLE:
|
||||
return Hibernate.DOUBLE;
|
||||
return StandardBasicTypes.DOUBLE;
|
||||
case NUM_BIG_INTEGER:
|
||||
return Hibernate.BIG_INTEGER;
|
||||
return StandardBasicTypes.BIG_INTEGER;
|
||||
case NUM_BIG_DECIMAL:
|
||||
return Hibernate.BIG_DECIMAL;
|
||||
return StandardBasicTypes.BIG_DECIMAL;
|
||||
case QUOTED_STRING:
|
||||
return Hibernate.STRING;
|
||||
return StandardBasicTypes.STRING;
|
||||
case TRUE:
|
||||
case FALSE:
|
||||
return Hibernate.BOOLEAN;
|
||||
return StandardBasicTypes.BOOLEAN;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
||||
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
|
@ -20,10 +20,10 @@
|
|||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
package org.hibernate.hql.ast.tree;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
|
@ -43,6 +43,6 @@ public class UnaryLogicOperatorNode extends HqlSqlWalkerNode implements UnaryOpe
|
|||
|
||||
public Type getDataType() {
|
||||
// logic operators by definition resolve to booleans
|
||||
return Hibernate.BOOLEAN;
|
||||
return StandardBasicTypes.BOOLEAN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
||||
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
|
@ -20,19 +20,20 @@
|
|||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
package org.hibernate.hql.classic;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import org.hibernate.QueryException;
|
||||
import org.hibernate.dialect.function.SQLFunction;
|
||||
import org.hibernate.hql.QuerySplitter;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
* Parsers the select clause of a Hibernate query.
|
||||
|
@ -146,7 +147,7 @@ public class SelectParser implements Parser {
|
|||
q.appendScalarSelectToken( token );
|
||||
if ( "*".equals( token ) ) {
|
||||
// special case
|
||||
q.addSelectScalar( getFunction( "count", q ).getReturnType( Hibernate.LONG, q.getFactory() ) );
|
||||
q.addSelectScalar( getFunction( "count", q ).getReturnType( StandardBasicTypes.LONG, q.getFactory() ) );
|
||||
}
|
||||
}
|
||||
else if ( getFunction( lctoken, q ) != null && token.equals( q.unalias( token ) ) ) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
||||
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
|
@ -20,9 +20,9 @@
|
|||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
package org.hibernate.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
@ -38,9 +38,9 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.MappingException;
|
||||
|
@ -48,21 +48,23 @@ import org.hibernate.NonUniqueResultException;
|
|||
import org.hibernate.PropertyNotFoundException;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.QueryException;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.engine.QueryParameters;
|
||||
import org.hibernate.engine.RowSelection;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.engine.TypedValue;
|
||||
import org.hibernate.engine.query.ParameterMetadata;
|
||||
import org.hibernate.hql.classic.ParserHelper;
|
||||
import org.hibernate.internal.util.MarkerObject;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||
import org.hibernate.property.Getter;
|
||||
import org.hibernate.proxy.HibernateProxyHelper;
|
||||
import org.hibernate.transform.ResultTransformer;
|
||||
import org.hibernate.type.SerializableType;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.internal.util.MarkerObject;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
|
||||
/**
|
||||
* Abstract implementation of the Query interface.
|
||||
|
@ -408,7 +410,7 @@ public abstract class AbstractQueryImpl implements Query {
|
|||
|
||||
public Query setParameter(int position, Object val) throws HibernateException {
|
||||
if (val == null) {
|
||||
setParameter( position, val, Hibernate.SERIALIZABLE );
|
||||
setParameter( position, val, StandardBasicTypes.SERIALIZABLE );
|
||||
}
|
||||
else {
|
||||
setParameter( position, val, determineType( position, val ) );
|
||||
|
@ -420,7 +422,7 @@ public abstract class AbstractQueryImpl implements Query {
|
|||
if (val == null) {
|
||||
Type type = parameterMetadata.getNamedParameterExpectedType( name );
|
||||
if ( type == null ) {
|
||||
type = Hibernate.SERIALIZABLE;
|
||||
type = StandardBasicTypes.SERIALIZABLE;
|
||||
}
|
||||
setParameter( name, val, type );
|
||||
}
|
||||
|
@ -491,7 +493,7 @@ public abstract class AbstractQueryImpl implements Query {
|
|||
throw new HibernateException("Could not determine a type for class: " + typename);
|
||||
}
|
||||
}
|
||||
return Hibernate.entity(clazz);
|
||||
return ( (Session) session ).getTypeHelper().entity( clazz );
|
||||
}
|
||||
else {
|
||||
return type;
|
||||
|
@ -499,84 +501,84 @@ public abstract class AbstractQueryImpl implements Query {
|
|||
}
|
||||
|
||||
public Query setString(int position, String val) {
|
||||
setParameter(position, val, Hibernate.STRING);
|
||||
setParameter(position, val, StandardBasicTypes.STRING);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setCharacter(int position, char val) {
|
||||
setParameter(position, new Character(val), Hibernate.CHARACTER);
|
||||
setParameter(position, new Character(val), StandardBasicTypes.CHARACTER);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setBoolean(int position, boolean val) {
|
||||
Boolean valueToUse = val ? Boolean.TRUE : Boolean.FALSE;
|
||||
Type typeToUse = determineType( position, valueToUse, Hibernate.BOOLEAN );
|
||||
Type typeToUse = determineType( position, valueToUse, StandardBasicTypes.BOOLEAN );
|
||||
setParameter( position, valueToUse, typeToUse );
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setByte(int position, byte val) {
|
||||
setParameter(position, new Byte(val), Hibernate.BYTE);
|
||||
setParameter(position, new Byte(val), StandardBasicTypes.BYTE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setShort(int position, short val) {
|
||||
setParameter(position, new Short(val), Hibernate.SHORT);
|
||||
setParameter(position, new Short(val), StandardBasicTypes.SHORT);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setInteger(int position, int val) {
|
||||
setParameter(position, new Integer(val), Hibernate.INTEGER);
|
||||
setParameter(position, new Integer(val), StandardBasicTypes.INTEGER);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setLong(int position, long val) {
|
||||
setParameter(position, new Long(val), Hibernate.LONG);
|
||||
setParameter(position, new Long(val), StandardBasicTypes.LONG);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setFloat(int position, float val) {
|
||||
setParameter(position, new Float(val), Hibernate.FLOAT);
|
||||
setParameter(position, new Float(val), StandardBasicTypes.FLOAT);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setDouble(int position, double val) {
|
||||
setParameter(position, new Double(val), Hibernate.DOUBLE);
|
||||
setParameter(position, new Double(val), StandardBasicTypes.DOUBLE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setBinary(int position, byte[] val) {
|
||||
setParameter(position, val, Hibernate.BINARY);
|
||||
setParameter(position, val, StandardBasicTypes.BINARY);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setText(int position, String val) {
|
||||
setParameter(position, val, Hibernate.TEXT);
|
||||
setParameter(position, val, StandardBasicTypes.TEXT);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setSerializable(int position, Serializable val) {
|
||||
setParameter(position, val, Hibernate.SERIALIZABLE);
|
||||
setParameter(position, val, StandardBasicTypes.SERIALIZABLE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setDate(int position, Date date) {
|
||||
setParameter(position, date, Hibernate.DATE);
|
||||
setParameter(position, date, StandardBasicTypes.DATE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setTime(int position, Date date) {
|
||||
setParameter(position, date, Hibernate.TIME);
|
||||
setParameter(position, date, StandardBasicTypes.TIME);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setTimestamp(int position, Date date) {
|
||||
setParameter(position, date, Hibernate.TIMESTAMP);
|
||||
setParameter(position, date, StandardBasicTypes.TIMESTAMP);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setEntity(int position, Object val) {
|
||||
setParameter( position, val, Hibernate.entity( resolveEntityName( val ) ) );
|
||||
setParameter( position, val, ( (Session) session ).getTypeHelper().entity( resolveEntityName( val ) ) );
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -588,134 +590,134 @@ public abstract class AbstractQueryImpl implements Query {
|
|||
}
|
||||
|
||||
public Query setLocale(int position, Locale locale) {
|
||||
setParameter(position, locale, Hibernate.LOCALE);
|
||||
setParameter(position, locale, StandardBasicTypes.LOCALE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setCalendar(int position, Calendar calendar) {
|
||||
setParameter(position, calendar, Hibernate.CALENDAR);
|
||||
setParameter(position, calendar, StandardBasicTypes.CALENDAR);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setCalendarDate(int position, Calendar calendar) {
|
||||
setParameter(position, calendar, Hibernate.CALENDAR_DATE);
|
||||
setParameter(position, calendar, StandardBasicTypes.CALENDAR_DATE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setBinary(String name, byte[] val) {
|
||||
setParameter(name, val, Hibernate.BINARY);
|
||||
setParameter(name, val, StandardBasicTypes.BINARY);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setText(String name, String val) {
|
||||
setParameter(name, val, Hibernate.TEXT);
|
||||
setParameter(name, val, StandardBasicTypes.TEXT);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setBoolean(String name, boolean val) {
|
||||
Boolean valueToUse = val ? Boolean.TRUE : Boolean.FALSE;
|
||||
Type typeToUse = determineType( name, valueToUse, Hibernate.BOOLEAN );
|
||||
Type typeToUse = determineType( name, valueToUse, StandardBasicTypes.BOOLEAN );
|
||||
setParameter( name, valueToUse, typeToUse );
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setByte(String name, byte val) {
|
||||
setParameter(name, new Byte(val), Hibernate.BYTE);
|
||||
setParameter(name, new Byte(val), StandardBasicTypes.BYTE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setCharacter(String name, char val) {
|
||||
setParameter(name, new Character(val), Hibernate.CHARACTER);
|
||||
setParameter(name, new Character(val), StandardBasicTypes.CHARACTER);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setDate(String name, Date date) {
|
||||
setParameter(name, date, Hibernate.DATE);
|
||||
setParameter(name, date, StandardBasicTypes.DATE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setDouble(String name, double val) {
|
||||
setParameter(name, new Double(val), Hibernate.DOUBLE);
|
||||
setParameter(name, new Double(val), StandardBasicTypes.DOUBLE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setEntity(String name, Object val) {
|
||||
setParameter( name, val, Hibernate.entity( resolveEntityName( val ) ) );
|
||||
setParameter( name, val, ( (Session) session ).getTypeHelper().entity( resolveEntityName( val ) ) );
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setFloat(String name, float val) {
|
||||
setParameter(name, new Float(val), Hibernate.FLOAT);
|
||||
setParameter(name, new Float(val), StandardBasicTypes.FLOAT);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setInteger(String name, int val) {
|
||||
setParameter(name, new Integer(val), Hibernate.INTEGER);
|
||||
setParameter(name, new Integer(val), StandardBasicTypes.INTEGER);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setLocale(String name, Locale locale) {
|
||||
setParameter(name, locale, Hibernate.LOCALE);
|
||||
setParameter(name, locale, StandardBasicTypes.LOCALE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setCalendar(String name, Calendar calendar) {
|
||||
setParameter(name, calendar, Hibernate.CALENDAR);
|
||||
setParameter(name, calendar, StandardBasicTypes.CALENDAR);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setCalendarDate(String name, Calendar calendar) {
|
||||
setParameter(name, calendar, Hibernate.CALENDAR_DATE);
|
||||
setParameter(name, calendar, StandardBasicTypes.CALENDAR_DATE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setLong(String name, long val) {
|
||||
setParameter(name, new Long(val), Hibernate.LONG);
|
||||
setParameter(name, new Long(val), StandardBasicTypes.LONG);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setSerializable(String name, Serializable val) {
|
||||
setParameter(name, val, Hibernate.SERIALIZABLE);
|
||||
setParameter(name, val, StandardBasicTypes.SERIALIZABLE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setShort(String name, short val) {
|
||||
setParameter(name, new Short(val), Hibernate.SHORT);
|
||||
setParameter(name, new Short(val), StandardBasicTypes.SHORT);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setString(String name, String val) {
|
||||
setParameter(name, val, Hibernate.STRING);
|
||||
setParameter(name, val, StandardBasicTypes.STRING);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setTime(String name, Date date) {
|
||||
setParameter(name, date, Hibernate.TIME);
|
||||
setParameter(name, date, StandardBasicTypes.TIME);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setTimestamp(String name, Date date) {
|
||||
setParameter(name, date, Hibernate.TIMESTAMP);
|
||||
setParameter(name, date, StandardBasicTypes.TIMESTAMP);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setBigDecimal(int position, BigDecimal number) {
|
||||
setParameter(position, number, Hibernate.BIG_DECIMAL);
|
||||
setParameter(position, number, StandardBasicTypes.BIG_DECIMAL);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setBigDecimal(String name, BigDecimal number) {
|
||||
setParameter(name, number, Hibernate.BIG_DECIMAL);
|
||||
setParameter(name, number, StandardBasicTypes.BIG_DECIMAL);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setBigInteger(int position, BigInteger number) {
|
||||
setParameter(position, number, Hibernate.BIG_INTEGER);
|
||||
setParameter(position, number, StandardBasicTypes.BIG_INTEGER);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query setBigInteger(String name, BigInteger number) {
|
||||
setParameter(name, number, Hibernate.BIG_INTEGER);
|
||||
setParameter(name, number, StandardBasicTypes.BIG_INTEGER);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
||||
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
|
@ -20,9 +20,9 @@
|
|||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
package org.hibernate.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.sql.Blob;
|
||||
|
@ -34,17 +34,19 @@ import java.util.Calendar;
|
|||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.ScrollableResults;
|
||||
import org.hibernate.engine.QueryParameters;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.hql.HolderInstantiator;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.loader.Loader;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* Implementation of the <tt>ScrollableResults</tt> interface
|
||||
|
@ -187,75 +189,75 @@ public abstract class AbstractScrollableResults implements ScrollableResults {
|
|||
}
|
||||
|
||||
public final BigDecimal getBigDecimal(int col) throws HibernateException {
|
||||
return (BigDecimal) getFinal(col, Hibernate.BIG_DECIMAL);
|
||||
return (BigDecimal) getFinal(col, StandardBasicTypes.BIG_DECIMAL);
|
||||
}
|
||||
|
||||
public final BigInteger getBigInteger(int col) throws HibernateException {
|
||||
return (BigInteger) getFinal(col, Hibernate.BIG_INTEGER);
|
||||
return (BigInteger) getFinal(col, StandardBasicTypes.BIG_INTEGER);
|
||||
}
|
||||
|
||||
public final byte[] getBinary(int col) throws HibernateException {
|
||||
return (byte[]) getFinal(col, Hibernate.BINARY);
|
||||
return (byte[]) getFinal(col, StandardBasicTypes.BINARY);
|
||||
}
|
||||
|
||||
public final String getText(int col) throws HibernateException {
|
||||
return (String) getFinal(col, Hibernate.TEXT);
|
||||
return (String) getFinal(col, StandardBasicTypes.TEXT);
|
||||
}
|
||||
|
||||
public final Blob getBlob(int col) throws HibernateException {
|
||||
return (Blob) getNonFinal(col, Hibernate.BLOB);
|
||||
return (Blob) getNonFinal(col, StandardBasicTypes.BLOB);
|
||||
}
|
||||
|
||||
public final Clob getClob(int col) throws HibernateException {
|
||||
return (Clob) getNonFinal(col, Hibernate.CLOB);
|
||||
return (Clob) getNonFinal(col, StandardBasicTypes.CLOB);
|
||||
}
|
||||
|
||||
public final Boolean getBoolean(int col) throws HibernateException {
|
||||
return (Boolean) getFinal(col, Hibernate.BOOLEAN);
|
||||
return (Boolean) getFinal(col, StandardBasicTypes.BOOLEAN);
|
||||
}
|
||||
|
||||
public final Byte getByte(int col) throws HibernateException {
|
||||
return (Byte) getFinal(col, Hibernate.BYTE);
|
||||
return (Byte) getFinal(col, StandardBasicTypes.BYTE);
|
||||
}
|
||||
|
||||
public final Character getCharacter(int col) throws HibernateException {
|
||||
return (Character) getFinal(col, Hibernate.CHARACTER);
|
||||
return (Character) getFinal(col, StandardBasicTypes.CHARACTER);
|
||||
}
|
||||
|
||||
public final Date getDate(int col) throws HibernateException {
|
||||
return (Date) getNonFinal(col, Hibernate.TIMESTAMP);
|
||||
return (Date) getNonFinal(col, StandardBasicTypes.TIMESTAMP);
|
||||
}
|
||||
|
||||
public final Calendar getCalendar(int col) throws HibernateException {
|
||||
return (Calendar) getNonFinal(col, Hibernate.CALENDAR);
|
||||
return (Calendar) getNonFinal(col, StandardBasicTypes.CALENDAR);
|
||||
}
|
||||
|
||||
public final Double getDouble(int col) throws HibernateException {
|
||||
return (Double) getFinal(col, Hibernate.DOUBLE);
|
||||
return (Double) getFinal(col, StandardBasicTypes.DOUBLE);
|
||||
}
|
||||
|
||||
public final Float getFloat(int col) throws HibernateException {
|
||||
return (Float) getFinal(col, Hibernate.FLOAT);
|
||||
return (Float) getFinal(col, StandardBasicTypes.FLOAT);
|
||||
}
|
||||
|
||||
public final Integer getInteger(int col) throws HibernateException {
|
||||
return (Integer) getFinal(col, Hibernate.INTEGER);
|
||||
return (Integer) getFinal(col, StandardBasicTypes.INTEGER);
|
||||
}
|
||||
|
||||
public final Long getLong(int col) throws HibernateException {
|
||||
return (Long) getFinal(col, Hibernate.LONG);
|
||||
return (Long) getFinal(col, StandardBasicTypes.LONG);
|
||||
}
|
||||
|
||||
public final Short getShort(int col) throws HibernateException {
|
||||
return (Short) getFinal(col, Hibernate.SHORT);
|
||||
return (Short) getFinal(col, StandardBasicTypes.SHORT);
|
||||
}
|
||||
|
||||
public final String getString(int col) throws HibernateException {
|
||||
return (String) getFinal(col, Hibernate.STRING);
|
||||
return (String) getFinal(col, StandardBasicTypes.STRING);
|
||||
}
|
||||
|
||||
public final Locale getLocale(int col) throws HibernateException {
|
||||
return (Locale) getFinal(col, Hibernate.LOCALE);
|
||||
return (Locale) getFinal(col, StandardBasicTypes.LOCALE);
|
||||
}
|
||||
|
||||
/*public final Currency getCurrency(int col) throws HibernateException {
|
||||
|
@ -263,7 +265,7 @@ public abstract class AbstractScrollableResults implements ScrollableResults {
|
|||
}*/
|
||||
|
||||
public final TimeZone getTimeZone(int col) throws HibernateException {
|
||||
return (TimeZone) getNonFinal(col, Hibernate.TIMEZONE);
|
||||
return (TimeZone) getNonFinal(col, StandardBasicTypes.TIMEZONE);
|
||||
}
|
||||
|
||||
public final Type getType(int i) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
||||
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
|
@ -20,12 +20,12 @@
|
|||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
package org.hibernate.persister.collection;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import org.hibernate.QueryException;
|
||||
import org.hibernate.persister.entity.PropertyMapping;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
|
@ -48,7 +48,7 @@ public class CollectionPropertyMapping implements PropertyMapping {
|
|||
return memberPersister.getIndexType();
|
||||
}
|
||||
else if ( propertyName.equals(CollectionPropertyNames.COLLECTION_SIZE) ) {
|
||||
return Hibernate.INTEGER;
|
||||
return StandardBasicTypes.INTEGER;
|
||||
}
|
||||
else if ( propertyName.equals(CollectionPropertyNames.COLLECTION_MAX_INDEX) ) {
|
||||
return memberPersister.getIndexType();
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
||||
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
|
@ -20,9 +20,9 @@
|
|||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
package org.hibernate.persister.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -30,8 +30,8 @@ import java.util.HashSet;
|
|||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.MappingException;
|
||||
|
@ -51,6 +51,7 @@ import org.hibernate.mapping.Subclass;
|
|||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.sql.SelectFragment;
|
||||
import org.hibernate.sql.SimpleSelect;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
|
@ -243,7 +244,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
|
|||
}
|
||||
|
||||
public Type getDiscriminatorType() {
|
||||
return Hibernate.INTEGER;
|
||||
return StandardBasicTypes.INTEGER;
|
||||
}
|
||||
|
||||
public String getDiscriminatorSQLValue() {
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.type;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.PreparedStatement;
|
||||
|
@ -29,10 +30,11 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.dom4j.Node;
|
||||
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.TransientObjectException;
|
||||
|
@ -196,10 +198,11 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
|
|||
public String toLoggableString(Object value, SessionFactoryImplementor factory)
|
||||
throws HibernateException {
|
||||
//TODO: terrible implementation!
|
||||
return value==null ?
|
||||
"null" :
|
||||
Hibernate.entity( HibernateProxyHelper.getClassWithoutInitializingProxy(value) )
|
||||
.toLoggableString(value, factory);
|
||||
return value == null
|
||||
? "null"
|
||||
: factory.getTypeHelper()
|
||||
.entity( HibernateProxyHelper.getClassWithoutInitializingProxy( value ) )
|
||||
.toLoggableString( value, factory );
|
||||
}
|
||||
|
||||
public Object fromXMLNode(Node xml, Mapping factory) throws HibernateException {
|
||||
|
|
|
@ -65,8 +65,12 @@ public final class TypeFactory implements Serializable {
|
|||
private SessionFactoryImplementor factory;
|
||||
|
||||
public void injectSessionFactory(SessionFactoryImplementor factory) {
|
||||
if (this.factory != null) LOG.scopingTypesToSessionFactoryAfterAlreadyScoped(this.factory, factory);
|
||||
else LOG.trace("Scoping types to session factory " + factory);
|
||||
if (this.factory != null) {
|
||||
LOG.scopingTypesToSessionFactoryAfterAlreadyScoped( this.factory, factory );
|
||||
}
|
||||
else {
|
||||
LOG.trace( "Scoping types to session factory " + factory );
|
||||
}
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.TestingDatabaseInfo;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
@ -43,6 +42,7 @@ import org.hibernate.impl.SessionImpl;
|
|||
import org.hibernate.jdbc.Work;
|
||||
import org.hibernate.mapping.SimpleAuxiliaryDatabaseObject;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -91,7 +91,7 @@ public class SequenceHiLoGeneratorNoIncrementTest extends BaseUnitTestCase {
|
|||
Dialect dialect = new H2Dialect();
|
||||
|
||||
generator = new SequenceHiLoGenerator();
|
||||
generator.configure( Hibernate.LONG, properties, dialect );
|
||||
generator.configure( StandardBasicTypes.LONG, properties, dialect );
|
||||
|
||||
cfg = TestingDatabaseInfo.buildBaseConfiguration()
|
||||
.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.TestingDatabaseInfo;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
@ -43,6 +42,7 @@ import org.hibernate.impl.SessionImpl;
|
|||
import org.hibernate.jdbc.Work;
|
||||
import org.hibernate.mapping.SimpleAuxiliaryDatabaseObject;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -91,7 +91,7 @@ public class SequenceHiLoGeneratorTest extends BaseUnitTestCase {
|
|||
Dialect dialect = new H2Dialect();
|
||||
|
||||
generator = new SequenceHiLoGenerator();
|
||||
generator.configure( Hibernate.LONG, properties, dialect );
|
||||
generator.configure( StandardBasicTypes.LONG, properties, dialect );
|
||||
|
||||
cfg = TestingDatabaseInfo.buildBaseConfiguration()
|
||||
.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.TestingDatabaseInfo;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
@ -43,6 +42,7 @@ import org.hibernate.impl.SessionImpl;
|
|||
import org.hibernate.jdbc.Work;
|
||||
import org.hibernate.mapping.SimpleAuxiliaryDatabaseObject;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -93,7 +93,7 @@ public class TableHiLoGeneratorTest extends BaseUnitTestCase {
|
|||
Dialect dialect = new H2Dialect();
|
||||
|
||||
generator = new TableHiLoGenerator();
|
||||
generator.configure( Hibernate.LONG, properties, dialect );
|
||||
generator.configure( StandardBasicTypes.LONG, properties, dialect );
|
||||
|
||||
cfg = TestingDatabaseInfo.buildBaseConfiguration()
|
||||
.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||
|
|
|
@ -1,248 +1,249 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.id.enhanced;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.cfg.ObjectNameNormalizer;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.id.PersistentIdentifierGenerator;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Tests that SequenceStyleGenerator configures itself as expected in various scenarios
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@SuppressWarnings({ "deprecation" })
|
||||
public class SequenceStyleConfigUnitTest extends BaseUnitTestCase {
|
||||
private void assertClassAssignability(Class expected, Class actual) {
|
||||
if ( ! expected.isAssignableFrom( actual ) ) {
|
||||
fail( "Actual type [" + actual.getName() + "] is not assignable to expected type [" + expected.getName() + "]" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test all params defaulted with a dialect supporting sequences
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultedSequenceBackedConfiguration() {
|
||||
Dialect dialect = new SequenceDialect();
|
||||
Properties props = buildGeneratorPropertiesBase();
|
||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||
generator.configure( Hibernate.LONG, props, dialect );
|
||||
|
||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.NoopOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||
}
|
||||
|
||||
private Properties buildGeneratorPropertiesBase() {
|
||||
Properties props = new Properties();
|
||||
props.put(
|
||||
PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER,
|
||||
new ObjectNameNormalizer() {
|
||||
protected boolean isUseQuotedIdentifiersGlobally() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected NamingStrategy getNamingStrategy() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
return props;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test all params defaulted with a dialect which does not support sequences
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultedTableBackedConfiguration() {
|
||||
Dialect dialect = new TableDialect();
|
||||
Properties props = buildGeneratorPropertiesBase();
|
||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||
generator.configure( Hibernate.LONG, props, dialect );
|
||||
|
||||
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.NoopOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test default optimizer selection for sequence backed generators
|
||||
* based on the configured increment size; both in the case of the
|
||||
* dialect supporting pooled sequences (pooled) and not (hilo)
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultOptimizerBasedOnIncrementBackedBySequence() {
|
||||
Properties props = buildGeneratorPropertiesBase();
|
||||
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "10" );
|
||||
|
||||
// for dialects which do not support pooled sequences, we default to pooled+table
|
||||
Dialect dialect = new SequenceDialect();
|
||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||
generator.configure( Hibernate.LONG, props, dialect );
|
||||
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.PooledOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||
|
||||
// for dialects which do support pooled sequences, we default to pooled+sequence
|
||||
dialect = new PooledSequenceDialect();
|
||||
generator = new SequenceStyleGenerator();
|
||||
generator.configure( Hibernate.LONG, props, dialect );
|
||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.PooledOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test default optimizer selection for table backed generators
|
||||
* based on the configured increment size. Here we always prefer
|
||||
* pooled.
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultOptimizerBasedOnIncrementBackedByTable() {
|
||||
Properties props = buildGeneratorPropertiesBase();
|
||||
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "10" );
|
||||
Dialect dialect = new TableDialect();
|
||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||
generator.configure( Hibernate.LONG, props, dialect );
|
||||
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.PooledOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test forcing of table as backing strucuture with dialect supporting sequences
|
||||
*/
|
||||
@Test
|
||||
public void testForceTableUse() {
|
||||
Dialect dialect = new SequenceDialect();
|
||||
Properties props = buildGeneratorPropertiesBase();
|
||||
props.setProperty( SequenceStyleGenerator.FORCE_TBL_PARAM, "true" );
|
||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||
generator.configure( Hibernate.LONG, props, dialect );
|
||||
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.NoopOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test explicitly specifying both optimizer and increment
|
||||
*/
|
||||
@Test
|
||||
public void testExplicitOptimizerWithExplicitIncrementSize() {
|
||||
// with sequence ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
final Dialect dialect = new SequenceDialect();
|
||||
|
||||
// optimizer=none w/ increment > 1 => should honor optimizer
|
||||
Properties props = buildGeneratorPropertiesBase();
|
||||
props.setProperty( SequenceStyleGenerator.OPT_PARAM, OptimizerFactory.NONE );
|
||||
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "20" );
|
||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||
generator.configure( Hibernate.LONG, props, dialect );
|
||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.NoopOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( 1, generator.getOptimizer().getIncrementSize() );
|
||||
assertEquals( 1, generator.getDatabaseStructure().getIncrementSize() );
|
||||
|
||||
// optimizer=hilo w/ increment > 1 => hilo
|
||||
props = buildGeneratorPropertiesBase();
|
||||
props.setProperty( SequenceStyleGenerator.OPT_PARAM, OptimizerFactory.HILO );
|
||||
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "20" );
|
||||
generator = new SequenceStyleGenerator();
|
||||
generator.configure( Hibernate.LONG, props, dialect );
|
||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.HiLoOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( 20, generator.getOptimizer().getIncrementSize() );
|
||||
assertEquals( 20, generator.getDatabaseStructure().getIncrementSize() );
|
||||
|
||||
// optimizer=pooled w/ increment > 1 => hilo
|
||||
props = buildGeneratorPropertiesBase();
|
||||
props.setProperty( SequenceStyleGenerator.OPT_PARAM, OptimizerFactory.POOL );
|
||||
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "20" );
|
||||
generator = new SequenceStyleGenerator();
|
||||
generator.configure( Hibernate.LONG, props, dialect );
|
||||
// because the dialect reports to not support pooled seqyences, the expectation is that we will
|
||||
// use a table for the backing structure...
|
||||
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.PooledOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( 20, generator.getOptimizer().getIncrementSize() );
|
||||
assertEquals( 20, generator.getDatabaseStructure().getIncrementSize() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPreferPooledLoSettingHonored() {
|
||||
final Dialect dialect = new PooledSequenceDialect();
|
||||
|
||||
Properties props = buildGeneratorPropertiesBase();
|
||||
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "20" );
|
||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||
generator.configure( Hibernate.LONG, props, dialect );
|
||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.PooledOptimizer.class, generator.getOptimizer().getClass() );
|
||||
|
||||
props.setProperty( Environment.PREFER_POOLED_VALUES_LO, "true" );
|
||||
generator = new SequenceStyleGenerator();
|
||||
generator.configure( Hibernate.LONG, props, dialect );
|
||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.PooledLoOptimizer.class, generator.getOptimizer().getClass() );
|
||||
}
|
||||
|
||||
private static class TableDialect extends Dialect {
|
||||
public boolean supportsSequences() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static class SequenceDialect extends Dialect {
|
||||
public boolean supportsSequences() {
|
||||
return true;
|
||||
}
|
||||
public boolean supportsPooledSequences() {
|
||||
return false;
|
||||
}
|
||||
public String getSequenceNextValString(String sequenceName) throws MappingException {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private static class PooledSequenceDialect extends SequenceDialect {
|
||||
public boolean supportsPooledSequences() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.id.enhanced;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.cfg.ObjectNameNormalizer;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.id.PersistentIdentifierGenerator;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Tests that SequenceStyleGenerator configures itself as expected in various scenarios
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@SuppressWarnings({ "deprecation" })
|
||||
public class SequenceStyleConfigUnitTest extends BaseUnitTestCase {
|
||||
private void assertClassAssignability(Class expected, Class actual) {
|
||||
if ( ! expected.isAssignableFrom( actual ) ) {
|
||||
fail( "Actual type [" + actual.getName() + "] is not assignable to expected type [" + expected.getName() + "]" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test all params defaulted with a dialect supporting sequences
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultedSequenceBackedConfiguration() {
|
||||
Dialect dialect = new SequenceDialect();
|
||||
Properties props = buildGeneratorPropertiesBase();
|
||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||
generator.configure( StandardBasicTypes.LONG, props, dialect );
|
||||
|
||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.NoopOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||
}
|
||||
|
||||
private Properties buildGeneratorPropertiesBase() {
|
||||
Properties props = new Properties();
|
||||
props.put(
|
||||
PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER,
|
||||
new ObjectNameNormalizer() {
|
||||
protected boolean isUseQuotedIdentifiersGlobally() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected NamingStrategy getNamingStrategy() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
return props;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test all params defaulted with a dialect which does not support sequences
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultedTableBackedConfiguration() {
|
||||
Dialect dialect = new TableDialect();
|
||||
Properties props = buildGeneratorPropertiesBase();
|
||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||
generator.configure( StandardBasicTypes.LONG, props, dialect );
|
||||
|
||||
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.NoopOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test default optimizer selection for sequence backed generators
|
||||
* based on the configured increment size; both in the case of the
|
||||
* dialect supporting pooled sequences (pooled) and not (hilo)
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultOptimizerBasedOnIncrementBackedBySequence() {
|
||||
Properties props = buildGeneratorPropertiesBase();
|
||||
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "10" );
|
||||
|
||||
// for dialects which do not support pooled sequences, we default to pooled+table
|
||||
Dialect dialect = new SequenceDialect();
|
||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||
generator.configure( StandardBasicTypes.LONG, props, dialect );
|
||||
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.PooledOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||
|
||||
// for dialects which do support pooled sequences, we default to pooled+sequence
|
||||
dialect = new PooledSequenceDialect();
|
||||
generator = new SequenceStyleGenerator();
|
||||
generator.configure( StandardBasicTypes.LONG, props, dialect );
|
||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.PooledOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test default optimizer selection for table backed generators
|
||||
* based on the configured increment size. Here we always prefer
|
||||
* pooled.
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultOptimizerBasedOnIncrementBackedByTable() {
|
||||
Properties props = buildGeneratorPropertiesBase();
|
||||
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "10" );
|
||||
Dialect dialect = new TableDialect();
|
||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||
generator.configure( StandardBasicTypes.LONG, props, dialect );
|
||||
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.PooledOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test forcing of table as backing strucuture with dialect supporting sequences
|
||||
*/
|
||||
@Test
|
||||
public void testForceTableUse() {
|
||||
Dialect dialect = new SequenceDialect();
|
||||
Properties props = buildGeneratorPropertiesBase();
|
||||
props.setProperty( SequenceStyleGenerator.FORCE_TBL_PARAM, "true" );
|
||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||
generator.configure( StandardBasicTypes.LONG, props, dialect );
|
||||
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.NoopOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test explicitly specifying both optimizer and increment
|
||||
*/
|
||||
@Test
|
||||
public void testExplicitOptimizerWithExplicitIncrementSize() {
|
||||
// with sequence ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
final Dialect dialect = new SequenceDialect();
|
||||
|
||||
// optimizer=none w/ increment > 1 => should honor optimizer
|
||||
Properties props = buildGeneratorPropertiesBase();
|
||||
props.setProperty( SequenceStyleGenerator.OPT_PARAM, OptimizerFactory.NONE );
|
||||
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "20" );
|
||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||
generator.configure( StandardBasicTypes.LONG, props, dialect );
|
||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.NoopOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( 1, generator.getOptimizer().getIncrementSize() );
|
||||
assertEquals( 1, generator.getDatabaseStructure().getIncrementSize() );
|
||||
|
||||
// optimizer=hilo w/ increment > 1 => hilo
|
||||
props = buildGeneratorPropertiesBase();
|
||||
props.setProperty( SequenceStyleGenerator.OPT_PARAM, OptimizerFactory.HILO );
|
||||
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "20" );
|
||||
generator = new SequenceStyleGenerator();
|
||||
generator.configure( StandardBasicTypes.LONG, props, dialect );
|
||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.HiLoOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( 20, generator.getOptimizer().getIncrementSize() );
|
||||
assertEquals( 20, generator.getDatabaseStructure().getIncrementSize() );
|
||||
|
||||
// optimizer=pooled w/ increment > 1 => hilo
|
||||
props = buildGeneratorPropertiesBase();
|
||||
props.setProperty( SequenceStyleGenerator.OPT_PARAM, OptimizerFactory.POOL );
|
||||
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "20" );
|
||||
generator = new SequenceStyleGenerator();
|
||||
generator.configure( StandardBasicTypes.LONG, props, dialect );
|
||||
// because the dialect reports to not support pooled seqyences, the expectation is that we will
|
||||
// use a table for the backing structure...
|
||||
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.PooledOptimizer.class, generator.getOptimizer().getClass() );
|
||||
assertEquals( 20, generator.getOptimizer().getIncrementSize() );
|
||||
assertEquals( 20, generator.getDatabaseStructure().getIncrementSize() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPreferPooledLoSettingHonored() {
|
||||
final Dialect dialect = new PooledSequenceDialect();
|
||||
|
||||
Properties props = buildGeneratorPropertiesBase();
|
||||
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "20" );
|
||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||
generator.configure( StandardBasicTypes.LONG, props, dialect );
|
||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.PooledOptimizer.class, generator.getOptimizer().getClass() );
|
||||
|
||||
props.setProperty( Environment.PREFER_POOLED_VALUES_LO, "true" );
|
||||
generator = new SequenceStyleGenerator();
|
||||
generator.configure( StandardBasicTypes.LONG, props, dialect );
|
||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||
assertClassAssignability( OptimizerFactory.PooledLoOptimizer.class, generator.getOptimizer().getClass() );
|
||||
}
|
||||
|
||||
private static class TableDialect extends Dialect {
|
||||
public boolean supportsSequences() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static class SequenceDialect extends Dialect {
|
||||
public boolean supportsSequences() {
|
||||
return true;
|
||||
}
|
||||
public boolean supportsPooledSequences() {
|
||||
return false;
|
||||
}
|
||||
public String getSequenceNextValString(String sequenceName) throws MappingException {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private static class PooledSequenceDialect extends SequenceDialect {
|
||||
public boolean supportsPooledSequences() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.hibernate.StaleStateException;
|
|||
import org.hibernate.Transaction;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -377,7 +378,7 @@ public class EntityTest extends BaseCoreFunctionalTestCase {
|
|||
s = openSession();
|
||||
tx = s.beginTransaction();
|
||||
Query q = s.createQuery( "from Flight f where f.departureDate = :departureDate" );
|
||||
q.setParameter( "departureDate", airFrance.getDepartureDate(), Hibernate.DATE );
|
||||
q.setParameter( "departureDate", airFrance.getDepartureDate(), StandardBasicTypes.DATE );
|
||||
Flight copyAirFrance = (Flight) q.uniqueResult();
|
||||
assertNotNull( copyAirFrance );
|
||||
assertEquals(
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
//$Id$
|
||||
package org.hibernate.test.annotations.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Currency;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
|
||||
|
@ -22,12 +24,12 @@ public class MonetaryAmountUserType implements CompositeUserType {
|
|||
}
|
||||
|
||||
public Type[] getPropertyTypes() {
|
||||
return new Type[]{Hibernate.BIG_DECIMAL, Hibernate.CURRENCY};
|
||||
return new Type[]{ StandardBasicTypes.BIG_DECIMAL, StandardBasicTypes.CURRENCY };
|
||||
}
|
||||
|
||||
public Object getPropertyValue(Object component, int property) throws HibernateException {
|
||||
MonetaryAmount ma = (MonetaryAmount) component;
|
||||
return property == 0 ? (Object) ma.getAmount() : (Object) ma.getCurrency();
|
||||
return property == 0 ? ma.getAmount() : ma.getCurrency();
|
||||
}
|
||||
|
||||
public void setPropertyValue(Object component, int property, Object value)
|
||||
|
@ -60,8 +62,8 @@ public class MonetaryAmountUserType implements CompositeUserType {
|
|||
|
||||
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
||||
throws HibernateException, SQLException {
|
||||
BigDecimal amt = (BigDecimal) Hibernate.BIG_DECIMAL.nullSafeGet( rs, names[0], session);
|
||||
Currency cur = (Currency) Hibernate.CURRENCY.nullSafeGet( rs, names[1], session );
|
||||
BigDecimal amt = StandardBasicTypes.BIG_DECIMAL.nullSafeGet( rs, names[0], session);
|
||||
Currency cur = StandardBasicTypes.CURRENCY.nullSafeGet( rs, names[1], session );
|
||||
if ( amt == null ) return null;
|
||||
return new MonetaryAmount( amt, cur );
|
||||
}
|
||||
|
@ -73,8 +75,8 @@ public class MonetaryAmountUserType implements CompositeUserType {
|
|||
MonetaryAmount ma = (MonetaryAmount) value;
|
||||
BigDecimal amt = ma == null ? null : ma.getAmount();
|
||||
Currency cur = ma == null ? null : ma.getCurrency();
|
||||
Hibernate.BIG_DECIMAL.nullSafeSet( st, amt, index, session );
|
||||
Hibernate.CURRENCY.nullSafeSet( st, cur, index + 1, session );
|
||||
StandardBasicTypes.BIG_DECIMAL.nullSafeSet( st, amt, index, session );
|
||||
StandardBasicTypes.CURRENCY.nullSafeSet( st, cur, index + 1, session );
|
||||
}
|
||||
|
||||
public Object deepCopy(Object value) throws HibernateException {
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
//$Id$
|
||||
package org.hibernate.test.annotations.type;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
|
||||
|
@ -15,9 +16,12 @@ import org.hibernate.usertype.CompositeUserType;
|
|||
*/
|
||||
public class MyOidType implements CompositeUserType {
|
||||
|
||||
public static final String[] PROPERTY_NAMES = new String[]{"high", "middle", "low", "other"};
|
||||
public static final Type[] TYPES = new Type[]{Hibernate.INTEGER, Hibernate.INTEGER, Hibernate.INTEGER, Hibernate.INTEGER};
|
||||
|
||||
public static final String[] PROPERTY_NAMES = new String[]{
|
||||
"high", "middle", "low", "other"
|
||||
};
|
||||
public static final Type[] TYPES = new Type[]{
|
||||
StandardBasicTypes.INTEGER, StandardBasicTypes.INTEGER, StandardBasicTypes.INTEGER, StandardBasicTypes.INTEGER
|
||||
};
|
||||
|
||||
public String[] getPropertyNames() {
|
||||
return PROPERTY_NAMES;
|
||||
|
@ -91,10 +95,10 @@ public class MyOidType implements CompositeUserType {
|
|||
public Object nullSafeGet(
|
||||
ResultSet aResultSet, String[] names, SessionImplementor aSessionImplementor, Object aObject
|
||||
) throws HibernateException, SQLException {
|
||||
Integer highval = (Integer) Hibernate.INTEGER.nullSafeGet( aResultSet, names[0], aSessionImplementor );
|
||||
Integer midval = (Integer) Hibernate.INTEGER.nullSafeGet( aResultSet, names[1], aSessionImplementor );
|
||||
Integer lowval = (Integer) Hibernate.INTEGER.nullSafeGet( aResultSet, names[2], aSessionImplementor );
|
||||
Integer other = (Integer) Hibernate.INTEGER.nullSafeGet( aResultSet, names[3], aSessionImplementor );
|
||||
Integer highval = StandardBasicTypes.INTEGER.nullSafeGet( aResultSet, names[0], aSessionImplementor );
|
||||
Integer midval = StandardBasicTypes.INTEGER.nullSafeGet( aResultSet, names[1], aSessionImplementor );
|
||||
Integer lowval = StandardBasicTypes.INTEGER.nullSafeGet( aResultSet, names[2], aSessionImplementor );
|
||||
Integer other = StandardBasicTypes.INTEGER.nullSafeGet( aResultSet, names[3], aSessionImplementor );
|
||||
|
||||
return new MyOid( highval, midval, lowval, other );
|
||||
}
|
||||
|
@ -111,10 +115,10 @@ public class MyOidType implements CompositeUserType {
|
|||
c = (MyOid) value;
|
||||
}
|
||||
|
||||
Hibernate.INTEGER.nullSafeSet( aPreparedStatement, c.getHigh(), index, aSessionImplementor );
|
||||
Hibernate.INTEGER.nullSafeSet( aPreparedStatement, c.getMiddle(), index + 1, aSessionImplementor );
|
||||
Hibernate.INTEGER.nullSafeSet( aPreparedStatement, c.getLow(), index + 2, aSessionImplementor );
|
||||
Hibernate.INTEGER.nullSafeSet( aPreparedStatement, c.getOther(), index + 3, aSessionImplementor );
|
||||
StandardBasicTypes.INTEGER.nullSafeSet( aPreparedStatement, c.getHigh(), index, aSessionImplementor );
|
||||
StandardBasicTypes.INTEGER.nullSafeSet( aPreparedStatement, c.getMiddle(), index + 1, aSessionImplementor );
|
||||
StandardBasicTypes.INTEGER.nullSafeSet( aPreparedStatement, c.getLow(), index + 2, aSessionImplementor );
|
||||
StandardBasicTypes.INTEGER.nullSafeSet( aPreparedStatement, c.getOther(), index + 3, aSessionImplementor );
|
||||
}
|
||||
|
||||
public Object deepCopy(Object aObject) throws HibernateException {
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.hibernate.dialect.function.SQLFunction;
|
|||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.Formula;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -88,7 +89,7 @@ public class ComponentTest extends BaseCoreFunctionalTestCase {
|
|||
else {
|
||||
List args = new ArrayList();
|
||||
args.add( "dob" );
|
||||
f.setFormula( yearFunction.render( Hibernate.INTEGER, args, null ) );
|
||||
f.setFormula( yearFunction.render( StandardBasicTypes.INTEGER, args, null ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.hibernate.dialect.function.SQLFunction;
|
|||
import org.hibernate.mapping.Collection;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.Formula;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -61,7 +62,7 @@ public class CompositeElementTest extends BaseCoreFunctionalTestCase {
|
|||
if ( lengthFunction != null ) {
|
||||
ArrayList args = new ArrayList();
|
||||
args.add( "bio" );
|
||||
f.setFormula( lengthFunction.render( Hibernate.INTEGER, args, null ) );
|
||||
f.setFormula( lengthFunction.render( StandardBasicTypes.INTEGER, args, null ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ import org.hibernate.criterion.Subqueries;
|
|||
import org.hibernate.exception.SQLGrammarException;
|
||||
import org.hibernate.internal.util.SerializationHelper;
|
||||
import org.hibernate.transform.Transformers;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
import org.junit.Test;
|
||||
|
@ -658,7 +659,7 @@ public class CriteriaQueryTest extends BaseCoreFunctionalTestCase {
|
|||
.add( Projections.sqlProjection(
|
||||
"1 as constOne, count(*) as countStar",
|
||||
new String[] { "constOne", "countStar" },
|
||||
new Type[] { Hibernate.INTEGER, Hibernate.INTEGER }
|
||||
new Type[] { StandardBasicTypes.INTEGER, StandardBasicTypes.INTEGER }
|
||||
) );
|
||||
|
||||
Object[] array = (Object[]) s.createCriteria(Enrolment.class)
|
||||
|
@ -930,7 +931,7 @@ public class CriteriaQueryTest extends BaseCoreFunctionalTestCase {
|
|||
.add( Projections.sqlProjection(
|
||||
"1 as constOne, count(*) as countStar",
|
||||
new String[] { "constOne", "countStar" },
|
||||
new Type[] { Hibernate.INTEGER, Hibernate.INTEGER }
|
||||
new Type[] { StandardBasicTypes.INTEGER, StandardBasicTypes.INTEGER }
|
||||
) );
|
||||
|
||||
Object[] array = (Object[]) s.createCriteria(Enrolment.class)
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
//$Id: MonetoryAmountUserType.java 6235 2005-03-29 03:17:49Z oneovthafew $
|
||||
package org.hibernate.test.cut;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Currency;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
|
||||
|
@ -22,12 +23,12 @@ public class MonetoryAmountUserType implements CompositeUserType {
|
|||
}
|
||||
|
||||
public Type[] getPropertyTypes() {
|
||||
return new Type[] { Hibernate.BIG_DECIMAL, Hibernate.CURRENCY };
|
||||
return new Type[] { StandardBasicTypes.BIG_DECIMAL, StandardBasicTypes.CURRENCY };
|
||||
}
|
||||
|
||||
public Object getPropertyValue(Object component, int property) throws HibernateException {
|
||||
MonetoryAmount ma = (MonetoryAmount) component;
|
||||
return property==0 ? (Object) ma.getAmount() : (Object) ma.getCurrency();
|
||||
return property==0 ? ma.getAmount() : ma.getCurrency();
|
||||
}
|
||||
|
||||
public void setPropertyValue(Object component, int property, Object value)
|
||||
|
@ -60,8 +61,8 @@ public class MonetoryAmountUserType implements CompositeUserType {
|
|||
|
||||
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
||||
throws HibernateException, SQLException {
|
||||
BigDecimal amt = (BigDecimal) Hibernate.BIG_DECIMAL.nullSafeGet( rs, names[0], session );
|
||||
Currency cur = (Currency) Hibernate.CURRENCY.nullSafeGet( rs, names[1], session );
|
||||
BigDecimal amt = StandardBasicTypes.BIG_DECIMAL.nullSafeGet( rs, names[0], session );
|
||||
Currency cur = StandardBasicTypes.CURRENCY.nullSafeGet( rs, names[1], session );
|
||||
if (amt==null) return null;
|
||||
return new MonetoryAmount(amt, cur);
|
||||
}
|
||||
|
@ -71,8 +72,8 @@ public class MonetoryAmountUserType implements CompositeUserType {
|
|||
MonetoryAmount ma = (MonetoryAmount) value;
|
||||
BigDecimal amt = ma == null ? null : ma.getAmount();
|
||||
Currency cur = ma == null ? null : ma.getCurrency();
|
||||
Hibernate.BIG_DECIMAL.nullSafeSet(st, amt, index, session);
|
||||
Hibernate.CURRENCY.nullSafeSet(st, cur, index+1, session);
|
||||
StandardBasicTypes.BIG_DECIMAL.nullSafeSet(st, amt, index, session);
|
||||
StandardBasicTypes.CURRENCY.nullSafeSet(st, cur, index+1, session);
|
||||
}
|
||||
|
||||
public Object deepCopy(Object value) throws HibernateException {
|
||||
|
|
|
@ -1,102 +1,102 @@
|
|||
package org.hibernate.test.hql;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.type.IntegerType;
|
||||
import org.hibernate.usertype.EnhancedUserType;
|
||||
|
||||
/**
|
||||
* A custom type for mapping {@link org.hibernate.test.hql.Classification} instances
|
||||
* to the respective db column.
|
||||
* </p>
|
||||
* THis is largely intended to mimic JDK5 enum support in JPA. Here we are
|
||||
* using the approach of storing the ordinal values, rather than the names.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ClassificationType implements EnhancedUserType {
|
||||
|
||||
public int[] sqlTypes() {
|
||||
return new int[] { Types.TINYINT };
|
||||
}
|
||||
|
||||
public Class returnedClass() {
|
||||
return Classification.class;
|
||||
}
|
||||
|
||||
public boolean equals(Object x, Object y) throws HibernateException {
|
||||
if ( x == null && y == null ) {
|
||||
return false;
|
||||
}
|
||||
else if ( x != null ) {
|
||||
return x.equals( y );
|
||||
}
|
||||
else {
|
||||
return y.equals( x );
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode(Object x) throws HibernateException {
|
||||
return x.hashCode();
|
||||
}
|
||||
|
||||
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
|
||||
Integer ordinal = IntegerType.INSTANCE.nullSafeGet( rs, names[0], session );
|
||||
return Classification.valueOf( ordinal );
|
||||
}
|
||||
|
||||
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
|
||||
Integer ordinal = value == null ? null : new Integer( ( ( Classification ) value ).ordinal() );
|
||||
Hibernate.INTEGER.nullSafeSet( st, ordinal, index, session );
|
||||
}
|
||||
|
||||
public Object deepCopy(Object value) throws HibernateException {
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isMutable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Serializable disassemble(Object value) throws HibernateException {
|
||||
return ( Classification ) value;
|
||||
}
|
||||
|
||||
public Object assemble(Serializable cached, Object owner) throws HibernateException {
|
||||
return cached;
|
||||
}
|
||||
|
||||
public Object replace(Object original, Object target, Object owner) throws HibernateException {
|
||||
return original;
|
||||
}
|
||||
|
||||
public String objectToSQLString(Object value) {
|
||||
return extractOrdinalString( value );
|
||||
}
|
||||
|
||||
public String toXMLString(Object value) {
|
||||
return extractName( value );
|
||||
}
|
||||
|
||||
public Object fromXMLString(String xmlValue) {
|
||||
return Classification.valueOf( xmlValue );
|
||||
}
|
||||
|
||||
private String extractName(Object obj) {
|
||||
return ( ( Classification ) obj ).name();
|
||||
}
|
||||
|
||||
private int extractOrdinal(Object value) {
|
||||
return ( ( Classification ) value ).ordinal();
|
||||
}
|
||||
|
||||
private String extractOrdinalString(Object value) {
|
||||
return Integer.toString( extractOrdinal( value ) );
|
||||
}
|
||||
}
|
||||
package org.hibernate.test.hql;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.usertype.EnhancedUserType;
|
||||
|
||||
/**
|
||||
* A custom type for mapping {@link org.hibernate.test.hql.Classification} instances
|
||||
* to the respective db column.
|
||||
* </p>
|
||||
* THis is largely intended to mimic JDK5 enum support in JPA. Here we are
|
||||
* using the approach of storing the ordinal values, rather than the names.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ClassificationType implements EnhancedUserType {
|
||||
|
||||
public int[] sqlTypes() {
|
||||
return new int[] { Types.TINYINT };
|
||||
}
|
||||
|
||||
public Class returnedClass() {
|
||||
return Classification.class;
|
||||
}
|
||||
|
||||
public boolean equals(Object x, Object y) throws HibernateException {
|
||||
if ( x == null && y == null ) {
|
||||
return false;
|
||||
}
|
||||
else if ( x != null ) {
|
||||
return x.equals( y );
|
||||
}
|
||||
else {
|
||||
return y.equals( x );
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode(Object x) throws HibernateException {
|
||||
return x.hashCode();
|
||||
}
|
||||
|
||||
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
|
||||
Integer ordinal = StandardBasicTypes.INTEGER.nullSafeGet( rs, names[0], session );
|
||||
return Classification.valueOf( ordinal );
|
||||
}
|
||||
|
||||
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
|
||||
Integer ordinal = value == null ? null : new Integer( ( ( Classification ) value ).ordinal() );
|
||||
StandardBasicTypes.INTEGER.nullSafeSet( st, ordinal, index, session );
|
||||
}
|
||||
|
||||
public Object deepCopy(Object value) throws HibernateException {
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isMutable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Serializable disassemble(Object value) throws HibernateException {
|
||||
return ( Classification ) value;
|
||||
}
|
||||
|
||||
public Object assemble(Serializable cached, Object owner) throws HibernateException {
|
||||
return cached;
|
||||
}
|
||||
|
||||
public Object replace(Object original, Object target, Object owner) throws HibernateException {
|
||||
return original;
|
||||
}
|
||||
|
||||
public String objectToSQLString(Object value) {
|
||||
return extractOrdinalString( value );
|
||||
}
|
||||
|
||||
public String toXMLString(Object value) {
|
||||
return extractName( value );
|
||||
}
|
||||
|
||||
public Object fromXMLString(String xmlValue) {
|
||||
return Classification.valueOf( xmlValue );
|
||||
}
|
||||
|
||||
private String extractName(Object obj) {
|
||||
return ( ( Classification ) obj ).name();
|
||||
}
|
||||
|
||||
private int extractOrdinal(Object value) {
|
||||
return ( ( Classification ) value ).ordinal();
|
||||
}
|
||||
|
||||
private String extractOrdinalString(Object value) {
|
||||
return Integer.toString( extractOrdinal( value ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,109 +1,110 @@
|
|||
package org.hibernate.test.instrument.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.Arrays;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
/**
|
||||
* A simple byte[]-based custom type.
|
||||
*/
|
||||
public class CustomBlobType implements UserType {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Object nullSafeGet(ResultSet rs, String names[], SessionImplementor session, Object owner) throws SQLException {
|
||||
// cast just to make sure...
|
||||
return Hibernate.BINARY.nullSafeGet( rs, names[0], session );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void nullSafeSet(PreparedStatement ps, Object value, int index, SessionImplementor session) throws SQLException, HibernateException {
|
||||
// cast just to make sure...
|
||||
Hibernate.BINARY.nullSafeSet( ps, value, index, session );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Object deepCopy(Object value) {
|
||||
byte result[] = null;
|
||||
|
||||
if ( value != null ) {
|
||||
byte bytes[] = ( byte[] ) value;
|
||||
|
||||
result = new byte[bytes.length];
|
||||
System.arraycopy( bytes, 0, result, 0, bytes.length );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean isMutable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public int[] sqlTypes() {
|
||||
return new int[] { Types.VARBINARY };
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Class returnedClass() {
|
||||
return byte[].class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean equals(Object x, Object y) {
|
||||
return Arrays.equals( ( byte[] ) x, ( byte[] ) y );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Object assemble(Serializable arg0, Object arg1)
|
||||
throws HibernateException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Serializable disassemble(Object arg0)
|
||||
throws HibernateException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public int hashCode(Object arg0)
|
||||
throws HibernateException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Object replace(Object arg0, Object arg1, Object arg2)
|
||||
throws HibernateException {
|
||||
return null;
|
||||
}
|
||||
package org.hibernate.test.instrument.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.Arrays;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
/**
|
||||
* A simple byte[]-based custom type.
|
||||
*/
|
||||
public class CustomBlobType implements UserType {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Object nullSafeGet(ResultSet rs, String names[], SessionImplementor session, Object owner) throws SQLException {
|
||||
// cast just to make sure...
|
||||
return StandardBasicTypes.BINARY.nullSafeGet( rs, names[0], session );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void nullSafeSet(PreparedStatement ps, Object value, int index, SessionImplementor session) throws SQLException, HibernateException {
|
||||
// cast just to make sure...
|
||||
StandardBasicTypes.BINARY.nullSafeSet( ps, value, index, session );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Object deepCopy(Object value) {
|
||||
byte result[] = null;
|
||||
|
||||
if ( value != null ) {
|
||||
byte bytes[] = ( byte[] ) value;
|
||||
|
||||
result = new byte[bytes.length];
|
||||
System.arraycopy( bytes, 0, result, 0, bytes.length );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean isMutable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public int[] sqlTypes() {
|
||||
return new int[] { Types.VARBINARY };
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Class returnedClass() {
|
||||
return byte[].class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean equals(Object x, Object y) {
|
||||
return Arrays.equals( ( byte[] ) x, ( byte[] ) y );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Object assemble(Serializable arg0, Object arg1)
|
||||
throws HibernateException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Serializable disassemble(Object arg0)
|
||||
throws HibernateException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public int hashCode(Object arg0)
|
||||
throws HibernateException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Object replace(Object arg0, Object arg1, Object arg2)
|
||||
throws HibernateException {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -4,8 +4,8 @@ import java.io.Serializable;
|
|||
import java.util.Comparator;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.LockOptions;
|
||||
|
@ -14,7 +14,6 @@ import org.hibernate.cache.access.EntityRegionAccessStrategy;
|
|||
import org.hibernate.cache.entry.CacheEntryStructure;
|
||||
import org.hibernate.cache.entry.UnstructuredCacheEntry;
|
||||
import org.hibernate.engine.CascadeStyle;
|
||||
import org.hibernate.engine.EntityKey;
|
||||
import org.hibernate.engine.Mapping;
|
||||
import org.hibernate.engine.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
|
@ -32,6 +31,7 @@ import org.hibernate.persister.entity.EntityPersister;
|
|||
import org.hibernate.sql.QuerySelect;
|
||||
import org.hibernate.sql.Select;
|
||||
import org.hibernate.tuple.entity.EntityMetamodel;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.VersionType;
|
||||
|
||||
|
@ -434,7 +434,7 @@ public class CustomPersister implements EntityPersister {
|
|||
|
||||
}
|
||||
|
||||
private static final Type[] TYPES = new Type[] { Hibernate.STRING };
|
||||
private static final Type[] TYPES = new Type[] { StandardBasicTypes.STRING };
|
||||
private static final String[] NAMES = new String[] { "name" };
|
||||
private static final boolean[] MUTABILITY = new boolean[] { true };
|
||||
private static final boolean[] GENERATION = new boolean[] { false };
|
||||
|
@ -464,7 +464,7 @@ public class CustomPersister implements EntityPersister {
|
|||
* @see EntityPersister#getIdentifierType()
|
||||
*/
|
||||
public Type getIdentifierType() {
|
||||
return Hibernate.STRING;
|
||||
return StandardBasicTypes.STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -82,6 +82,7 @@ import org.hibernate.jdbc.AbstractReturningWork;
|
|||
import org.hibernate.jdbc.AbstractWork;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -413,7 +414,7 @@ public class FooBarTest extends LegacyTestCase {
|
|||
s.createQuery( "from Baz baz left outer join fetch baz.fooToGlarch" ).list();
|
||||
|
||||
list = s.createQuery( "select foo, bar from Foo foo left outer join foo.foo bar where foo = ?" )
|
||||
.setParameter( 0, foo, Hibernate.entity(Foo.class) )
|
||||
.setParameter( 0, foo, s.getTypeHelper().entity(Foo.class) )
|
||||
.list();
|
||||
Object[] row1 = (Object[]) list.get(0);
|
||||
assertTrue( row1[0]==foo && row1[1]==foo2 );
|
||||
|
@ -491,7 +492,7 @@ public class FooBarTest extends LegacyTestCase {
|
|||
// && !db.equals("weblogic") {
|
||||
if ( !( getDialect() instanceof InterbaseDialect ) ) {
|
||||
list = s.createQuery( "from Foo foo where ? = some elements(foo.component.importantDates)" )
|
||||
.setParameter( 0, new Date(), Hibernate.DATE )
|
||||
.setParameter( 0, new Date(), StandardBasicTypes.DATE )
|
||||
.list();
|
||||
assertTrue( "component query", list.size()==2 );
|
||||
}
|
||||
|
@ -541,11 +542,11 @@ public class FooBarTest extends LegacyTestCase {
|
|||
list = s.createQuery( "select foo.foo from Foo foo" ).list();
|
||||
assertTrue( "query", list.size()==2 );
|
||||
list = s.createQuery( "from Foo foo where foo.id=?" )
|
||||
.setParameter( 0, foo.getKey(), Hibernate.STRING )
|
||||
.setParameter( 0, foo.getKey(), StandardBasicTypes.STRING )
|
||||
.list();
|
||||
assertTrue( "id query", list.size()==1 );
|
||||
list = s.createQuery( "from Foo foo where foo.key=?" )
|
||||
.setParameter( 0, foo.getKey(), Hibernate.STRING )
|
||||
.setParameter( 0, foo.getKey(), StandardBasicTypes.STRING )
|
||||
.list();
|
||||
assertTrue( "named id query", list.size()==1 );
|
||||
assertTrue( "id query", list.get(0)==foo );
|
||||
|
@ -555,19 +556,19 @@ public class FooBarTest extends LegacyTestCase {
|
|||
list = s.createQuery( "from Foo foo where foo.component.subcomponent.name='bar'" ).list();
|
||||
assertTrue( "components of components", list.size()==2 );
|
||||
list = s.createQuery( "select foo.foo from Foo foo where foo.foo.id=?" )
|
||||
.setParameter( 0, foo.getFoo().getKey(), Hibernate.STRING )
|
||||
.setParameter( 0, foo.getFoo().getKey(), StandardBasicTypes.STRING )
|
||||
.list();
|
||||
assertTrue( "by id query", list.size()==1 );
|
||||
assertTrue( "by id returned object", list.get(0)==foo.getFoo() );
|
||||
|
||||
s.createQuery( "from Foo foo where foo.foo = ?" ).setParameter( 0, foo.getFoo(), Hibernate.entity(Foo.class) ).list();
|
||||
s.createQuery( "from Foo foo where foo.foo = ?" ).setParameter( 0, foo.getFoo(), s.getTypeHelper().entity(Foo.class) ).list();
|
||||
|
||||
assertTrue( !s.createQuery( "from Bar bar where bar.string='a string' or bar.string='a string'" )
|
||||
.iterate()
|
||||
.hasNext() );
|
||||
|
||||
iter = s.createQuery( "select foo.component.name, elements(foo.component.importantDates) from Foo foo where foo.foo.id=?" )
|
||||
.setParameter( 0, foo.getFoo().getKey(), Hibernate.STRING )
|
||||
.setParameter( 0, foo.getFoo().getKey(), StandardBasicTypes.STRING )
|
||||
.iterate();
|
||||
int i=0;
|
||||
while ( iter.hasNext() ) {
|
||||
|
@ -628,13 +629,13 @@ public class FooBarTest extends LegacyTestCase {
|
|||
assertTrue( "sum", ( (Long) rs.next() ).longValue()==4 );
|
||||
assertTrue( !rs.hasNext() );
|
||||
rs = s.createQuery( "select count(foo) from Foo foo where foo.id=?" )
|
||||
.setParameter( 0, foo.getKey(), Hibernate.STRING )
|
||||
.setParameter( 0, foo.getKey(), StandardBasicTypes.STRING )
|
||||
.iterate();
|
||||
assertTrue( "id query count", ( (Long) rs.next() ).longValue()==1 );
|
||||
assertTrue( !rs.hasNext() );
|
||||
|
||||
s.createQuery( "from Foo foo where foo.boolean = ?" )
|
||||
.setParameter( 0, new Boolean(true), Hibernate.BOOLEAN )
|
||||
.setParameter( 0, new Boolean(true), StandardBasicTypes.BOOLEAN )
|
||||
.list();
|
||||
|
||||
s.createQuery( "select new Foo(fo.x) from Fo fo" ).list();
|
||||
|
@ -734,7 +735,7 @@ public class FooBarTest extends LegacyTestCase {
|
|||
s.createQuery( "select baz.code, min(baz.count) from Baz baz group by baz.code" ).iterate();
|
||||
|
||||
iter = s.createQuery( "selecT baz from Baz baz where baz.stringDateMap['foo'] is not null or baz.stringDateMap['bar'] = ?" )
|
||||
.setParameter( 0, new Date(), Hibernate.DATE )
|
||||
.setParameter( 0, new Date(), StandardBasicTypes.DATE )
|
||||
.iterate();
|
||||
assertFalse( iter.hasNext() );
|
||||
list = s.createQuery( "select baz from Baz baz where baz.stringDateMap['now'] is not null" ).list();
|
||||
|
@ -2189,16 +2190,16 @@ public class FooBarTest extends LegacyTestCase {
|
|||
List results = s.createQuery(
|
||||
"from Stuff as s where s.foo.id = ? and s.id.id = ? and s.moreStuff.id.intId = ? and s.moreStuff.id.stringId = ?"
|
||||
)
|
||||
.setParameter( 0, bar, Hibernate.entity(Foo.class) )
|
||||
.setParameter( 1, new Long(1234), Hibernate.LONG )
|
||||
.setParameter( 2, new Integer(12), Hibernate.INTEGER )
|
||||
.setParameter( 3, "id", Hibernate.STRING )
|
||||
.setParameter( 0, bar, s.getTypeHelper().entity(Foo.class) )
|
||||
.setParameter( 1, new Long(1234), StandardBasicTypes.LONG )
|
||||
.setParameter( 2, new Integer(12), StandardBasicTypes.INTEGER )
|
||||
.setParameter( 3, "id", StandardBasicTypes.STRING )
|
||||
.list();
|
||||
assertEquals( 1, results.size() );
|
||||
results = s.createQuery( "from Stuff as s where s.foo.id = ? and s.id.id = ? and s.moreStuff.name = ?" )
|
||||
.setParameter( 0, bar, Hibernate.entity(Foo.class) )
|
||||
.setParameter( 1, new Long(1234), Hibernate.LONG )
|
||||
.setParameter( 2, "More Stuff", Hibernate.STRING )
|
||||
.setParameter( 0, bar, s.getTypeHelper().entity(Foo.class) )
|
||||
.setParameter( 1, new Long(1234), StandardBasicTypes.LONG )
|
||||
.setParameter( 2, "More Stuff", StandardBasicTypes.STRING )
|
||||
.list();
|
||||
assertEquals( 1, results.size() );
|
||||
s.createQuery( "from Stuff as s where s.foo.string is not null" ).list();
|
||||
|
@ -2382,20 +2383,20 @@ public class FooBarTest extends LegacyTestCase {
|
|||
s.createQuery( "select max( elements(one.manies) ) from One one" ).iterate();
|
||||
s.createQuery( "select one, elements(one.manies) from One one" ).list();
|
||||
Iterator iter = s.createQuery( "select elements(baz.fooArray) from Baz baz where baz.id=?" )
|
||||
.setParameter( 0, baz.getCode(), Hibernate.STRING )
|
||||
.setParameter( 0, baz.getCode(), StandardBasicTypes.STRING )
|
||||
.iterate();
|
||||
assertTrue( iter.next()==foos[1] && !iter.hasNext() );
|
||||
list = s.createQuery( "select elements(baz.fooArray) from Baz baz where baz.id=?" )
|
||||
.setParameter( 0, baz.getCode(), Hibernate.STRING )
|
||||
.setParameter( 0, baz.getCode(), StandardBasicTypes.STRING )
|
||||
.list();
|
||||
assertEquals( 1, list.size() );
|
||||
iter = s.createQuery( "select indices(baz.fooArray) from Baz baz where baz.id=?" )
|
||||
.setParameter( 0, baz.getCode(), Hibernate.STRING )
|
||||
.setParameter( 0, baz.getCode(), StandardBasicTypes.STRING )
|
||||
.iterate();
|
||||
assertTrue( iter.next().equals( new Integer(1) ) && !iter.hasNext() );
|
||||
|
||||
iter = s.createQuery( "select size(baz.stringSet) from Baz baz where baz.id=?" )
|
||||
.setParameter( 0, baz.getCode(), Hibernate.STRING )
|
||||
.setParameter( 0, baz.getCode(), StandardBasicTypes.STRING )
|
||||
.iterate();
|
||||
assertEquals( new Integer(3), iter.next() );
|
||||
|
||||
|
@ -2990,7 +2991,7 @@ public class FooBarTest extends LegacyTestCase {
|
|||
doDelete( s, "from Trivial" );
|
||||
|
||||
list2 = s.createQuery( "from Foo foo where foo.date = ?" )
|
||||
.setParameter( 0, new java.sql.Date(123), Hibernate.DATE )
|
||||
.setParameter( 0, new java.sql.Date(123), StandardBasicTypes.DATE )
|
||||
.list();
|
||||
assertTrue ( "find by date", list2.size()==4 );
|
||||
Iterator iter = list2.iterator();
|
||||
|
@ -3198,7 +3199,7 @@ public class FooBarTest extends LegacyTestCase {
|
|||
|
||||
s = openSession();
|
||||
s.beginTransaction();
|
||||
assertEquals( 8, doDelete( s, "from Qux q where q.stuff=?", "foo", Hibernate.STRING ) );
|
||||
assertEquals( 8, doDelete( s, "from Qux q where q.stuff=?", "foo", StandardBasicTypes.STRING ) );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
||||
|
@ -4171,7 +4172,7 @@ public class FooBarTest extends LegacyTestCase {
|
|||
"cached object identity",
|
||||
im,
|
||||
s.createQuery( "from Immutable im where im = ?" ).setParameter(
|
||||
0, im, Hibernate.entity( Immutable.class )
|
||||
0, im, s.getTypeHelper().entity( Immutable.class )
|
||||
).uniqueResult()
|
||||
);
|
||||
s.doWork(
|
||||
|
@ -4366,7 +4367,7 @@ public class FooBarTest extends LegacyTestCase {
|
|||
&& !(getDialect() instanceof SAPDBDialect) ) {
|
||||
baz.getFooArray()[0] = null;
|
||||
i = s.createQuery( "from Baz baz where ? in elements(baz.fooArray)" )
|
||||
.setParameter( 0, foo, Hibernate.entity( Foo.class ) )
|
||||
.setParameter( 0, foo, s.getTypeHelper().entity( Foo.class ) )
|
||||
.iterate();
|
||||
assertTrue( !i.hasNext() );
|
||||
baz.getFooArray()[0] = foo;
|
||||
|
@ -4532,8 +4533,8 @@ public class FooBarTest extends LegacyTestCase {
|
|||
s = openSession();
|
||||
s.beginTransaction();
|
||||
List results = s.createQuery( "from Bar bar where bar.object.id = ? and bar.object.class = ?" )
|
||||
.setParameter( 0, oid, Hibernate.LONG )
|
||||
.setParameter( 1, new Character('O'), Hibernate.CHARACTER )
|
||||
.setParameter( 0, oid, StandardBasicTypes.LONG )
|
||||
.setParameter( 1, new Character('O'), StandardBasicTypes.CHARACTER )
|
||||
.list();
|
||||
assertEquals( 1, results.size() );
|
||||
results = s.createQuery( "select one from One one, Bar bar where bar.object.id = one.id and bar.object.class = 'O'" )
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.hibernate.dialect.TimesTenDialect;
|
|||
import org.hibernate.transform.Transformers;
|
||||
import org.hibernate.type.DateType;
|
||||
import org.hibernate.type.EntityType;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.StringType;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
|
@ -425,7 +426,7 @@ public class FumTest extends LegacyTestCase {
|
|||
|
||||
// Try to find the Fum object "fi" that we inserted searching by the date in the id
|
||||
vList = s.createQuery( "from Fum fum where fum.id.short = ?" )
|
||||
.setParameter( 0, new Short(fiShort), Hibernate.SHORT )
|
||||
.setParameter( 0, new Short(fiShort), StandardBasicTypes.SHORT )
|
||||
.list();
|
||||
assertEquals( "find by composite key query (find fi object)", 1, vList.size() );
|
||||
fi = (Fum)vList.get(0);
|
||||
|
@ -433,7 +434,7 @@ public class FumTest extends LegacyTestCase {
|
|||
|
||||
// Make sure we can return all of the objects by searching by the date id
|
||||
vList = s.createQuery( "from Fum fum where fum.id.date <= ? and not fum.fum='FRIEND'" )
|
||||
.setParameter( 0, new Date(), Hibernate.DATE )
|
||||
.setParameter( 0, new Date(), StandardBasicTypes.DATE )
|
||||
.list();
|
||||
assertEquals( "find by composite key query with arguments", 4, vList.size() );
|
||||
s.getTransaction().commit();
|
||||
|
@ -468,7 +469,7 @@ public class FumTest extends LegacyTestCase {
|
|||
fum = (Fum) s.load( Fum.class, fum.getId() );
|
||||
s.createFilter( fum.getQuxArray(), "where this.foo is null" ).list();
|
||||
s.createFilter( fum.getQuxArray(), "where this.foo.id = ?" )
|
||||
.setParameter( 0, "fooid", Hibernate.STRING )
|
||||
.setParameter( 0, "fooid", StandardBasicTypes.STRING )
|
||||
.list();
|
||||
Query f = s.createFilter( fum.getQuxArray(), "where this.foo.id = :fooId" );
|
||||
f.setString("fooId", "abc");
|
||||
|
@ -681,7 +682,7 @@ public class FumTest extends LegacyTestCase {
|
|||
s = openSession();
|
||||
s.beginTransaction();
|
||||
d = (Outer) s.createQuery( "from Outer o where o.id.detailId = ?" )
|
||||
.setParameter( 0, d.getId().getDetailId(), Hibernate.STRING )
|
||||
.setParameter( 0, d.getId().getDetailId(), StandardBasicTypes.STRING )
|
||||
.list()
|
||||
.get(0);
|
||||
s.createQuery( "from Outer o where o.id.master.id.sup.dudu is not null" ).list();
|
||||
|
|
|
@ -6,11 +6,16 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.engine.ForeignKeys;
|
||||
import org.hibernate.engine.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.type.IntegerType;
|
||||
import org.hibernate.type.ManyToOneType;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.StringType;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.TypeFactory;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
|
||||
public class MultiplicityType implements CompositeUserType {
|
||||
|
@ -19,10 +24,21 @@ public class MultiplicityType implements CompositeUserType {
|
|||
"count", "glarch"
|
||||
};
|
||||
private static final int[] SQL_TYPES = new int[] {
|
||||
IntegerType.INSTANCE.getSqlTypeDescriptor().getSqlType(), StringType.INSTANCE.getSqlTypeDescriptor().getSqlType()
|
||||
IntegerType.INSTANCE.getSqlTypeDescriptor().getSqlType(),
|
||||
StringType.INSTANCE.getSqlTypeDescriptor().getSqlType()
|
||||
};
|
||||
private static final Type[] TYPES = new Type[] {
|
||||
IntegerType.INSTANCE, Hibernate.entity(Glarch.class)
|
||||
IntegerType.INSTANCE,
|
||||
new ManyToOneType(
|
||||
new TypeFactory.TypeScope() {
|
||||
@Override
|
||||
public SessionFactoryImplementor resolveFactory() {
|
||||
// todo : can we tie this into org.hibernate.type.TypeFactory.TypeScopeImpl() somehow?
|
||||
throw new HibernateException( "Cannot access SessionFactory from here" );
|
||||
}
|
||||
},
|
||||
Glarch.class.getName()
|
||||
)
|
||||
};
|
||||
|
||||
public String[] getPropertyNames() {
|
||||
|
@ -79,7 +95,7 @@ public class MultiplicityType implements CompositeUserType {
|
|||
throws HibernateException, SQLException {
|
||||
|
||||
Integer c = (Integer) IntegerType.INSTANCE.nullSafeGet( rs, names[0], session );
|
||||
GlarchProxy g = (GlarchProxy) Hibernate.entity(Glarch.class).nullSafeGet(rs, names[1], session, owner);
|
||||
GlarchProxy g = (GlarchProxy) ( (Session) session ).getTypeHelper().entity( Glarch.class ).nullSafeGet(rs, names[1], session, owner);
|
||||
Multiplicity m = new Multiplicity();
|
||||
m.count = c==null ? 0 : c.intValue();
|
||||
m.glarch = g;
|
||||
|
@ -100,8 +116,8 @@ public class MultiplicityType implements CompositeUserType {
|
|||
g = o.glarch;
|
||||
c = new Integer(o.count);
|
||||
}
|
||||
Hibernate.INTEGER.nullSafeSet(st, c, index, session);
|
||||
Hibernate.entity(Glarch.class).nullSafeSet(st, g, index+1, session);
|
||||
StandardBasicTypes.INTEGER.nullSafeSet(st, c, index, session);
|
||||
( (Session) session ).getTypeHelper().entity( Glarch.class ).nullSafeSet(st, g, index+1, session);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ import org.hibernate.engine.EntityEntry;
|
|||
import org.hibernate.impl.SessionImpl;
|
||||
import org.hibernate.jdbc.AbstractWork;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -681,7 +682,7 @@ public class ParentChildTest extends LegacyTestCase {
|
|||
s.createQuery( "select c, c.parent from Child c where c.parent.count=66 order by c.parent.count" ).list();
|
||||
s.createQuery( "select c, c.parent, c.parent.count from Child c order by c.parent.count" ).iterate();
|
||||
List result = s.createQuery( "FROM Parent AS p WHERE p.count = ?" )
|
||||
.setParameter( 0, new Integer(66), Hibernate.INTEGER )
|
||||
.setParameter( 0, new Integer(66), StandardBasicTypes.INTEGER )
|
||||
.list();
|
||||
assertEquals( "1-1 query", 1, result.size() );
|
||||
s.delete(c); s.delete(p);
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.hibernate.proxy.HibernateProxy;
|
|||
import org.hibernate.transform.AliasToBeanConstructorResultTransformer;
|
||||
import org.hibernate.transform.ResultTransformer;
|
||||
import org.hibernate.transform.Transformers;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
import org.junit.Test;
|
||||
|
@ -1789,7 +1790,7 @@ public abstract class AbstractQueryCacheResultTransformerTest extends BaseCoreFu
|
|||
.add( Projections.sqlProjection(
|
||||
"'lame description' as courseDescription",
|
||||
new String[] { "courseDescription" },
|
||||
new Type[] { Hibernate.STRING }
|
||||
new Type[] { StandardBasicTypes.STRING }
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -1966,7 +1967,7 @@ public abstract class AbstractQueryCacheResultTransformerTest extends BaseCoreFu
|
|||
return s.createCriteria( Student.class, "s" )
|
||||
.setProjection(
|
||||
Projections.projectionList()
|
||||
.add( Projections.sqlProjection( "555 as studentNumber", new String[]{ "studentNumber" }, new Type[] { Hibernate.LONG } ) )
|
||||
.add( Projections.sqlProjection( "555 as studentNumber", new String[]{ "studentNumber" }, new Type[] { StandardBasicTypes.LONG } ) )
|
||||
.add( Property.forName( "s.name" ).as( "name" ) )
|
||||
)
|
||||
.addOrder( Order.asc( "s.studentNumber" ) )
|
||||
|
@ -2222,7 +2223,7 @@ public abstract class AbstractQueryCacheResultTransformerTest extends BaseCoreFu
|
|||
( ( SessionFactoryImpl ) sessionFactory() )
|
||||
.getEntityPersister( Student.class.getName() )
|
||||
.getPropertyType( "name" );
|
||||
return ReflectHelper.getConstructor( Student.class, new Type[] {Hibernate.LONG, studentNametype} );
|
||||
return ReflectHelper.getConstructor( Student.class, new Type[] {StandardBasicTypes.LONG, studentNametype} );
|
||||
}
|
||||
};
|
||||
HqlExecutor hqlExecutor = new HqlExecutor() {
|
||||
|
|
|
@ -22,11 +22,12 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.test.version.db;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -70,7 +71,7 @@ public class DbVersionTest extends BaseCoreFunctionalTestCase {
|
|||
t.commit();
|
||||
s.close();
|
||||
|
||||
assertFalse( "owner version not incremented", Hibernate.TIMESTAMP.isEqual( steveTimestamp, steve.getTimestamp() ) );
|
||||
assertFalse( "owner version not incremented", StandardBasicTypes.TIMESTAMP.isEqual( steveTimestamp, steve.getTimestamp() ) );
|
||||
|
||||
steveTimestamp = steve.getTimestamp();
|
||||
Thread.sleep( 1500 );
|
||||
|
@ -82,7 +83,7 @@ public class DbVersionTest extends BaseCoreFunctionalTestCase {
|
|||
t.commit();
|
||||
s.close();
|
||||
|
||||
assertFalse( "owner version not incremented", Hibernate.TIMESTAMP.isEqual( steveTimestamp, steve.getTimestamp() ) );
|
||||
assertFalse( "owner version not incremented", StandardBasicTypes.TIMESTAMP.isEqual( steveTimestamp, steve.getTimestamp() ) );
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
|
@ -103,7 +104,7 @@ public class DbVersionTest extends BaseCoreFunctionalTestCase {
|
|||
t.commit();
|
||||
s.close();
|
||||
|
||||
Timestamp steveTimestamp = ( Timestamp ) steve.getTimestamp();
|
||||
Timestamp steveTimestamp = steve.getTimestamp();
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
|
@ -113,7 +114,7 @@ public class DbVersionTest extends BaseCoreFunctionalTestCase {
|
|||
t.commit();
|
||||
s.close();
|
||||
|
||||
assertTrue( "owner version was incremented", Hibernate.TIMESTAMP.isEqual( steveTimestamp, steve.getTimestamp() ) );
|
||||
assertTrue( "owner version was incremented", StandardBasicTypes.TIMESTAMP.isEqual( steveTimestamp, steve.getTimestamp() ) );
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
|
@ -122,7 +123,7 @@ public class DbVersionTest extends BaseCoreFunctionalTestCase {
|
|||
t.commit();
|
||||
s.close();
|
||||
|
||||
assertTrue( "owner version was incremented", Hibernate.TIMESTAMP.isEqual( steveTimestamp, steve.getTimestamp() ) );
|
||||
assertTrue( "owner version was incremented", StandardBasicTypes.TIMESTAMP.isEqual( steveTimestamp, steve.getTimestamp() ) );
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
|
|
Loading…
Reference in New Issue