• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to not reinialize tables created with JPA?

 
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

Thanks,
Siegfried

HelloWorld.java:


Greeting.java:


Message.java:
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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.
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic