本文整理汇总了Java中org.hibernate.persister.collection.CollectionPersister类的典型用法代码示例。如果您正苦于以下问题:Java CollectionPersister类的具体用法?Java CollectionPersister怎么用?Java CollectionPersister使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CollectionPersister类属于org.hibernate.persister.collection包,在下文中一共展示了CollectionPersister类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDeletes
import org.hibernate.persister.collection.CollectionPersister; //导入依赖的package包/类
@Override
public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
final java.util.List<Integer> deletes = new ArrayList<Integer>();
final Serializable sn = getSnapshot();
final int snSize = Array.getLength( sn );
final int arraySize = Array.getLength( array );
int end;
if ( snSize > arraySize ) {
for ( int i=arraySize; i<snSize; i++ ) {
deletes.add( i );
}
end = arraySize;
}
else {
end = snSize;
}
for ( int i=0; i<end; i++ ) {
if ( Array.get( array, i ) == null && Array.get( sn, i ) != null ) {
deletes.add( i );
}
}
return deletes.iterator();
}
示例2: addIdToCollectionInfoString
import org.hibernate.persister.collection.CollectionPersister; //导入依赖的package包/类
private static void addIdToCollectionInfoString(
CollectionPersister persister,
Serializable id,
SessionFactoryImplementor factory,
StringBuilder s ) {
// Need to use the identifier type of the collection owner
// since the incoming is value is actually the owner's id.
// Using the collection's key type causes problems with
// property-ref keys.
// Also need to check that the expected identifier type matches
// the given ID. Due to property-ref keys, the collection key
// may not be the owner key.
Type ownerIdentifierType = persister.getOwnerEntityPersister()
.getIdentifierType();
if ( id.getClass().isAssignableFrom(
ownerIdentifierType.getReturnedClass() ) ) {
s.append( ownerIdentifierType.toLoggableString( id, factory ) );
} else {
// TODO: This is a crappy backup if a property-ref is used.
// If the reference is an object w/o toString(), this isn't going to work.
s.append( id.toString() );
}
}
示例3: equalsSnapshot
import org.hibernate.persister.collection.CollectionPersister; //导入依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
final Type elementType = persister.getElementType();
final ArrayList snapshot = (ArrayList) getSnapshot();
final List elements = element.elements( persister.getElementNodeName() );
if ( snapshot.size() != elements.size() ) {
return false;
}
for ( int i=0; i<snapshot.size(); i++ ) {
final Object old = snapshot.get( i );
final Element elem = (Element) elements.get( i );
final Object current = elementType.fromXMLNode( elem, persister.getFactory() );
if ( elementType.isDirty( old, current, getSession() ) ) {
return false;
}
}
return true;
}
示例4: PersistentElementHolder
import org.hibernate.persister.collection.CollectionPersister; //导入依赖的package包/类
/**
* Constructs a PersistentElementHolder
*
* @param session The session
* @param persister The collection persister
* @param key The collection key (the fk value)
*/
@SuppressWarnings("UnusedDeclaration")
public PersistentElementHolder(SessionImplementor session, CollectionPersister persister, Serializable key) {
super( session );
final Element owner = (Element) session.getPersistenceContext().getCollectionOwner( key, persister );
if ( owner == null ) {
throw new AssertionFailure("null owner");
}
final String nodeName = persister.getNodeName();
if ( ".".equals( nodeName ) ) {
element = owner;
}
else {
element = owner.element( nodeName );
if ( element == null ) {
element = owner.addElement( nodeName );
}
}
}
示例5: equalsSnapshot
import org.hibernate.persister.collection.CollectionPersister; //导入依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
final Type elementType = persister.getElementType();
final String indexNode = getIndexAttributeName( persister );
final HashMap snapshot = (HashMap) getSnapshot();
final List elements = element.elements( persister.getElementNodeName() );
if ( snapshot.size() != elements.size() ) {
return false;
}
for ( int i=0; i<snapshot.size(); i++ ) {
final Element elem = (Element) elements.get( i );
final Object old = snapshot.get( getIndex( elem, indexNode, i ) );
final Object current = elementType.fromXMLNode( elem, persister.getFactory() );
if ( elementType.isDirty( old, current, getSession() ) ) {
return false;
}
}
return true;
}
示例6: equalsSnapshot
import org.hibernate.persister.collection.CollectionPersister; //导入依赖的package包/类
@Override
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
final Type elementType = persister.getElementType();
final List sn = (List) getSnapshot();
if ( sn.size()!=this.list.size() ) {
return false;
}
final Iterator itr = list.iterator();
final Iterator snapshotItr = sn.iterator();
while ( itr.hasNext() ) {
if ( elementType.isDirty( itr.next(), snapshotItr.next(), getSession() ) ) {
return false;
}
}
return true;
}
示例7: getSnapshot
import org.hibernate.persister.collection.CollectionPersister; //导入依赖的package包/类
@Override
public Serializable getSnapshot(CollectionPersister persister) throws HibernateException {
// final int length = (array==null) ? tempList.size() : Array.getLength( array );
final int length = Array.getLength( array );
final Serializable result = (Serializable) Array.newInstance( persister.getElementClass(), length );
for ( int i=0; i<length; i++ ) {
// final Object elt = (array==null) ? tempList.get( i ) : Array.get( array, i );
final Object elt = Array.get( array, i );
try {
Array.set( result, i, persister.getElementType().deepCopy( elt, persister.getFactory() ) );
}
catch (IllegalArgumentException iae) {
LOG.invalidArrayElementType( iae.getMessage() );
throw new HibernateException( "Array element type error", iae );
}
}
return result;
}
示例8: makeCollectionQuerySpace
import org.hibernate.persister.collection.CollectionPersister; //导入依赖的package包/类
@Override
public ExpandingCollectionQuerySpace makeCollectionQuerySpace(
String uid,
CollectionPersister collectionPersister,
boolean canJoinsBeRequired) {
checkQuerySpaceDoesNotExist( uid );
final ExpandingCollectionQuerySpace space = new CollectionQuerySpaceImpl(
collectionPersister,
uid,
this,
canJoinsBeRequired
);
registerQuerySpace( space );
return space;
}
示例9: readFrom
import org.hibernate.persister.collection.CollectionPersister; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Object readFrom(
ResultSet rs,
CollectionPersister persister,
CollectionAliases descriptor,
Object owner) throws HibernateException, SQLException {
final Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
if ( element != null ) {
final Object index = persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() );
if ( loadingEntries == null ) {
loadingEntries = new ArrayList<Object[]>();
}
loadingEntries.add( new Object[] { index, element } );
}
return element;
}
示例10: equalsSnapshot
import org.hibernate.persister.collection.CollectionPersister; //导入依赖的package包/类
@Override
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
final Type elementType = persister.getElementType();
final Map snap = (Map) getSnapshot();
if ( snap.size()!= values.size() ) {
return false;
}
for ( int i=0; i<values.size(); i++ ) {
final Object value = values.get( i );
final Object id = identifiers.get( i );
if ( id == null ) {
return false;
}
final Object old = snap.get( id );
if ( elementType.isDirty( old, value, getSession() ) ) {
return false;
}
}
return true;
}
示例11: getNumberOfAssociations
import org.hibernate.persister.collection.CollectionPersister; //导入依赖的package包/类
@Override
public long getNumberOfAssociations(SessionFactory sessionFactory) {
int associationCount = 0;
IgniteDatastoreProvider datastoreProvider = getProvider( sessionFactory );
for ( CollectionPersister collectionPersister : ( (SessionFactoryImplementor) sessionFactory ).getCollectionPersisters().values() ) {
AssociationKeyMetadata associationKeyMetadata = ( (OgmCollectionPersister) collectionPersister ).getAssociationKeyMetadata();
if ( associationKeyMetadata.getAssociationKind() == AssociationKind.ASSOCIATION ) {
IgniteCache<Object, BinaryObject> associationCache = getAssociationCache( sessionFactory, associationKeyMetadata );
StringBuilder query = new StringBuilder( "SELECT " )
.append( StringHelper.realColumnName( associationKeyMetadata.getColumnNames()[0] ) )
.append( " FROM " ).append( associationKeyMetadata.getTable() );
SqlFieldsQuery sqlQuery = datastoreProvider.createSqlFieldsQueryWithLog( query.toString(), null );
Iterable<List<?>> queryResult = associationCache.query( sqlQuery );
Set<Object> uniqs = new HashSet<>();
for ( List<?> row : queryResult ) {
Object value = row.get( 0 );
if ( value != null ) {
uniqs.add( value );
}
}
associationCount += uniqs.size();
}
}
return associationCount;
}
示例12: getDeletes
import org.hibernate.persister.collection.CollectionPersister; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
final List deletes = new ArrayList();
final List sn = (List) getSnapshot();
int end;
if ( sn.size() > list.size() ) {
for ( int i=list.size(); i<sn.size(); i++ ) {
deletes.add( indexIsFormula ? sn.get( i ) : i );
}
end = list.size();
}
else {
end = sn.size();
}
for ( int i=0; i<end; i++ ) {
final Object item = list.get( i );
final Object snapshotItem = sn.get( i );
if ( item == null && snapshotItem != null ) {
deletes.add( indexIsFormula ? snapshotItem : i );
}
}
return deletes.iterator();
}
示例13: disassemble
import org.hibernate.persister.collection.CollectionPersister; //导入依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public Serializable disassemble(CollectionPersister persister) throws HibernateException {
final Type elementType = persister.getElementType();
final String indexNodeName = getIndexAttributeName( persister );
final List elements = element.elements( persister.getElementNodeName() );
final int length = elements.size();
final Serializable[] result = new Serializable[length];
for ( int i=0; i<length; i++ ) {
final Element elem = (Element) elements.get( i );
final Object object = elementType.fromXMLNode( elem, persister.getFactory() );
final Integer index = IntegerType.INSTANCE.fromString( getIndex( elem, indexNodeName, i ) );
result[index] = elementType.disassemble( object, getSession(), null );
}
return result;
}
示例14: replaceElements
import org.hibernate.persister.collection.CollectionPersister; //导入依赖的package包/类
public Object replaceElements(
final Object original,
final Object target,
final Object owner,
final java.util.Map copyCache,
final SessionImplementor session)
throws HibernateException {
CollectionPersister cp = session.getFactory().getCollectionPersister( getRole() );
java.util.Map result = (java.util.Map) target;
result.clear();
Iterator iter = ( (java.util.Map) original ).entrySet().iterator();
while ( iter.hasNext() ) {
java.util.Map.Entry me = (java.util.Map.Entry) iter.next();
Object key = cp.getIndexType().replace( me.getKey(), null, session, owner, copyCache );
Object value = cp.getElementType().replace( me.getValue(), null, session, owner, copyCache );
result.put(key, value);
}
return result;
}
示例15: needsRecreate
import org.hibernate.persister.collection.CollectionPersister; //导入依赖的package包/类
@Override
public boolean needsRecreate(CollectionPersister persister) {
// Workaround for situations like HHH-7072. If the collection element is a component that consists entirely
// of nullable properties, we currently have to forcefully recreate the entire collection. See the use
// of hasNotNullableColumns in the AbstractCollectionPersister constructor for more info. In order to delete
// row-by-row, that would require SQL like "WHERE ( COL = ? OR ( COL is null AND ? is null ) )", rather than
// the current "WHERE COL = ?" (fails for null for most DBs). Note that
// the param would have to be bound twice. Until we eventually add "parameter bind points" concepts to the
// AST in ORM 5+, handling this type of condition is either extremely difficult or impossible. Forcing
// recreation isn't ideal, but not really any other option in ORM 4.
if (persister.getElementType() instanceof ComponentType) {
ComponentType componentType = (ComponentType) persister.getElementType();
return !componentType.hasNotNullProperty();
}
return false;
}