Message:
A new issue has been created in JIRA.
---------------------------------------------------------------------
View the issue:
http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-377
Here is an overview of the issue:
---------------------------------------------------------------------
Key: HB-377
Summary: Hibernate 2.1 appears to break jcs caching
Type: Bug
Status: Unassigned
Priority: Major
Project: Hibernate2
Components:
core
Versions:
2.1
Assignee:
Reporter: tekno
Created: Thu, 2 Oct 2003 4:34 AM
Updated: Thu, 2 Oct 2003 4:34 AM
Environment: Development Windows 2000 SP3, JSDK 4.1.2
Deployment Solaris 9
Database Postgresql 7.3
Description:
I am getting an AssertionFailure - cannot cache a reference to an object with a null id when I try to do an update. Here is the sample code -
NB: This has been working fine for me in hibernate versions 2.0 - 2.03
I have the following two mappings
<class name="Customer" table="customers" polymorphism="explicit">
<cache usage="read-write"/>
<id name="id" unsaved-value="0">
<generator class="sequence">
<param name="sequence">customers_id_seq</param>
</generator>
</id>
<property name="postcode"/>
<many-to-one name="csOwner" class="Employee" column="cs_owner" />
</class>
and
<class name="Employee" table="staff">
<id name="id">
<generator class="sequence">
<param name="sequence">staff_id_seq</param>
</generator>
</id>
<property name="name"/>
</class>
the following main() throws the exception
Session session = null;
Customer customer = null;
SessionFactory factory = null;
try {
// build factory
factory = new Configuration().configure().buildSessionFactory();
System.out.println("Starting first session");
// first session gets customer instance
session = factory.openSession();
customer = (Customer) session.load(Customer.class, new Long(1275));
System.out.println("Loaded customer " + customer.getId() + " has owner " + customer.getCsOwner().getId());
session.flush();
session.connection().commit();
session.close();
System.out.println("Updating address field");
// update a field
customer.setPostcode("TESTING");
System.out.println("Starting second session");
// second session persists update
session = factory.openSession();
session.update(customer);
session.flush();
session.connection().commit();
session.close();
System.out.println("Finished");
factory.close();
} catch (Exception ex){
ex.printStackTrace();
} finally {
if(session!=null)session.close();
if(factory!=null)factory.close();
System.exit(0);
}
If i remove the cache entry in the customer mapping everything is OK, but other wise i get
net.sf.hibernate.AssertionFailure: cannot cache a reference to an object with a null id
at net.sf.hibernate.type.EntityType.disassemble(EntityType.java:89)
at net.sf.hibernate.impl.CacheEntry.disassemble(CacheEntry.java:36)
at net.sf.hibernate.impl.CacheEntry.<init>(CacheEntry.java:27)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:42)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2278)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2235)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2178)
at com.lab.model.HibBug.main(HibBug.java:46)
---------------------------------------------------------------------
JIRA INFORMATION:
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.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
|