use of jakarta.persistence.criteria.Path in project hibernate-orm by hibernate.
the class CompositeParameterTests method testDeTypedInPredicateCriteria.
@Test
public void testDeTypedInPredicateCriteria(SessionFactoryScope scope) {
final HibernateCriteriaBuilder builder = scope.getSessionFactory().getCriteriaBuilder();
final JpaMetamodel jpaMetamodel = scope.getSessionFactory().getRuntimeMetamodels().getJpaMetamodel();
final EntityDomainType entityDescriptor = jpaMetamodel.entity(SimpleEntity.class);
final SingularAttribute attribute = entityDescriptor.getSingularAttribute("composite");
scope.inTransaction((session) -> {
final JpaCriteriaQuery criteria = builder.createQuery(SimpleEntity.class);
final JpaRoot root = criteria.from(entityDescriptor);
final Path attrPath = root.get(attribute);
final JpaParameterExpression parameter = builder.parameter(SimpleComposite.class);
criteria.where(builder.in(attrPath, parameter));
final QueryImplementor query = session.createQuery(criteria);
query.setParameter(parameter, new SimpleComposite());
query.list();
});
}
use of jakarta.persistence.criteria.Path in project eclipselink by eclipse-ee4j.
the class CriteriaBuilderImpl method treat.
@Override
public <X, T, E extends T> SetJoin<X, E> treat(SetJoin<X, T> join, Class<E> type) {
SetJoinImpl parentJoin = (SetJoinImpl) join;
SetJoin joinImpl = null;
if (join instanceof BasicSetJoinImpl) {
joinImpl = new BasicSetJoinImpl<X, E>(parentJoin, this.metamodel, type, parentJoin.currentNode.treat(type), parentJoin.getModel(), parentJoin.getJoinType());
} else {
joinImpl = new SetJoinImpl<X, E>((Path) join, this.metamodel.managedType(type), this.metamodel, type, parentJoin.currentNode.treat(type), parentJoin.getModel(), parentJoin.getJoinType());
}
parentJoin.joins.add(joinImpl);
((FromImpl) joinImpl).isJoin = parentJoin.isJoin;
parentJoin.isJoin = false;
return joinImpl;
}
use of jakarta.persistence.criteria.Path in project eclipselink by eclipse-ee4j.
the class CriteriaBuilderImpl method treat.
@Override
public <X, T, E extends T> CollectionJoin<X, E> treat(CollectionJoin<X, T> join, Class<E> type) {
CollectionJoinImpl parentJoin = (CollectionJoinImpl) join;
CollectionJoin joinImpl = null;
if (join instanceof BasicCollectionJoinImpl) {
joinImpl = new BasicCollectionJoinImpl<X, E>(parentJoin, this.metamodel, type, parentJoin.currentNode.treat(type), parentJoin.getModel(), parentJoin.getJoinType());
} else {
joinImpl = new CollectionJoinImpl<X, E>((Path) join, this.metamodel.managedType(type), this.metamodel, type, parentJoin.currentNode.treat(type), parentJoin.getModel(), parentJoin.getJoinType());
}
parentJoin.joins.add(joinImpl);
((FromImpl) joinImpl).isJoin = parentJoin.isJoin;
parentJoin.isJoin = false;
return joinImpl;
}
Aggregations