aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate replacing my tables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate replacing my tables" Watch "Hibernate replacing my tables" New topic
Author

Hibernate replacing my tables

Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
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-


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
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


blog - InfoQ.com
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
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...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate replacing my tables
 
Similar Threads
My class is not mapped
Three problems with mysql...
need help in JPA ANNOTATION regarding Inheritance.
Mapping ENUM('0', '1') or CHAR(0) for Boolean
Retreving PDF File from Database using Java