-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Novice with JPA / Hibernate help in dynamic select
PostPosted: Tue Jan 13, 2009 1:07 pm 
Newbie

Joined: Tue Jan 13, 2009 11:04 am
Posts: 13
Hello,

I'm using JPA with Hibernate and falls into a situation and I do not know how to resolve because I have a jsp page like this:

[code]

jsp page with list box

Operacao Field Value
======== ===== =====
Id = 20
State = "SP"
Balance > 1000



Where the field:

ID -> Client object
State -> object Address
Balance -> Object Balance

If the three lines are met as the command would be:

jhl.append ( "SELECT DISTINCT (customer) FROM Customer user, Balance balance JOIN user.address end where doc.estado = 'SP' = saldo.id user.id");

List usuariosdoctos = em.getManager (). CreateQuery (jhl.toString ()). GetResultList ();

If the first line is completed would be like this:

jhl.append ( "SELECT DISTINCT (customer) FROM Customer user where user.id = 20");

List usuariosdoctos = em.getManager (). CreateQuery (jhl.toString ()). GetResultList ();

[/ code]

My doubts mount as it dynamically heard that criteria but I do not know if it can gain criteria ...

If anyone can help me ....


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 13, 2009 5:12 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
JPA 1.0 does not define a Criteria API, however you can use the Hibernate Session directly like this:

Session s = (Session) entityManager.getDelegate();

Of course this is not portable but it gives you access to the Criteria API.

Note that JPA 2.0 will have a Criteria API but that's several months off.

-Chris

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 14, 2009 7:15 am 
Newbie

Joined: Tue Jan 13, 2009 11:04 am
Posts: 13
Thanks for the feedback but I have doubts as to criteria that would make my problem reported above.

Can you give me some example (mounted dynamic select and how to receive several lines through MAP, List ... how?) Or url you try to mount any intelligence that you solve my problem.

If anyone can help me ....

Thank you


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.