java.is.for.desktop
java.is.for.desktop

Reputation: 11216

Hibernate: Query without SQL-strings?

Is it possible (and if yes, is it advisable) to do queries of Hibernate-mapped data without using SQL-strings, but some OOP way instead?

Upvotes: 2

Views: 1345

Answers (3)

Kaleb Brasee
Kaleb Brasee

Reputation: 51935

It's possible using Criteria, but I think the queries are generally more understandable when using HQL with parameters. Still, Criteria does work well for the queries that are quite dynamic (I've seen people concatenate HQL strings for dynamic queries, and Criteria is cleaner in those cases).

Upvotes: 1

twk
twk

Reputation: 3120

I am using linq. But HQL uses entities, so it should be named object-oriented :)

Upvotes: 1

dfa
dfa

Reputation: 116334

use the Criteria API, more examples here.

Upvotes: 7

Related Questions