Search in sources :

Example 1 with AbstractEntityPersister

use of org.hibernate.persister.entity.AbstractEntityPersister in project hibernate-orm by hibernate.

the class JoinSequence method isSubclassAliasDereferenced.

private boolean isSubclassAliasDereferenced(Join join, String withClauseFragment) {
    if (join.getJoinable() instanceof AbstractEntityPersister) {
        AbstractEntityPersister persister = (AbstractEntityPersister) join.getJoinable();
        int subclassTableSpan = persister.getSubclassTableSpan();
        for (int j = 1; j < subclassTableSpan; j++) {
            String subclassAlias = AbstractEntityPersister.generateTableAlias(join.getAlias(), j);
            if (isAliasDereferenced(withClauseFragment, subclassAlias)) {
                return true;
            }
        }
    }
    return false;
}
Also used : AbstractEntityPersister(org.hibernate.persister.entity.AbstractEntityPersister)

Example 2 with AbstractEntityPersister

use of org.hibernate.persister.entity.AbstractEntityPersister in project hibernate-orm by hibernate.

the class TableCommentTest method getTableName.

private String getTableName() {
    SessionFactoryImplementor sessionFactoryImplementor = sessionFactory();
    ClassMetadata tableWithCommentMetadata = sessionFactoryImplementor.getClassMetadata(TableWithComment.class);
    return ((AbstractEntityPersister) tableWithCommentMetadata).getTableName();
}
Also used : ClassMetadata(org.hibernate.metadata.ClassMetadata) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) AbstractEntityPersister(org.hibernate.persister.entity.AbstractEntityPersister)

Example 3 with AbstractEntityPersister

use of org.hibernate.persister.entity.AbstractEntityPersister in project midpoint by Evolveum.

the class RUtil method fixCompositeIdentifierInMetaModel.

private static void fixCompositeIdentifierInMetaModel(SessionFactory sessionFactory, Class clazz) {
    ClassMetadata classMetadata = sessionFactory.getClassMetadata(clazz);
    if (classMetadata instanceof AbstractEntityPersister) {
        AbstractEntityPersister persister = (AbstractEntityPersister) classMetadata;
        EntityMetamodel model = persister.getEntityMetamodel();
        IdentifierProperty identifier = model.getIdentifierProperty();
        try {
            Field field = IdentifierProperty.class.getDeclaredField("hasIdentifierMapper");
            field.setAccessible(true);
            field.set(identifier, true);
            field.setAccessible(false);
        } catch (Exception ex) {
            throw new SystemException("Attempt to fix entity meta model with hack failed, reason: " + ex.getMessage(), ex);
        }
    }
}
Also used : ClassMetadata(org.hibernate.metadata.ClassMetadata) Field(java.lang.reflect.Field) SystemException(com.evolveum.midpoint.util.exception.SystemException) IdentifierProperty(org.hibernate.tuple.IdentifierProperty) EntityMetamodel(org.hibernate.tuple.entity.EntityMetamodel) AbstractEntityPersister(org.hibernate.persister.entity.AbstractEntityPersister) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException)

Aggregations

AbstractEntityPersister (org.hibernate.persister.entity.AbstractEntityPersister)3 ClassMetadata (org.hibernate.metadata.ClassMetadata)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 SystemException (com.evolveum.midpoint.util.exception.SystemException)1 Field (java.lang.reflect.Field)1 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)1 IdentifierProperty (org.hibernate.tuple.IdentifierProperty)1 EntityMetamodel (org.hibernate.tuple.entity.EntityMetamodel)1