-->
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.  [ 6 posts ] 
Author Message
 Post subject: Customized SQL usage
PostPosted: Wed Jan 14, 2004 11:03 pm 
Newbie

Joined: Wed Jan 14, 2004 10:58 pm
Posts: 2
hi folks,

am i enable to generate my customize sql and add to the session to allow commit at a single point with others generated by hibernate?

and is there a way to get all generated sql from the session as if it havent flush or commit yet?

Thank for the help...
regards, K


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2004 3:03 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
No, all you can do is get the underlying JDBC connection and do a classic JDBC call. You'll be in the same transaction but the session may not be synchronized with the the changes you've made (object already loaded and change by your JDBC call...)
No

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2004 3:05 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Oh, I forgot this way: use the createSQLQuery() mechanism. Have a look at the docs on that. It allow native SQL queries with some restrictions. This way, the session stay up-to-date.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 5:07 am 
Newbie

Joined: Wed Jan 14, 2004 10:58 pm
Posts: 2
hi emmanue,

i wanna to clarify with you more on ...

1) what if i get the underlying JDBC connection and do whatever customized SQL and commit it by myself. Will this commition update the persistence object of that seesion automatically?

2) similar to Q1. i insert my own customized SQL into the JDBC connection of that session, and after that i did do a save or flush from that session (without my own commit), will my customized SQL changes update the persistence object of the session ? Will the original herbernate session update has the same effect as there is no any distortion to the JDBC?


Thank for ur greate help.
Have a nice day ....


Regards, K


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 5:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
session.connection() -> The session will not stay synchronized
session.createSQLQuery() -> The session will stay synchronized, but you only can do SELECTs


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 6:07 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
1) If you commit using the underlying connection and wo flushing, then changes in session won't be commited. You have to use Hibernate Tx for that.

2) Your custom SQL will be executed before Hibernate ones and won't change the persisted object loaded in session. Yes, session update will be done as if there were no distortion.

Be careful, session flushing can be done wo explicit session.flush() by Hibernate http://www.hibernate.org/hib_docs/reference/html_single/#manipulating-data-s12

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.