-->
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: Create table in sql server using native query
PostPosted: Thu Jul 01, 2004 12:15 am 
Newbie

Joined: Wed Jun 30, 2004 4:44 am
Posts: 5
Location: Indonesia
Dear friends,

I am using hibernate 2.1 and mssql 2000 as the db. Can i create new tables in db using hibernate native query ?

If i can do that, please give me some examples :)


Really thanx,

H


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 01, 2004 3:12 am 
Senior
Senior

Joined: Sun Jan 04, 2004 2:46 pm
Posts: 147
If you're thinking about session.createSQLQuery() then you can't. You have to do session.connection() and use the returned JDBC connection to create your table.

eg.

Code:
Session session = factory.openSession();
Transaction tx = session.beginTransaction();

Connection conn = session.connection();

Statement stmt = conn.createStatement();
stmt.execute( "create table xxx ......" );

tx.commit();
session.close();


Remember to trap exceptions to do rollbacks and put session.close() in a finally block.


Top
 Profile  
 
 Post subject: Create table from hibernate is very easy
PostPosted: Thu Jul 01, 2004 10:49 pm 
Newbie

Joined: Wed Jun 30, 2004 4:44 am
Posts: 5
Location: Indonesia
Thank you it works smoothly :)


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.