-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: My database is cleaned after an insert
PostPosted: Sun Oct 12, 2003 6:42 pm 
Newbie

Joined: Sun Oct 12, 2003 6:33 pm
Posts: 7
I am new to Hibernate. Suppose I have a SQL Server database with a single table and a couple existing entries.

When I run the following test code:

SessionFactory sf = new Configuration().configure().buildSessionFactory();
Session session = sf.openSession();
Transaction transaction = session.beginTransaction();
session.save( createEntry() );
transaction.commit();
session.close();

the object created by createEntry() is persisted, but all existing entries in the table are deleted.

The createEntry() method returns an instance of the class MyEntry, whose mapping is as follows:

<id name="id" type="int" unsaved-value="null" >
<column name="id" sql-type="int" not-null="true"/>
<generator class="assigned">
</generator>
</id>

<property name="clientName">
<column name="Cliente"/>
</property>

What could be happening? I have tried a couple generator id strategies, including sequence and increment, and the problem persists.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 13, 2003 8:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Hibernate does not clear the db as you are suggesting. You can turn the show sql property on and see what SQL is being generated by Hibernate. You can also set the appropriate log4j debug level. This will give you a clear picture of what is going on.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.