-->
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.  [ 5 posts ] 
Author Message
 Post subject: dynamic insert/update/delete
PostPosted: Mon Mar 06, 2006 11:06 am 
Newbie

Joined: Mon Mar 06, 2006 11:01 am
Posts: 3
The session class contains a "createSQLQuery()" method to provide dynamic native sql in runtime. Are there any approaches to execute dynamic native insert/update/delete SQL statement?


Top
 Profile  
 
 Post subject: jdbc
PostPosted: Mon Mar 06, 2006 2:47 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Connection c = session.connection();
and straight JDBC code from here

Please consult javadoc for your H version because you may need to close connection yourself.
And do not forget to invalidate appropriate objects in Session or Second level cache...

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 11:20 pm 
Newbie

Joined: Mon Mar 06, 2006 11:01 am
Posts: 3
Can I still use the createSQLQuery() and use the inser/update/delete SQL statement instead of the query statement?

It just cheat the createSQLQuery() method to execute an update for me. Is it possible?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 11:48 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Not yet. But you can use HQL to execute inserts, updates, and deletes in addition to selects.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 07, 2006 12:04 am 
Newbie

Joined: Mon Mar 06, 2006 11:01 am
Posts: 3
The <sql-insert> in the mapping file can not meet my requirement because I was asked to use map one POJO to multiple tables of same structure. The table name is dynamic in runtime. e.g. anytime a new device was created, a device_? table is created in the database. the ? is the primary key of the device. Then, all data from this device will be put into this table. So, another question is that can I use Hibernate to create a table at runtime instead of direct JDBC?


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