-->
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.  [ 2 posts ] 
Author Message
 Post subject: unsaved-value="0" for native generator not working
PostPosted: Fri Dec 09, 2005 6:55 am 
Newbie

Joined: Fri Dec 09, 2005 2:43 am
Posts: 2
Dear all,

I have problem with sesion.load(Test.class, new Integer(id)) with the native type of generator if Id is zero.
Previously, this has been working fine with "increment". the returned object is null.

But after I changed it to "native", the same code returns "something" as Test$$EnhancerByCGLIB$$xxx when I use debugger to step into it.
I can't access any of its value using system out print. Since it is not null, when .save(), i get following error:

org.hibernate.util.JDBCExceptionReporter (JDBCExceptionReporter.java:58) - Cannot add or update a child row: a foreign key constraint fails
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.test.Test#0]
at org.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:27)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:171)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:140)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:119)
at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:593)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:59)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
at com.test.Test$$EnhancerByCGLIB$$fac28c5a.getIsTemplate(<generated>)



Apart from this, I starts to get LockAcquisitionException on and off.

<id name="id" column="`id`" type="integer" unsaved-value="0">
<generator class="native">
</generator>
</id>
lazy=true
in POJO, the data type for Id is "int"

Hibernate 3.0
MySQL 4.1 - jdbc connector 3.1.10



thank you in advance


Top
 Profile  
 
 Post subject: actually caused by lazy="true"
PostPosted: Fri Dec 09, 2005 8:41 pm 
Newbie

Joined: Fri Dec 09, 2005 2:43 am
Posts: 2
hi,

I managed to narrow down the problem. it's caused by lazy="true".
previously it was false.

If lazy=false then the returned object is null.

I understand that it's not encouraged to set the class lazy to true but since my hibernate files keep growing (now already 160 files, more to come), I always get java heap space.

yesterday tried to use Hibernate.initialise(test) but still getting the same error.

is there anyway to better handle this?


thank you[/b]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.