[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3030?page=c...
]
Rishik Dhar commented on HHH-3030:
----------------------------------
I encountered the same problem and after a bit of painful hit and trials I realized the
reason in my case was that the table in database corresponding to the object that was
being loaded, modified and persisted (and encountered a NullPointerException) was that the
version field was a newly introduced column in an existing (and being used by the
Application) table with no values in the column to begin with.
I have introduced the column and added the mapping however, while loading the objects from
the DB, the value for "version" column is "null", hence the exception.
I even tried modifying the setter method for the version field in the object being loaded,
just to put a default value when a null was encountered, yet it didn't matter because
the value is loaded from EntityEntry.getVersion() which is initialized as null as of now.
Hope this info helps you!
NullPointerException happens in versioning
------------------------------------------
Key: HHH-3030
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3030
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.5
Environment: any
Reporter: John
Priority: Minor
Here is the stack trace:
java.lang.NullPointerException
at org.hibernate.type.IntegerType.next(IntegerType.java:59)
at org.hibernate.engine.Versioning.increment(Versioning.java:25)
at
org.hibernate.event.def.DefaultFlushEntityEventListener.getNextVersion(DefaultFlushEntityEventListener.java:358)
at
org.hibernate.event.def.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:250)
at
org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:121)
at
org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196)
at
org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at
org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:969)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1114)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
......
The code is:
public Object next(Object current, SessionImplementor session) {
return new Integer( ( (Integer) current ).intValue() + 1 );
}
Should there be a null checking for the object "current"?
--
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