The moose likes Object Relational Mapping and the fly likes How to not reinialize tables created with JPA? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to not reinialize tables created with JPA?" Watch "How to not reinialize tables created with JPA?" New topic

How to not reinialize tables created with JPA?

Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 381
This example seems to work: http://javahowto.blogspot.com/2006/07/helloworld-with-jpa-toplink-and-mysql.html

However, when I comment out the statements that create and delete the objects (as I have done below), I expect to see it display the same greetings and messages. Instead, no messages are being retrieved. Apparently something is recreating the database tables every time I run the program. What do change so I can run this program and see the data previously entered into the database?




Vesa Tanhua-Tyrkk�

Joined: Jan 16, 2008
Posts: 25

This is configured in persistence.xml by property:
<property name="toplink.ddl-generation" value="drop-and-create-tables"/>

possible values for this are create-tables, drop-and-create-tables,none

So I think that by removing that property form persistence.xml preserves your data.
I agree. Here's the link: http://aspose.com/file-tools
subject: How to not reinialize tables created with JPA?
Similar Threads
persistence.xml file for MS SQL Server 2000
JBoss5.1 EJB3 JSF1.2 integration problem
How to start JPA
How to delete all records in a JPA table?
Query after JPA collective update not getting updates