-->
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.  [ 1 post ] 
Author Message
 Post subject: persister.findModified returns many-to-one always modified
PostPosted: Mon Oct 03, 2005 6:15 pm 
Newbie

Joined: Thu Sep 29, 2005 9:00 pm
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0.5

Inside an PostUpdate Event listener I call isModified on EntityPersister to find the values that have been changed. A many-to-one relationship that I have is always identified as modified. (incorrectly) When I get down to it the problem appears to be that when calling equals() on that many-to-one object (called Person) It calls the Person.equals(), but instead of providing it with another Person, it is providing it with a java.lang.Long that is the ID of that Person...

It appears that the ManyToOneType.isModified calls AbstractType.isModified() passing the old value (as a Person) but calling getIdentifier(current, session) to get the identifier property of the current. I winds up trying to determine if Person and a Long are equal...obviously they are not.

Does anyone have any clue as to why it does this? It seems wrong.

Here is a stack trace that shows how it gets there
Code:
        at phase2.domain.Person.equals(Ljava.lang.Object;)Z(Person.java:49)
        at phase2.domain.Person$$FastClassByCGLIB$$b5bfa048.invoke(ILjava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(<generated>:???)
        at net.sf.cglib.proxy.MethodProxy.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(MethodProxy.java:149)
        at org.hibernate.proxy.CGLIBLazyInitializer.intercept(Ljava.lang.Object;Ljava.lang.reflect.Method;[Ljava.lang.Object;Lnet.sf.cglib.proxy.MethodProxy;)Ljava.lang.Object;(CGLIBLazyInitializer.java:137)
        at phase2.domain.Person$$EnhancerByCGLIB$$7e73c2f9.equals(Ljava.lang.Object;)Z(<generated>:???)
        at org.hibernate.util.EqualsHelper.equals(Ljava.lang.Object;Ljava.lang.Object;)Z(EqualsHelper.java:10)
        at org.hibernate.type.NullableType.isEqual(Ljava.lang.Object;Ljava.lang.Object;)Z(NullableType.java:118)
        at org.hibernate.type.NullableType.isEqual(Ljava.lang.Object;Ljava.lang.Object;Lorg.hibernate.EntityMode;)Z(NullableType.java:114)
        at org.hibernate.type.AbstractType.isSame(Ljava.lang.Object;Ljava.lang.Object;Lorg.hibernate.EntityMode;)Z(AbstractType.java:103)
        at org.hibernate.type.AbstractType.isDirty(Ljava.lang.Object;Ljava.lang.Object;Lorg.hibernate.engine.SessionImplementor;)Z(AbstractType.java:69)
        at org.hibernate.type.AbstractType.isModified(Ljava.lang.Object;Ljava.lang.Object;Lorg.hibernate.engine.SessionImplementor;)Z(AbstractType.java:99)
        at org.hibernate.type.ManyToOneType.isModified(Ljava.lang.Object;Ljava.lang.Object;Lorg.hibernate.engine.SessionImplementor;)Z(ManyToOneType.java:118)
        at org.hibernate.type.TypeFactory.findModified([Lorg.hibernate.tuple.StandardProperty;[Ljava.lang.Object;[Ljava.lang.Object;ZLorg.hibernate.engine.Sessi
onImplementor;)[I(TypeFactory.java:455)
        at org.hibernate.persister.entity.BasicEntityPersister.findModified([Ljava.lang.Object;[Ljava.lang.Object;Ljava.lang.Object;Lorg.hibernate.engine.Sessio
nImplementor;)[I(BasicEntityPersister.java:2566)
        at phase2.store.ChangeListener.onPostUpdate(Lorg.hibernate.event.PostUpdateEvent;)V(ChangeListener.java:39)


I would be happy to provide any other info desired.

I'm real stumped an would appreciate any insight,
Frank


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

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.