• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

[JPA 2.0] Redoploying app deletes my database?

 
Greenhorn
Posts: 24
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,

I'm using Glassfish v3 as app server, Java EE 6 Web, JSF and EclipseLink (JPA 2.0). My project was working just fine, redeploying was no problem, even if I deleted a table from my database EclipseLink would regenerate it without any hassle. But now when I drop a table from my database it will give me the following error:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'dkyc.question' doesn't exist

when it used to simply remake the table from the Entity. Also, when I undeploy the application, all my tables get dropped! Redeploying remakes the tables but of course the data is lost then.

If someone can helping in this it would be much appreciated.

My persistence.xml:


And this is the sun-resources.xml
 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your persistence.xml you have,

<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>

This will cause your database to be dropped and re-created when this persistent unit is initialized. If you do not want this, then remove this setting.

EclipseLink will never drop your database on undeploy.

The ddl-generation of "create" should create any missing tables, but this depends on the changes and constraints from existing tables.

What did you change from when it was working?
 
Abdullah Dokuyucu
Greenhorn
Posts: 24
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I deleted and remade my persistance units, which didn't seem to affect. I had an unused realm defined on the server, I deleted that. It's back to normal now... I had that realm defined since a while but looks like it messed with my Glassfish-v3 at some point.

I still couldn't figure out what exactly coused it.
 
Abdullah Dokuyucu
Greenhorn
Posts: 24
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I have a persistance unit that has table generation strategy as "Create" and a version of it with the "Drop and Create". Now most tables have the Create one and then another one has got

So I cannot use them together?

I think this problem started after I tried to have a third persistence unit that used a different JNDI and Connection pool (which was for another schema). I was trying to have my application persist from 2 different schemas (from same MySQL server though).
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If they have different schema/tables it is fine. But if they share the same tables, then one will be dropping the others tables.
 
No. No. No. No. Changed my mind. Wanna come down. To see this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic