User: Password:
|
|
Subscribe / Log in / New account

A report from OpenSQLCamp

A report from OpenSQLCamp

Posted Nov 3, 2010 17:46 UTC (Wed) by Cyberax (✭ supporter ✭, #52523)
In reply to: A report from OpenSQLCamp by alankila
Parent article: A report from OpenSQLCamp

You're in luck:

List%lt;SomeObject%gt; objects=sess.from(someObject)
  .where(someObject.someField.lt(10))
  .where(someObject.anotherLinkedObject().anotherField.gt(10))
  .where(someObject.name.in("Joe", "Smith", "Bubba")
  .list(someObject);
or even:
HibernateQuery query=sess.from(someObject)
  .where(someObject.someField.lt(10))
  .where(someObject.anotherLinkedObject().anotherField.gt(10));

if (weNeedToLimitByName)
    query.where(someObject.name.in("Joe", "Smith", "Bubba"));

if (someAnotherCondition)
    query.where(someObject.id.eq(10));

query.list(someObject);
Secret sauce is QueryDSL. LINQ in C# has even more powerful capabilities.


(Log in to post comments)

A report from OpenSQLCamp

Posted Nov 3, 2010 22:10 UTC (Wed) by alankila (guest, #47141) [Link]

It looks reasonable on the surface, at least. I normally use the Criteria API when dealing with Hibernate on Java, but it is not especially smart or type safe. It's a pity that code generator is required for this.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds