jpaメタモデル
4500 ワード
maven
2.3.3
${project.name}
org.springframework.boot
spring-boot-maven-plugin
repackage
org.apache.maven.plugins
maven-compiler-plugin
${maven-compiler-plugin.version}
org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor
${java.version}
${java.version}
org.projectlombok
lombok
${lombok.version}
org.hibernate
hibernate-jpamodelgen
${hibernate.version}
org.glassfish.jaxb
jaxb-runtime
${jaxb-runtime.version}
IDE
org.hibernate
hibernate-jpamodelgen
org.hibernate
hibernate-jpamodelgen
provided
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery query = builder.createQuery(UserRoleVo.class);
Root postComment = query.from(UserEntity.class);
Join post = postComment.join(UserEntity_.level);
query.multiselect(
postComment.get(UserEntity_.CODE).alias(UserEntity_.CODE),
postComment.get(UserEntity_.TREE_ID).alias(UserEntity_.TREE_ID),
post.get(RoleEntity_.TITLE_FILED).alias(RoleEntity_.TITLE_FILED)
);
query.where(
builder.and(
builder.like(
post.get(RoleEntity_.NAME),
"% %"
)
// ,
// builder.equal(
// post.get(RoleEntity_.details).get(RoleEntityDetails_.CREATED_BY),
// "Vlad Mihalcea"
// )
)
);
List comments = entityManager
.createQuery(query)
.unwrap(Query.class)
.getResultList();