users@glassfish.java.net

Re: JPA: Preload data

From: Wolfram Rittmeyer <w.rittmeyer_at_jsptutorial.org>
Date: Mon, 09 Mar 2009 20:12:03 +0100

Actually I do not know whether there exists a solution. For testing
purposes I sometimes use DBUnit but apart from that I do not see why I
should do as you described.

If I have a more or less stable entity model than there is no need to
drop and recreate the tables with every (re)deployment.

If on the other hand your entities still change pretty often there is no
proper way to populate the created tables since attributes might have
changed, etc.

What you could do of course is to log the DDL statements, and copy them
to a database script. After these statements add the insert statements
to add data needed, should the db late need to be recreated. This script
could be maintained with relatively little effort in case of minor
changes to your entities.

--
Wolfram Rittmeyer
glassfish_at_javadesktop.org wrote:
> Hi,<br/>
> <br/>
> Thanks, put my problem is how do i pupulate the actual tables in the database with data? For example lets say I have a table with cities and a City entity. When I deploy my application for the first time, the cities table will be created in the database from the City entity. But the cities table of course empty. What if i would like a number of speciic cities to be preloaded (populated) into the database? How can i trigg this when the application is deployed?<br/>
> <br/>
> Thanks,
> Mattias
> [Message sent by forum member 'nightzero' (nightzero)]
> 
> http://forums.java.net/jive/thread.jspa?messageID=335876
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
> 
>