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.
|