Recent Posts

RSS Feeds

Bogus Hibernate Config - tail chasing adventure

Well I spent about 2 hrs today tracking down stupidity in my hibernate configuration. The problem boiled down to specifying that my one-to-one relationship was constrained but I'd also said the two entities share a common key. Which is not the way its supposed to work, either the one-to-one is a pseudo many-to-one with a foreign key and the FK is (can be) constrained or they two entities share a common primary key, but not both.

Anyway I was getting an error message about a relationship (included at the end of this entry as a stack trace) which lead me down the path of looking at the relationship. However as I dug in I noticed that the request had a selection criteria and vice versa. I got further distracted by the exception that was being thrown. The real exception was a null pointer exception thrown in the versioning code. Specifically net.sf.hibernate.engine.Versioning.increment(Object, VersionType) was being passed null as the first argument. That lead me down a 2hr deep rabbit trail.

The correct config for the child object is as follows;

<id name="id" column="id" type="integer" unsaved-value="null" > <generator class="foreign"> <param name="property">request</param>> </generator> </id>

hopefully this stack trace and discussion will help others stuck here.

org.springframework.orm.hibernate.HibernateSystemException: not-null property references a null or transient value: ....SelectionCriteriaHibernate.request; nested exception is net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: ....SelectionCriteriaHibernate.request net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: com.fanniemae.idqc.domain.hibernate.SelectionCriteriaHibernate.request at net.sf.hibernate.impl.SessionImpl.checkNullability(SessionImpl.java:1277) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:928) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857) at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:779)

Permalink     1 Comment



Comments:

I'm seeing the same "net.sf.hibernate.engine.Versioning.increment(Object, VersionType) was being passed null as the first argument" problem. What did you figure out the cause to be?

Ted

Posted by Ted on February 10, 2005 at 03:13 PM MST #

Post a Comment:
  • HTML Syntax: Allowed