-->
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: Prepared statements for arbitary queries
PostPosted: Thu Mar 29, 2007 8:11 am 
Senior
Senior

Joined: Mon Jul 24, 2006 8:43 am
Posts: 160
Hi,
In my application I have to issue queries to read from sequence tables. At the moment I do this as:

Code:
Query query = em.createNativeQuery("SELECT " + SPERSON   + ".NEXTVAL FROM DUAL");
Object o = query.getSingleResult();
BigDecimal bigDecimal = (BigDecimal)o;

// bigDecimal is the next value


My questions are:
1. Will the above code just generate a normal SQL statement, I presume it will not use a prepared statement?

2. When does a JPA Query use a prepared statement?

3. How do I adjust the above code to use a prepared statement?

Remember there is no corresponding POJO for the sequence table, so my last question is
4. Is it possible to use prepared statements if there is no corresponding POJO for the query?

Many thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 12:51 pm 
Senior
Senior

Joined: Mon Jul 24, 2006 8:43 am
Posts: 160
Anybody any ideas on this?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 03, 2007 5:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hibernate always uses preparedstatements.

_________________
Max
Don't forget to rate


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.