-->
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: hibernate.use_identifier_rollback can't work
PostPosted: Fri Dec 19, 2008 3:41 am 
Newbie

Joined: Tue Aug 29, 2006 2:54 am
Posts: 16
Dear all
I read the book "Java Persistence with Hibernate"
In page 407, it says that if you enable the hibernat.use_identifier_rollback configuration option.Hibernate sets the database identifier property of the deleted item to null after deletion and flushing.

I want to try this feature but it can't work.
The code and hibernate configuration as below.
Can someone help me to see if there are any problem?
Code:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>

   <session-factory>
      <property name="dialect">
         org.hibernate.dialect.Oracle9Dialect
      </property>
      <property name="connection.url">
         jdbc:oracle:thin:@localhost:1521:TESTDB
      </property>
      <property name="connection.username">abc</property>
      <property name="connection.password">123</property>
      <property name="connection.driver_class">
         oracle.jdbc.driver.OracleDriver
      </property>
      <property name="hibernate.use_identifier_rollback">true</property>
      <mapping resource="com/test/Item.hbm.xml" />
   </session-factory>

</hibernate-configuration>


Code:
    public static void main( String[] args )
    {
        Session session = HibernateSessionFactory.getSession();
        Transaction tx = session.beginTransaction();
        Item item = (Item)session.load( Item.class , new Long(1) );
        session.delete( item );
        tx.commit();
        System.out.println( item.getItemId());   //The PK item_id is not set to null
        session.close();
    }


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.