Used internally to obtain instances of
. Applications should use static methods
and constants on
.
| Method from org.hibernate.type.TypeFactory Detail: |
public static CollectionType array(String role,
String propertyRef,
boolean embedded,
Class elementClass) {
return new ArrayType( role, propertyRef, elementClass, embedded );
}
|
public static Object[] assemble(Serializable[] row,
Type[] types,
SessionImplementor session,
Object owner) {
Object[] assembled = new Object[row.length];
for ( int i = 0; i < types.length; i++ ) {
if ( row[i] == LazyPropertyInitializer.UNFETCHED_PROPERTY || row[i] == BackrefPropertyAccessor.UNKNOWN ) {
assembled[i] = row[i];
}
else {
assembled[i] = types[i].assemble( row[i], session, owner );
}
}
return assembled;
}
|
public static CollectionType bag(String role,
String propertyRef,
boolean embedded) {
return new BagType( role, propertyRef, embedded );
}
|
public static Type basic(String name) {
return (Type) BASIC_TYPES.get( name );
}
Given the name of a Hibernate basic type, return an instance of
org.hibernate.type.Type. |
public static void beforeAssemble(Serializable[] row,
Type[] types,
SessionImplementor session) {
for ( int i = 0; i < types.length; i++ ) {
if ( row[i] != LazyPropertyInitializer.UNFETCHED_PROPERTY
&& row[i] != BackrefPropertyAccessor.UNKNOWN ) {
types[i].beforeAssemble( row[i], session );
}
}
}
|
public static CollectionType customCollection(String typeName,
String role,
String propertyRef,
boolean embedded) {
return customCollection( typeName, null, role, propertyRef, embedded );
} Deprecated! Use - #customCollection(String, java.util.Properties, String, String, boolean) instead
|
public static CollectionType customCollection(String typeName,
Properties typeParameters,
String role,
String propertyRef,
boolean embedded) {
Class typeClass;
try {
typeClass = ReflectHelper.classForName( typeName );
}
catch ( ClassNotFoundException cnfe ) {
throw new MappingException( "user collection type class not found: " + typeName, cnfe );
}
CustomCollectionType result = new CustomCollectionType( typeClass, role, propertyRef, embedded );
if ( typeParameters != null ) {
TypeFactory.injectParameters( result.getUserType(), typeParameters );
}
return result;
}
|
public static void deepCopy(Object[] values,
Type[] types,
boolean[] copy,
Object[] target,
SessionImplementor session) {
for ( int i = 0; i < types.length; i++ ) {
if ( copy[i] ) {
if ( values[i] == LazyPropertyInitializer.UNFETCHED_PROPERTY
|| values[i] == BackrefPropertyAccessor.UNKNOWN ) {
target[i] = values[i];
}
else {
target[i] = types[i].deepCopy( values[i], session.getEntityMode(), session
.getFactory() );
}
}
}
}
Deep copy a series of values from one array to another... |
public static Serializable[] disassemble(Object[] row,
Type[] types,
boolean[] nonCacheable,
SessionImplementor session,
Object owner) {
Serializable[] disassembled = new Serializable[row.length];
for ( int i = 0; i < row.length; i++ ) {
if ( nonCacheable!=null && nonCacheable[i] ) {
disassembled[i] = LazyPropertyInitializer.UNFETCHED_PROPERTY;
}
else if ( row[i] == LazyPropertyInitializer.UNFETCHED_PROPERTY || row[i] == BackrefPropertyAccessor.UNKNOWN ) {
disassembled[i] = (Serializable) row[i];
}
else {
disassembled[i] = types[i].disassemble( row[i], session, owner );
}
}
return disassembled;
}
|
public static int[] findDirty(StandardProperty[] properties,
Object[] currentState,
Object[] previousState,
boolean[][] includeColumns,
boolean anyUninitializedProperties,
SessionImplementor session) {
int[] results = null;
int count = 0;
int span = properties.length;
for ( int i = 0; i < span; i++ ) {
final boolean dirty = currentState[i] != LazyPropertyInitializer.UNFETCHED_PROPERTY
&& properties[i].isDirtyCheckable( anyUninitializedProperties )
&& properties[i].getType().isDirty( previousState[i], currentState[i], includeColumns[i], session );
if ( dirty ) {
if ( results == null ) {
results = new int[span];
}
results[count++] = i;
}
}
if ( count == 0 ) {
return null;
}
else {
int[] trimmed = new int[count];
System.arraycopy( results, 0, trimmed, 0, count );
return trimmed;
}
}
Determine if any of the given field values are dirty, returning an array containing
indices of the dirty fields.
If it is determined that no fields are dirty, null is returned. |
public static int[] findModified(StandardProperty[] properties,
Object[] currentState,
Object[] previousState,
boolean[][] includeColumns,
boolean anyUninitializedProperties,
SessionImplementor session) {
int[] results = null;
int count = 0;
int span = properties.length;
for ( int i = 0; i < span; i++ ) {
final boolean modified = currentState[i]!=LazyPropertyInitializer.UNFETCHED_PROPERTY
&& properties[i].isDirtyCheckable(anyUninitializedProperties)
&& properties[i].getType().isModified( previousState[i], currentState[i], includeColumns[i], session );
if ( modified ) {
if ( results == null ) {
results = new int[span];
}
results[count++] = i;
}
}
if ( count == 0 ) {
return null;
}
else {
int[] trimmed = new int[count];
System.arraycopy( results, 0, trimmed, 0, count );
return trimmed;
}
}
Determine if any of the given field values are modified, returning an array containing
indices of the modified fields.
If it is determined that no fields are dirty, null is returned. |
public static Type heuristicType(String typeName) throws MappingException {
return heuristicType( typeName, null );
}
Uses heuristics to deduce a Hibernate type given a string naming the type or Java class.
Return an instance of org.hibernate.type.Type. |
public static Type heuristicType(String typeName,
Properties parameters) throws MappingException {
Type type = TypeFactory.basic( typeName );
if ( type == null ) {
Class typeClass;
try {
typeClass = ReflectHelper.classForName( typeName );
}
catch (ClassNotFoundException cnfe) {
typeClass = null;
}
if ( typeClass != null ) {
if ( Type.class.isAssignableFrom( typeClass ) ) {
try {
type = (Type) typeClass.newInstance();
}
catch (Exception e) {
throw new MappingException(
"Could not instantiate Type: " + typeClass.getName(),
e
);
}
injectParameters(type, parameters);
}
else if ( CompositeUserType.class.isAssignableFrom( typeClass ) ) {
type = new CompositeCustomType( typeClass, parameters );
}
else if ( UserType.class.isAssignableFrom( typeClass ) ) {
type = new CustomType( typeClass, parameters );
}
else if ( Lifecycle.class.isAssignableFrom( typeClass ) ) {
type = Hibernate.entity( typeClass );
}
else if ( Serializable.class.isAssignableFrom( typeClass ) ) {
type = Hibernate.serializable( typeClass );
}
}
}
return type;
}
Uses heuristics to deduce a Hibernate type given a string naming the type or Java class.
Return an instance of org.hibernate.type.Type. |
public static CollectionType idbag(String role,
String propertyRef,
boolean embedded) {
return new IdentifierBagType( role, propertyRef, embedded );
}
|
public static void injectParameters(Object type,
Properties parameters) {
if (type instanceof ParameterizedType) {
( (ParameterizedType) type ).setParameterValues(parameters);
}
else if ( parameters!=null && !parameters.isEmpty() ) {
throw new MappingException(
"type is not parameterized: " +
type.getClass().getName()
);
}
}
|
public static CollectionType list(String role,
String propertyRef,
boolean embedded) {
return new ListType( role, propertyRef, embedded );
}
|
public static EntityType manyToOne(String persistentClass) {
return new ManyToOneType( persistentClass );
}
A many-to-one association type for the given class |
public static EntityType manyToOne(String persistentClass,
boolean lazy) {
return new ManyToOneType( persistentClass, lazy );
}
A many-to-one association type for the given class |
public static EntityType manyToOne(String persistentClass,
String uniqueKeyPropertyName,
boolean lazy,
boolean unwrapProxy,
boolean isEmbeddedInXML,
boolean ignoreNotFound) {
return new ManyToOneType(
persistentClass,
uniqueKeyPropertyName,
lazy,
unwrapProxy,
isEmbeddedInXML,
ignoreNotFound
);
}
A many-to-one association type for the given class |
public static CollectionType map(String role,
String propertyRef,
boolean embedded) {
return new MapType( role, propertyRef, embedded );
}
|
public static EntityType oneToOne(String persistentClass,
ForeignKeyDirection foreignKeyType,
String uniqueKeyPropertyName,
boolean lazy,
boolean unwrapProxy,
boolean isEmbeddedInXML,
String entityName,
String propertyName) {
return new OneToOneType(
persistentClass,
foreignKeyType,
uniqueKeyPropertyName,
lazy,
unwrapProxy,
isEmbeddedInXML,
entityName,
propertyName
);
}
A one-to-one association type for the given class |
public static CollectionType orderedMap(String role,
String propertyRef,
boolean embedded) {
return new OrderedMapType( role, propertyRef, embedded );
}
|
public static CollectionType orderedSet(String role,
String propertyRef,
boolean embedded) {
return new OrderedSetType( role, propertyRef, embedded );
}
|
public static Object[] replace(Object[] original,
Object[] target,
Type[] types,
SessionImplementor session,
Object owner,
Map copyCache) {
Object[] copied = new Object[original.length];
for ( int i = 0; i < types.length; i++ ) {
if ( original[i] == LazyPropertyInitializer.UNFETCHED_PROPERTY
|| original[i] == BackrefPropertyAccessor.UNKNOWN ) {
copied[i] = target[i];
}
else {
copied[i] = types[i].replace( original[i], target[i], session, owner, copyCache );
}
}
return copied;
}
|
public static Object[] replace(Object[] original,
Object[] target,
Type[] types,
SessionImplementor session,
Object owner,
Map copyCache,
ForeignKeyDirection foreignKeyDirection) {
Object[] copied = new Object[original.length];
for ( int i = 0; i < types.length; i++ ) {
if ( original[i] == LazyPropertyInitializer.UNFETCHED_PROPERTY
|| original[i] == BackrefPropertyAccessor.UNKNOWN ) {
copied[i] = target[i];
}
else {
copied[i] = types[i].replace( original[i], target[i], session, owner, copyCache, foreignKeyDirection );
}
}
return copied;
}
|
public static Object[] replaceAssociations(Object[] original,
Object[] target,
Type[] types,
SessionImplementor session,
Object owner,
Map copyCache,
ForeignKeyDirection foreignKeyDirection) {
Object[] copied = new Object[original.length];
for ( int i = 0; i < types.length; i++ ) {
if ( original[i] == LazyPropertyInitializer.UNFETCHED_PROPERTY
|| original[i] == BackrefPropertyAccessor.UNKNOWN ) {
copied[i] = target[i];
}
else if ( types[i].isComponentType() ) {
// need to extract the component values and check for subtype replacements...
AbstractComponentType componentType = ( AbstractComponentType ) types[i];
Type[] subtypes = componentType.getSubtypes();
Object[] origComponentValues = original[i] == null ? new Object[subtypes.length] : componentType.getPropertyValues( original[i], session );
Object[] targetComponentValues = target[i] == null ? new Object[subtypes.length] : componentType.getPropertyValues( target[i], session );
replaceAssociations( origComponentValues, targetComponentValues, subtypes, session, null, copyCache, foreignKeyDirection );
copied[i] = target[i];
}
else if ( !types[i].isAssociationType() ) {
copied[i] = target[i];
}
else {
copied[i] = types[i].replace( original[i], target[i], session, owner, copyCache, foreignKeyDirection );
}
}
return copied;
}
Apply the Type#replace operation across a series of values, as
long as the corresponding Type is an association.
If the corresponding type is a component type, then apply #replaceAssociations
accross the component subtypes but do not replace the component value itself. |
public static CollectionType set(String role,
String propertyRef,
boolean embedded) {
return new SetType( role, propertyRef, embedded );
}
|
public static CollectionType sortedMap(String role,
String propertyRef,
boolean embedded,
Comparator comparator) {
return new SortedMapType( role, propertyRef, comparator, embedded );
}
|
public static CollectionType sortedSet(String role,
String propertyRef,
boolean embedded,
Comparator comparator) {
return new SortedSetType( role, propertyRef, comparator, embedded );
}
|