📄 typefactory.java
字号:
}
public static CollectionType idbag(String role, String propertyRef, boolean embedded) {
return new IdentifierBagType( role, propertyRef, embedded );
}
public static CollectionType map(String role, String propertyRef, boolean embedded) {
return new MapType( role, propertyRef, embedded );
}
public static CollectionType orderedMap(String role, String propertyRef, boolean embedded) {
return new OrderedMapType( role, propertyRef, embedded );
}
public static CollectionType set(String role, String propertyRef, boolean embedded) {
return new SetType( role, propertyRef, embedded );
}
public static CollectionType orderedSet(String role, String propertyRef, boolean embedded) {
return new OrderedSetType( 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 );
}
/**
* Deep copy values in the first array into the second
*/
public static void deepCopy(Object[] values, Type[] types, boolean[] copy, Object[] target,
SessionImplementor session) throws HibernateException {
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() );
}
}
}
}
/**
* Determine if any of the given field values are dirty, returning an array containing indexes
* of the dirty fields or <tt>null</tt> if no fields are dirty.
*/
/*public static int[] findDirty(Type[] types, Object[] x, Object[] y, boolean[] check,
SessionImplementor session) throws HibernateException {
int[] results = null;
int count = 0;
for ( int i = 0; i < types.length; i++ ) {
if ( check[i] && types[i].isDirty( x[i], y[i], session ) ) {
if ( results == null ) results = new int[types.length];
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
* indexes of the dirty fields or <tt>null</tt> if no fields are dirty.
*/
/*public static int[] findModified(Type[] types, Object[] old, Object[] current, boolean[] check,
SessionImplementor session) throws HibernateException {
int[] results = null;
int count = 0;
for ( int i = 0; i < types.length; i++ ) {
if ( check[i]
&& types[i].isModified( old[i], current[i], session ) ) {
if ( results == null ) results = new int[types.length];
results[count++] = i;
}
}
if ( count == 0 ) {
return null;
}
else {
int[] trimmed = new int[count];
System.arraycopy( results, 0, trimmed, 0, count );
return trimmed;
}
}*/
public static void beforeAssemble(Serializable[] row, Type[] types, SessionImplementor session)
throws HibernateException {
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 Object[] assemble(Serializable[] row, Type[] types, SessionImplementor session,
Object owner) throws HibernateException {
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 Serializable[] disassemble(Object[] row, Type[] types, boolean[] nonCacheable, SessionImplementor session,
Object owner) throws HibernateException {
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 Object[] replace(Object[] original, Object[] target, Type[] types,
SessionImplementor session, Object owner, Map copyCache) throws HibernateException {
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) throws HibernateException {
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;
}
/**
* Determine if any of the given field values are dirty, returning an array containing
* indexes of the dirty fields or <tt>null</tt> if no fields are dirty.
* @param x the current state of the entity
* @param y the snapshot state from the time the object was loaded
*/
public static int[] findDirty(
final StandardProperty[] properties,
final Object[] x,
final Object[] y,
final boolean[][] includeColumns,
final boolean anyUninitializedProperties,
final SessionImplementor session)
throws HibernateException {
int[] results = null;
int count = 0;
int span = properties.length;
for ( int i = 0; i < span; i++ ) {
final boolean dirty = x[i]!=LazyPropertyInitializer.UNFETCHED_PROPERTY //x is the "current" state
&& properties[i].isDirtyCheckable(anyUninitializedProperties)
&& properties[i].getType().isDirty( y[i], x[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 modified, returning an array containing
* indexes of the dirty fields or <tt>null</tt> if no fields are dirty.
* @param x the current state of the entity
* @param y the snapshot state just retrieved from the database
*/
public static int[] findModified(
final StandardProperty[] properties,
final Object[] x,
final Object[] y,
final boolean[][] includeColumns,
final boolean anyUninitializedProperties,
final SessionImplementor session)
throws HibernateException {
int[] results = null;
int count = 0;
int span = properties.length;
for ( int i = 0; i < span; i++ ) {
final boolean modified = x[i]!=LazyPropertyInitializer.UNFETCHED_PROPERTY //x is the "current" state
&& properties[i].isDirtyCheckable(anyUninitializedProperties)
&& properties[i].getType().isModified( y[i], x[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;
}
}
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()
);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -