I understand that metamodel is kind of an abstraction of entity classes, but what exactly it is and how can I profit from that?
Asked
Active
Viewed 467 times
1 Answers
1
They're used for writing Criteria queries for JPA.
Also, it's used for writing Specifications (if you're using spring data)
Specification<Foo> isBar() {
return (root, query, builder) -> builder.isNotNull(root.get(Foo_.bar));
}

lane.maxwell
- 5,002
- 1
- 20
- 30
-
So it is not possible to write Criteria queries without Metamodel objects? – Jakub Gruber Jan 04 '17 at 19:26
-
2You can write very simple queries without them, but you'll need them to perform joins. Hibernate has created a cool utility for generating these for you, so you don't have to write them yourself. If you are using Maven, simply add the org.hibernate:hibernate-jpamodelgen artifact to your pom – lane.maxwell Jan 04 '17 at 19:45