problem refreshing a detached object
------------------------------------
Key: HHH-2396
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2396
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.2
Environment: Hibernate 3.2.2, Oracle OC4J 10.1.3 (JDK 1.5)
Reporter: Dmitry
Calling session.refresh() on a detached instance neither refreshes the instance, nor
throws any exception, while a refresh() gets triggered on another persistent instance with
the same identifier (if such a persistent instance is present in the session cache):
-----------------------------
MyClass obj1 = session.get(MyClass.class, someId);
System.out.println(obj1.getName()); // prints old value
session.evict(obj1); // obj1 is now detached
MyClass obj2 = session.get(MyClass.class, someId);
obj2.setName("new value");
session.save(obj2);
session.flush();
session.refresh(obj1); // this refresh() is somehow applied to obj2 - not obj1!
System.out.println(obj1.getName()); // still prints the old value!
System.out.println(obj2.getName()); // prints new value
-----------------------------
Configuraion:
<session-factory>
<property
name="hibernate.connection.datasource">java:comp/env/jdbc/EladCoreDS</property>
<property name="connection.pool_size">1</property>
<property
name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="current_session_context_class">thread</property>
<property
name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="show_sql">true</property>
<mapping resource="my.hbm.xml"/>
</session-factory>
Mapping:
<hibernate-mapping>
<class name="MyClass" table="SOME_TABLE"
dynamic-update="true" rowid="rowid"
optimistic-lock="version">
<id name="id" type="long" column="ID">
<generator class="assigned"/>
</id>
<version name="versionNumber" type="long"
column="VERSION#" unsaved-value="null"/>
<property name="code" column="CODE"
type="string"/>
<property name="name" column="NAME"
type="string"/>
</class>
</hibernate-mapping>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira