org.hibernate.graph.internal.RootGraphImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
JPMS Module-Info's for a few of the Jakarta Libraries just until they add them in themselves
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.graph.internal;
import javax.persistence.EntityGraph;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.graph.SubGraph;
import org.hibernate.graph.spi.GraphImplementor;
import org.hibernate.graph.spi.RootGraphImplementor;
import org.hibernate.graph.spi.SubGraphImplementor;
import org.hibernate.metamodel.model.domain.spi.EntityTypeDescriptor;
import org.hibernate.metamodel.model.domain.spi.IdentifiableTypeDescriptor;
/**
* The Hibernate implementation of the JPA EntityGraph contract.
*
* @author Steve Ebersole
*/
public class RootGraphImpl extends AbstractGraph implements EntityGraph, RootGraphImplementor {
private final String name;
public RootGraphImpl(
String name,
EntityTypeDescriptor entityType,
boolean mutable,
SessionFactoryImplementor sessionFactory) {
super( entityType, mutable, sessionFactory );
this.name = name;
}
public RootGraphImpl(String name, EntityTypeDescriptor entityType, SessionFactoryImplementor sessionFactory) {
this(
name,
entityType,
true,
sessionFactory
);
}
public RootGraphImpl(String name, boolean mutable, GraphImplementor original) {
super( mutable, original );
this.name = name;
}
@Override
public String getName() {
return name;
}
@Override
public RootGraphImplementor makeCopy(boolean mutable) {
return new RootGraphImpl<>( null, mutable, this );
}
@Override
public SubGraphImplementor makeSubGraph(boolean mutable) {
return new SubGraphImpl<>( mutable, this );
}
@Override
public RootGraphImplementor makeRootGraph(String name, boolean mutable) {
if ( ! mutable && ! isMutable() ) {
return this;
}
return super.makeRootGraph( name, mutable );
}
@Override
public SubGraph extends T1> addSubclassSubgraph(Class extends T1> type) {
throw new NotYetImplementedException( );
}
@Override
public boolean appliesTo(EntityTypeDescriptor super J> entityType) {
if ( this.getGraphedType().equals( entityType ) ) {
return true;
}
IdentifiableTypeDescriptor superType = entityType.getSupertype();
while ( superType != null ) {
if ( superType.equals( entityType ) ) {
return true;
}
superType = superType.getSupertype();
}
return false;
}
@Override
public boolean appliesTo(String entityName) {
return appliesTo( sessionFactory().getMetamodel().entity( entityName ) );
}
@Override
public boolean appliesTo(Class entityType) {
return appliesTo( sessionFactory().getMetamodel().entity( entityType ) );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy