use of org.hibernate.persister.entity.EntityPersister in project hibernate-orm by hibernate.
the class StatelessSessionImpl method delete.
@Override
public void delete(String entityName, Object entity) {
checkOpen();
EntityPersister persister = getEntityPersister(entityName, entity);
Serializable id = persister.getIdentifier(entity, this);
Object version = persister.getVersion(entity);
persister.delete(id, version, entity, this);
}
use of org.hibernate.persister.entity.EntityPersister in project hibernate-orm by hibernate.
the class StatelessSessionImpl method internalLoad.
@Override
public Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable) throws HibernateException {
checkOpen();
EntityPersister persister = getFactory().getMetamodel().entityPersister(entityName);
// first, try to load it from the temp PC associated to this SS
Object loaded = temporaryPersistenceContext.getEntity(generateEntityKey(id, persister));
if (loaded != null) {
// containing eager fetches via join fetch
return loaded;
}
if (!eager && persister.hasProxy()) {
// generate a proxy
return persister.createProxy(id, this);
}
// otherwise immediately materialize it
return get(entityName, id);
}
use of org.hibernate.persister.entity.EntityPersister in project hibernate-orm by hibernate.
the class AbstractCollectionReference method buildElementGraph.
private CollectionFetchableElement buildElementGraph() {
final CollectionPersister persister = collectionQuerySpace.getCollectionPersister();
final Type type = persister.getElementType();
if (type.isAssociationType()) {
if (type.isEntityType()) {
final EntityPersister elementPersister = persister.getFactory().getEntityPersister(((EntityType) type).getAssociatedEntityName());
final ExpandingEntityQuerySpace entityQuerySpace = QuerySpaceHelper.INSTANCE.makeEntityQuerySpace(collectionQuerySpace, elementPersister, CollectionPropertyNames.COLLECTION_ELEMENTS, (EntityType) persister.getElementType(), collectionQuerySpace.getExpandingQuerySpaces().generateImplicitUid(), collectionQuerySpace.canJoinsBeRequired(), allowElementJoin);
return new CollectionFetchableElementEntityGraph(this, entityQuerySpace);
} else if (type.isAnyType()) {
return new CollectionFetchableElementAnyGraph(this);
}
} else if (type.isComponentType()) {
final ExpandingCompositeQuerySpace compositeQuerySpace = QuerySpaceHelper.INSTANCE.makeCompositeQuerySpace(collectionQuerySpace, new CompositePropertyMapping((CompositeType) persister.getElementType(), (PropertyMapping) persister, ""), CollectionPropertyNames.COLLECTION_ELEMENTS, (CompositeType) persister.getElementType(), collectionQuerySpace.getExpandingQuerySpaces().generateImplicitUid(), collectionQuerySpace.canJoinsBeRequired(), allowElementJoin);
return new CollectionFetchableElementCompositeGraph(this, compositeQuerySpace);
}
return null;
}
use of org.hibernate.persister.entity.EntityPersister in project hibernate-orm by hibernate.
the class AbstractExpandingFetchSource method buildBidirectionalEntityReference.
@Override
public BidirectionalEntityReference buildBidirectionalEntityReference(AssociationAttributeDefinition attributeDefinition, FetchStrategy fetchStrategy, EntityReference targetEntityReference) {
final EntityType fetchedType = (EntityType) attributeDefinition.getType();
final EntityPersister fetchedPersister = attributeDefinition.toEntityDefinition().getEntityPersister();
if (fetchedPersister == null) {
throw new WalkingException(String.format("Unable to locate EntityPersister [%s] for bidirectional entity reference [%s]", fetchedType.getAssociatedEntityName(), attributeDefinition.getName()));
}
final BidirectionalEntityReference bidirectionalEntityReference = new BidirectionalEntityReferenceImpl(this, attributeDefinition, targetEntityReference);
addBidirectionalEntityReference(bidirectionalEntityReference);
return bidirectionalEntityReference;
}
use of org.hibernate.persister.entity.EntityPersister in project hibernate-orm by hibernate.
the class QuerySpaceHelper method makeEntityQuerySpace.
public ExpandingEntityQuerySpace makeEntityQuerySpace(ExpandingQuerySpace lhsQuerySpace, AssociationAttributeDefinition attribute, String querySpaceUid, FetchStrategy fetchStrategy) {
final EntityType fetchedType = (EntityType) attribute.getType();
final EntityPersister fetchedPersister = attribute.toEntityDefinition().getEntityPersister();
if (fetchedPersister == null) {
throw new WalkingException(String.format("Unable to locate EntityPersister [%s] for fetch [%s]", fetchedType.getAssociatedEntityName(), attribute.getName()));
}
// TODO: Queryable.isMultiTable() may be more broad than it needs to be...
final boolean isMultiTable = Queryable.class.cast(fetchedPersister).isMultiTable();
final boolean required = lhsQuerySpace.canJoinsBeRequired() && !isMultiTable && !attribute.isNullable();
return makeEntityQuerySpace(lhsQuerySpace, fetchedPersister, attribute.getName(), (EntityType) attribute.getType(), querySpaceUid, required, shouldIncludeJoin(fetchStrategy));
}
Aggregations