-->
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.  [ 1 post ] 
Author Message
 Post subject: string as primary ky mapping in hbm.xml
PostPosted: Thu Dec 18, 2008 1:38 am 
Newbie

Joined: Thu Dec 18, 2008 1:06 am
Posts: 3
Location: Pune
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.


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

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.