user3248346
user3248346

Reputation:

Criteria API and Query DSL

Using the canonical meta model in JPA 2 provides very strong type safety. I am not sure about querydsl though. Which is more type safe and why?

Upvotes: 5

Views: 2378

Answers (1)

wgitscht
wgitscht

Reputation: 2776

Query DSL is typesafe it's actually one of the main reasons to use QueryDSL and one of the problems it tries to solve. You create your metamodel and it enables you to effevtively use it with JPA, JDO, SQL ..

The reason why you may want to consider to use it instead of the JPA may be the more easier expression construction or that it plays well with Spring Data. Or maybe you want to access a MongoDB..

In terms of type safety it doesn't matter which one you use imho. As often the Standard (JPA) picks the cherrys from projects (e.g. CDI, JSR, ..)

edit: their own principles state Type safety is the core principle of Querydsl. Queries are constructed based on generated query types that reflect the properties of your domain types. Also function/method invocations are constructed in a fully type-safe manner.

Upvotes: 8

Related Questions