-->
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: Unusual Question/Problem: retrieving SQL insert for Pojo
PostPosted: Mon Jan 14, 2008 6:02 am 
Newbie

Joined: Mon Mar 26, 2007 4:22 am
Posts: 4
Hibernate 3.2:

Hi folks,
my problem is:

Within our application (running on production server) we have a table entry with dubious values. I have the corresponding Pojo loaded (we're using inheritance and subcomponents). Since this is a production environment, we cannot play around with the data. Instead I would like to have something like

Code:
String sql = pojo.createSqlInsertCommand();   // not HQL !!
writeSqlToFile( sql );


If this would be possible, we could simply insert the selected pojos in a test environment and do/redo whatever we need to fix our problem.

(this would be extremely handy for the setup() of test cases too, since our application is to complicated to write this insert-command by hand.)

Perhaps this is an easy question, but I could not find anything matching within docs or this forum.

Thanks in advance
Andreas


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 14, 2008 5:20 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
In principle, Hibernate does not like to loose track of whatever pojos are being inserted in the dabatase. You can do inserts and deletes on hibernate3, but they have to be HQL. Hibernate won't even like a stored procedure called from within it, if the stored procedure does things other than select.

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 16, 2008 6:09 am 
Newbie

Joined: Mon Mar 26, 2007 4:22 am
Posts: 4
Hi,

perhaps my point was not clear:
I do not want to insert anything within the running application. What I would like to have is a sql (not hql) statement which I can save as String (say to a file) and insert it via some tool directly to another (test-) database.

What I need is more or less the statement which Hibernate would create if it would insert the (already existing) pojo to the database.

any help would be greatly appreciated
Andreas


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.