-->
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: Custom JDBC code after save does not get sent to DB
PostPosted: Wed Jun 09, 2004 5:17 pm 
Beginner
Beginner

Joined: Fri Feb 20, 2004 6:15 pm
Posts: 38
I need to do some custom JDBC code after I call save on an object (since I'm implementing my own type of lazy load).

I'm within a session bean transaction.

I then call session.save(obj);

After that call, I then use the session.connection() to execute some update statements using JDBC. The updates update fields of the table that obj is mapped to.


Once the transaction completes, I see the SQL log from Hibernate, but my custom JDBC statements are not being sent! I've put my own logging to make sure my JDBC code is being executed, and it is.

I've doing a connection commit and a session close after my custom statements, but that just causes errors.

Why would Hibernate ignore my statements? Any ideas on how to force my SQL to be executed?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 09, 2004 5:49 pm 
Beginner
Beginner

Joined: Fri Feb 20, 2004 6:15 pm
Posts: 38
session.flush seems to be doing it for me, if I call it right after my SQL code

I don't understand this though since I do call session.flush later in the method...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 09, 2004 5:52 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
as you said, you're getting the connection and doing your statement alone... so please don't say hibernate is not doing your job.

What you should try is doing it in 2 times:
1- getting session, start transaction, getting mapped object, modifying or instanciating a new one + commit (then maybe discard this first session)
2- (getting another clean session if you have discarded the 1rst) + getting jdbc connection + prepared statement + commit.


try it

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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.