-->
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.  [ 4 posts ] 
Author Message
 Post subject: Can Hibernate automatically dump data into DB?
PostPosted: Fri Mar 02, 2007 3:58 am 
Newbie

Joined: Tue Jan 16, 2007 11:01 pm
Posts: 8
I know Hibernate can automatically create table with ".hbm.xml" , if the table doesn't exist.

What i want to know is : can Hibernate automatically insert some data into the table after it is automatically created ??

And how to achieve that ??


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 02, 2007 4:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Sure, include a file named import.sql at the root of your classpath. SchemaExport will pick up this file and "import" its contents after it has exported the schema.

The format of this file is a new-line-delimited series of SQL commands...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 02, 2007 10:24 pm 
Newbie

Joined: Tue Jan 16, 2007 11:01 pm
Posts: 8
steve wrote:
Sure, include a file named import.sql at the root of your classpath. SchemaExport will pick up this file and "import" its contents after it has exported the schema.

The format of this file is a new-line-delimited series of SQL commands...


That is to say , if i place import.sql at the root of my classpth with .hbm.xml files together , Hibernate will automatically create table and dump predata into it??

I have tested your opinion , but didn't get data in table.
Should i do something else in my java files?

I use Ant to compile my project , and at the end of compiling , I make Ant to find the .hbm.xml files in project to create tables .
After creating tables in compiling process , i want to dump data into the tables next. That means i want to insert "dumping data" into the compiling process.



I am using Hibernate 2.1.8.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 05, 2007 2:22 am 
Newbie

Joined: Tue Jan 16, 2007 11:01 pm
Posts: 8
Anyone can give me some advisement about this ??


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