I am trying to retrieve data from table named user which is successfully retrieved some time but some time it automatically delete the data from table.
I am using
Hibernate version: 3
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Dec 17, 2008 1:38:05 PM by Hibernate Tools 3.1.0.beta5 -->
<hibernate-mapping>
<class name="com..entity.User" table="user" dynamic-update="true" catalog="database">
<comment></comment>
<id name="userId" type="string" length="30">
<column name="USER_ID" />
</id>
<property name="password" type="string" length="30">
<column name="PASSWORD">
<comment></comment>
</column>
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Transaction tx = null;
try {
Session currentSession = InitializeSessionFactory.getInstance().getCurrentSession();
tx = currentSession.beginTransaction();
//User temp = new User("doctor","doctor","DOCTOR",new Integer(1));
//currentSession.save(temp);
User user = (User)currentSession.get(User.class, userId);
tx.commit();
return user;
}catch(Exception e) {
tx.rollback();
logger.error(e.getMessage());
}
Name of the database :MySql
sql query:
Hibernate: select user0_.USER_ID as USER1_4_0_, user0_.PASSWORD as PASSWORD4_0_, user0_.USER_ROLE as USER3_4_0_, user0_.MAP_ID as MAP4_4_0_ from mcardio.user user0_ where user0_.USER_ID=?
_________________ Thanks.
Prashant Patil.
|