From: Arne Vajhøj on 31 Mar 2010 22:20 On 31-03-2010 21:07, Lew wrote: > Arne Vajhøj wrote: >> On 31-03-2010 19:57, Ken wrote: >>> On Mar 31, 5:30 pm, Arne Vajhøj<a...(a)vajhoej.dk> wrote: >>>> On 31-03-2010 19:27, Ken wrote: >>>>> I just looked at hibernate... but have never used it. >>>>> >>>>> Can it or any other main stream java tools query databases with an >>>>> optional WHERE clause? >> ... >>>> You can build criterias in Hibernate. >>>> >>>> http://docs.jboss.org/hibernate/core/3.3/reference/en/html/querycrite... >>>> >>> >>> Yes this is exactly what I was thinking! I think... >> >> Thinking is good ! > > Use the JPA packages, which Hibernate supports. JPA 2.0 has this: http://openjpa.apache.org/builds/latest/docs/manual/jpa_overview_criteria.html Arne
From: Arved Sandstrom on 1 Apr 2010 05:43 Arne Vajhøj wrote: > On 31-03-2010 21:07, Lew wrote: >> Arne Vajhøj wrote: >>> On 31-03-2010 19:57, Ken wrote: >>>> On Mar 31, 5:30 pm, Arne Vajhøj<a...(a)vajhoej.dk> wrote: >>>>> On 31-03-2010 19:27, Ken wrote: >>>>>> I just looked at hibernate... but have never used it. >>>>>> >>>>>> Can it or any other main stream java tools query databases with an >>>>>> optional WHERE clause? >>> ... >>>>> You can build criterias in Hibernate. >>>>> >>>>> http://docs.jboss.org/hibernate/core/3.3/reference/en/html/querycrite... >>>>> >>>>> >>>> >>>> Yes this is exactly what I was thinking! I think... >>> >>> Thinking is good ! >> >> Use the JPA packages, which Hibernate supports. > > JPA 2.0 has this: > > http://openjpa.apache.org/builds/latest/docs/manual/jpa_overview_criteria.html > > Arne > The JPA 2.0 Criteria API is absolutely the answer if you've got a JPA 2.0 implementation like EclipseLink 2.x. E.g. http://wiki.eclipse.org/EclipseLink/Examples/JPA/2.0/Criteria. Right now if you're using JPA 1.0 then it's down to Java conditional code and/or using the native APIs of Hibernate/Toplink/EclipseLink. I can't comment on Hibernate, but EclipseLink (and I would guess ToplinkEssentials) allow relatively painless transition between the native and JPA levels. For example, you can start with a ReadAllQuery, and after adding the reference class then execute your "criteria" logic (often handy as part of a JSF "criteria" class that encapsulates the "backing bean" portion of a managed bean), and then convert to a JPA Query with javax.persistence.Query jpaQuery = ((JpaEntityManager)em.getDelegate()).createQuery(readAllQuery); This can then be used to add pagination, if necessary, with straight JPA, and execute the actual query also in JPA. AHS
First
|
Prev
|
Pages: 1 2 Prev: bundling efficiency, too good to be true? Next: Enterprise Level Logging |