-->
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: Insert default data in the db with hibernate
PostPosted: Tue Jun 01, 2010 6:17 pm 
Newbie

Joined: Wed Mar 24, 2010 2:58 am
Posts: 10
Location: Livorno,Italy
Hi, i need to insert a default set(a set of INSERT INTO) of data at every first start of the program(before the creation of the db), with the same modality of hbm2dll update mode.(If is the first start of the database i need to execute the INSERT INTO statement, through hibernate,otherwise the program must not do the INSERT).
This is possible to do?

Sorry for my bad english, Thank You

Daniel


Top
 Profile  
 
 Post subject: Re: Insert default data in the db with hibernate
PostPosted: Wed Jun 02, 2010 4:08 am 
Newbie

Joined: Sat Mar 27, 2010 2:43 am
Posts: 8
Please quote your question clearly.
Are you going to create a new database everytime and inserting some default values for it each time the database is created?


Top
 Profile  
 
 Post subject: Re: Insert default data in the db with hibernate
PostPosted: Wed Jun 02, 2010 5:39 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
Hi, i need to insert a default set(a set of INSERT INTO) of data at every first start of the program(before the creation of the db), with the same modality of hbm2dll update mode.(If is the first start of the database i need to execute the INSERT INTO statement, through hibernate,otherwise the program must not do the INSERT).
This is possible to do?

Create a file named "import.sql", it will be automatically executed (imported) into your database when the schema is created. I don't remember if it is created when using "update", you might want to try "create" after having it dropped. I always develop with an in-memory database like H2 and setting it in create-drop for unit tests, using an import.sql to add the basic needed data.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Insert default data in the db with hibernate
PostPosted: Fri Jun 04, 2010 5:31 pm 
Newbie

Joined: Wed Mar 24, 2010 2:58 am
Posts: 10
Location: Livorno,Italy
I need to insert some default values in the db when it is created, and i'll use update propriety.How i can do it? I can import an sql file, but how i can says hibernate to import that files only when it create the db?
Thanks

Edit: s.grinovero and fivefingers: yes, but how i can do that?
thank you


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.