1

This is a simply one - how can I make my DB (I am using Derby) to commit the changes in entity(I mean changing the column name, constraints, etc)? Because I've discovered when I change something in entity atributes, my DB still remains the same. I am also using Netbeans if there is any functionality for this.

I am now aware of hibernate.hbm2ddl.auto, but I am looking for something similar(e.g. I don't want to drop date during structure changes from entity to DB)

Petr Mensik
  • 26,874
  • 17
  • 90
  • 115

1 Answers1

4

You didn't specify your persistence provider, but I'll assume hibernate; you can use the hibernate.hbm2ddl.auto configuration parameter to tell hibernate to recreate the tables. See this SO question for more details. Note that you should not use this in production; see this SO question for those details.

Community
  • 1
  • 1
beerbajay
  • 19,652
  • 6
  • 58
  • 75
  • No, I am using EclipseLink. Well after some googling, I see that I should set eclipselink.ddl-generation to drop-and-create-tables, but I will also lose my data, so is there any other way for doing this? – Petr Mensik Feb 22 '12 at 21:27
  • I haven't used EclipseLink; in hibernate you can set `hibernate.hbm2ddl.auto` to `update`, as discussed in the second link, but I've never tried this. This isn't safe; if you need it for test/development purposes, you can try using DBUnit; there's a tutorial in [this blog post](http://www.antoniogoncalves.org/xwiki/bin/view/Article/TestingJPA#HAddingDbUnit). – beerbajay Feb 22 '12 at 21:37