Example usage for org.hibernate.mapping PersistentClass hasSubclasses

List of usage examples for org.hibernate.mapping PersistentClass hasSubclasses

Introduction

In this page you can find the example usage for org.hibernate.mapping PersistentClass hasSubclasses.

Prototype

public boolean hasSubclasses() 

Source Link

Usage

From source file:com.db4o.drs.hibernate.impl.HibernateReplicationProvider.java

License:Open Source License

private Collection getChangedObjectsSinceLastReplication(PersistentClass persistentClass) {
    Criteria criteria = getSession().createCriteria(ObjectReference.class);
    long lastReplicationVersion = getLastReplicationVersion();
    criteria.add(Restrictions.gt(ObjectReference.Fields.VERSION, lastReplicationVersion));
    criteria.add(Restrictions.lt(ObjectReference.Fields.VERSION, _commitTimestamp));
    Disjunction disjunction = Restrictions.disjunction();

    List<String> names = new ArrayList<String>();
    names.add(persistentClass.getClassName());
    if (persistentClass.hasSubclasses()) {
        final Iterator it = persistentClass.getSubclassClosureIterator();
        while (it.hasNext()) {
            PersistentClass subC = (PersistentClass) it.next();
            names.add(subC.getClassName());
        }/*from  www  .ja va  2s  .  c  om*/
    }

    for (String s : names)
        disjunction.add(Restrictions.eq(ObjectReference.Fields.CLASS_NAME, s));

    criteria.add(disjunction);

    Set out = new HashSet();
    for (Object o : criteria.list()) {
        ObjectReference ref = (ObjectReference) o;
        out.add(getSession().load(persistentClass.getRootClass().getClassName(), ref.getTypedId()));
    }
    return out;
}

From source file:lucee.runtime.orm.hibernate.tuplizer.CFCInstantiator.java

License:Open Source License

/**
 * Constructor of the class/*from   ww w .j  av  a2 s  . c  o m*/
 * @param mappingInfo
 */
public CFCInstantiator(PersistentClass mappingInfo) {
    this.entityName = mappingInfo.getEntityName();
    isInstanceEntityNames.add(entityName);
    if (mappingInfo.hasSubclasses()) {
        Iterator<PersistentClass> itr = mappingInfo.getSubclassClosureIterator();
        while (itr.hasNext()) {
            final PersistentClass subclassInfo = itr.next();
            isInstanceEntityNames.add(subclassInfo.getEntityName());
        }
    }
}