Here are the examples of the java api org.hibernate.Session.getEntityGraph() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
16
Source : HibernateJpaOperations.java
with Apache License 2.0
from micronaut-projects
with Apache License 2.0
from micronaut-projects
private <T> void bindQueryHints(Query<?> q, @NonNull PagedQuery<T> preparedQuery, @NonNull Session session) {
Map<String, Object> queryHints = preparedQuery.getQueryHints();
if (CollectionUtils.isNotEmpty(queryHints)) {
for (Map.Entry<String, Object> entry : queryHints.entrySet()) {
String hintName = entry.getKey();
Object value = entry.getValue();
if (ENreplacedY_GRAPH_FETCH.equals(hintName) || ENreplacedY_GRAPH_LOAD.equals(hintName)) {
String graphName = preparedQuery.getAnnotationMetadata().stringValue(EnreplacedyGraph.clreplaced).orElse(null);
if (graphName != null) {
RootGraph<?> enreplacedyGraph = session.getEnreplacedyGraph(graphName);
q.setHint(hintName, enreplacedyGraph);
} else if (value instanceof String[]) {
String[] pathsDefinitions = (String[]) value;
if (ArrayUtils.isNotEmpty(pathsDefinitions)) {
RootGraph<T> enreplacedyGraph = session.createEnreplacedyGraph(preparedQuery.getRootEnreplacedy());
for (String pathsDefinition : pathsDefinitions) {
String[] paths = pathsDefinition.split("\\.");
if (paths.length == 1) {
enreplacedyGraph.addAttributeNode(paths[0]);
} else {
SubGraph<T> subGraph = null;
for (int i = 0; i < paths.length; i++) {
String path = paths[i];
if (subGraph == null) {
if (i + 1 == paths.length) {
enreplacedyGraph.addAttributeNode(path);
} else {
subGraph = enreplacedyGraph.addSubGraph(path);
}
} else {
if (i + 1 == paths.length) {
subGraph.addAttributeNode(path);
} else {
subGraph = subGraph.addSubGraph(path);
}
}
}
}
}
q.setHint(hintName, enreplacedyGraph);
}
}
} else {
q.setHint(hintName, value);
}
}
}
}