• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate replacing my tables

 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Why is Hibernate replacing existing tables in the database with its own, different tables upon a call to session.find("from X")?

Here's my mapping document:

Here's the class I'm mapping:

And this is what I used for creating the table before triggering the SELECT from within Tomcat:


Note that I've included a 'password' column in the database and that isn't mapped to the User class.

Finally, this is what happens when Hibernate has had a chance to do the SELECT:


I'd really appreciate any pointers towards where I'm going to the woods.

I'm using Hibernate 2.1.6 and MySQL 4.0.22.

-Lasse-
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lasse I think you have enabled the hibernate.hbm2ddl.auto property set to create-drop. This will create and drop the tables each time you create a SessionFactory. Have a look in chapter 3.5

./pope
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the tip. I had already spotted that one from the bottom of the mile-long hibernate.properties which I had copy-pasted from somewhere but forgot to post here...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic