This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes EJB and other Java EE Technologies and the fly likes How to fill database with initial data? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to fill database with initial data?" Watch "How to fill database with initial data?" New topic
Author

How to fill database with initial data?

Krystian Gor
Ranch Hand

Joined: Jan 11, 2011
Posts: 30
Using NetBeans 6.9.1 + Glassfish3. My table generation strategy is <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
My attempt to fill database with required data is to create @ApplicationScoped managed bean. Then inside @PostConstruct public void init() method declare some objects and persist them to database.
Then this Managed Bean is useless, but it will still be using memory.
Any advices how to solve it better?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30353
    
150

I wouldn't use "drop-and-create-tables" in production. I would create the database separately so I don't lose my data by accident later.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Krystian Gor
Ranch Hand

Joined: Jan 11, 2011
Posts: 30
Right. I forgot to mention it's not production I still learn, read JSF specification, debug a lot so "drop-and-create-tables" is useful.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to fill database with initial data?