Java 类org.hibernate.collection.internal.AbstractPersistentCollection 实例源码

项目:meditor    文件:OrikaHibernateFilter.java   
@Override
public <S, D> boolean shouldMap(Type<S> type, String s, S s1, Type<D> type1, String s2, D d,
    MappingContext mappingContext) {
  if (type != null && s1 != null) {
    if (type.isCollection()) {
      if (s1 instanceof AbstractPersistentCollection) {
        return false;
      }

      if (((PersistentSet) s1).wasInitialized()) {
        return false;
      }
    }
  }

  return true;
}
项目:jspresso-ce    文件:HibernateHelper.java   
/**
 * Whenever the entity has dirty persistent collection, make them clean to
 * workaround a "bug" with hibernate since hibernate cannot re-attach a
 * "dirty" detached collection.
 *
 * @param collection    the collection
 * @param targetSession the session that is targeted to after the dirty states have been
 *          reset or null if none.
 */
public static void unsetCollectionHibernateSession(PersistentCollection collection, Session targetSession) {
  // Whenever the entity has dirty persistent collection, make them
  // clean to workaround a "bug" with hibernate since hibernate cannot
  // re-attach a "dirty" detached collection.
  if (collection != null) {
    if (Hibernate.isInitialized(collection)) {
      collection.clearDirty();
    }
    if (collection instanceof AbstractPersistentCollection
        && ((AbstractPersistentCollection) collection).getSession() != null
        && targetSession != ((AbstractPersistentCollection) collection).getSession()) {
      // The following is to avoid to avoid Hibernate exceptions due to
      // re-associating a collection that is already associated with the
      // session.
      collection.unsetSession(((AbstractPersistentCollection) collection).getSession());
    }
  }
}
项目:BLOG-Microservice    文件:HibernateSerializerFactory.java   
@SuppressWarnings("rawtypes")
public Serializer getSerializer(Class cl) throws HessianProtocolException {
    if (PersistentMap.class.isAssignableFrom(cl)) {
        return mapSerializer;
    } else if (AbstractPersistentCollection.class.isAssignableFrom(cl)) {
        return listSerializer;
    } else if (cl.getSimpleName().contains("_$$_javassist_")) {
        return hibernateBeanSerializer;
    }
    return super.getSerializer(cl);
}
项目:lams    文件:CollectionEntry.java   
public void postInitialize(PersistentCollection collection) throws HibernateException {
    snapshot = getLoadedPersister().isMutable() ?
            collection.getSnapshot( getLoadedPersister() ) :
            null;
    collection.setSnapshot(loadedKey, role, snapshot);
    if (getLoadedPersister().getBatchSize() > 1) {
        ((AbstractPersistentCollection) collection).getSession().getPersistenceContext().getBatchFetchQueue().removeBatchLoadableCollection(this); 
    }
}
项目:elide    文件:HibernateTransaction.java   
@Override
public Object getRelation(
        DataStoreTransaction relationTx,
        Object entity,
        String relationName,
        Optional<FilterExpression> filterExpression,
        Optional<Sorting> sorting,
        Optional<Pagination> pagination,
        RequestScope scope) {

    EntityDictionary dictionary = scope.getDictionary();
    Object val = com.yahoo.elide.core.PersistentResource.getValue(entity, relationName, scope);
    if (val instanceof Collection) {
        Collection filteredVal = (Collection) val;
        if (filteredVal instanceof AbstractPersistentCollection) {
            Class<?> relationClass = dictionary.getParameterizedType(entity, relationName);

            RelationshipImpl relationship = new RelationshipImpl(
                    entity.getClass(),
                    relationClass,
                    relationName,
                    entity,
                    filteredVal);

            pagination.ifPresent(p -> {
                if (p.isGenerateTotals()) {
                    p.setPageTotals(getTotalRecords(relationship, filterExpression, dictionary));
                }
            });

            final QueryWrapper query = (QueryWrapper)
                    new SubCollectionFetchQueryBuilder(relationship, dictionary, sessionWrapper)
                            .withPossibleFilterExpression(filterExpression)
                            .withPossibleSorting(sorting)
                            .withPossiblePagination(pagination)
                            .build();

            if (query != null) {
                return query.getQuery().list();
            }
        }
    }
    return val;
}