-->
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: Updating DB without session.save or Update
PostPosted: Thu Jul 14, 2005 10:29 am 
Beginner
Beginner

Joined: Thu May 26, 2005 12:31 pm
Posts: 25
Hibernate version:2.1.8

Mapping documents:
<hibernate-mapping package="com.sample.dao">

<class
name="EMP"
table="TBPEMP"
>

<id
name="EMP_ID"
type="double"
unsaved-value="any"
column="EMP_ID"
>
<generator class="assigned"/>
</id>

<property
name="EMP_NAME"
type="java.lang.String"
column="EMP_NAME"
not-null="true"
length="20"
/>
</class>
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():
HibernateUtil.createSession();
HibernateUtil.beginTransaction();
session= HibernateUtil.getSession();
EMP emp = (EMP)session.load(EMP.class,new Double(11471884));
System.out.println(pol.getPOL_NUM());
emp.setEMP_NAME("New Name");
HibernateUtil.commit();


Full stack trace of any exception that occurs:

Name and version of the database you are using:
Oracle 9i


The generated SQL (show_sql=true):

First select statement for session.load...

then Update statement when doing commit.


I just loaded EMP object and modified obe field. Then just did commit WITHOUT doing session.save or update. Still its generated update statement and modifed data in DB. why it is happening like this? How to avoid this? Please help..


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 14, 2005 11:26 am 
Beginner
Beginner

Joined: Thu Jul 07, 2005 7:12 pm
Posts: 25
Maybe read up on what commit() does, and how flushing() works. You could have posted the generated SQL and debug statements.


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.