
com.alterioncorp.jpa.entitygraphbuilder.EntityGraphBuilderImpl Maven / Gradle / Ivy
The newest version!
package com.alterioncorp.jpa.entitygraphbuilder;
import javax.persistence.EntityGraph;
import javax.persistence.EntityManager;
import com.querydsl.core.types.Path;
public class EntityGraphBuilderImpl implements EntityGraphBuilder {
private final EntityManager entityManager;
private final RelationshipParser parser;
public EntityGraphBuilderImpl(EntityManager entityManager) {
this(entityManager, new RelationshipParserImpl());
}
EntityGraphBuilderImpl(EntityManager entityManager, RelationshipParser parser) {
super();
this.entityManager = entityManager;
this.parser = parser;
}
@Override
public EntityGraph build(Class type, Path>... relationshipsToFetch) {
EntityGraph entityGraph = entityManager.createEntityGraph(type);
RelationshipTree relationshipTree = parser.build(relationshipsToFetch);
relationshipTree.addToGraph(entityGraph);
return entityGraph;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy