Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Parent Child Heirarchy with Subclasses Bug
Parent Child Heirarchy with Subclasses Bug [message #518021] Tue, 02 March 2010 19:28 Go to next message
Brendan Haverlock is currently offline Brendan HaverlockFriend
Messages: 46
Registered: July 2009
Member
Hi all...please bear with me here.

I have an abstract class called Item. Item is subclassed using joined inheritance to many different implementation classes. Items can be related to each other through an ItemRelatiionship class. So, here's relevant code below.

@Entity
@Table(name = "item")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "item_type_id", discriminatorType = DiscriminatorType.STRING)
public abstract class Item implements Serializable {
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "itemTarget")
    private List<ItemRelationship> targetRelationships;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "itemSource")
    private List<ItemRelationship> sourceRelationships;
}

@Entity
@Table(name = "item_relationship")
public class ItemRelationship implements Serializable {

    @Id
    @Basic(optional = false)
    @Column(name = "item_relationship_key")
    private Integer itemRelationshipKey;
    @Column(name = "sequence_number")
    private Integer sequenceNumber;
    @JoinColumn(name = "item_target_key", referencedColumnName = "item_key")
    @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE})
    private Item itemTarget;
    @JoinColumn(name = "item_source_key", referencedColumnName = "item_key")
    @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE})
    private Item itemSource;
    @JoinColumn(name = "item_relationship_type_key", referencedColumnName = "item_relationship_type_key")
    @ManyToOne
    private ItemRelationshipType itemRelationshipType;
}

EXAMPLE IMPLEMENTATION CLASS:

@Entity
@Table(name = "item_impl")
@DiscriminatorValue("item_impl")
public class ItemImpl extends Item


Now, take for instance I want to store a parent-child relationship in the sourceRelationships and targetRelationships fields. So, when adding a relationship I create a new ItemRelationship. I then proceed to add it to both the child's targetRelationships List and the parent's sourceRelationships List. Now, this is all working fine and dandy until I've persisted somewhere between 100-1000 entities. All of the sudden, I get an error on every em.merge saying that EclipseLink is firing a property changed event for the WRONG class that is implementing item. So, it's basically trying to call the setter on one of the implementations of Item, but not the correct one. From then on, it is broken and I every em.merge call fails with the same error from then on.

It seems like this is an issue with EclipseLink getting confused with the implementation class to use during persistence. Any help would be much appreciated. This appears to be a bug, however, but I'll let the experts weigh in.

Thanks in advance,
-Brendan
Re: Parent Child Heirarchy with Subclasses Bug [message #518084 is a reply to message #518021] Tue, 02 March 2010 23:50 Go to previous messageGo to next message
Brendan Haverlock is currently offline Brendan HaverlockFriend
Messages: 46
Registered: July 2009
Member
Oh yes, let me also give the exception that is actually happening:

EJB5018: An exception was thrown during an ejb invocation on [Bean]
javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean; nested exception is: Exception [EclipseLink-7173] (Eclipse Persistence Services - 1.2.0.v20091016-r5565): org.eclipse.persistence.exceptions.ValidationException
Exception Description: A property change event has been fired on a property with name [itemImplProperty] in [class com.test.ItemImpl].  However this property does not exist.
Local Exception Stack: 
Exception [EclipseLink-7173] (Eclipse Persistence Services - 1.2.0.v20091016-r5565): org.eclipse.persistence.exceptions.ValidationException
Exception Description: A property change event has been fired on a property with name [itemImplProperty] in [class com.test.ItemImpl].  However this property does not exist.


I have tried EclipseLink 2.0, and I still run into the same problem.
Re: Parent Child Heirarchy with Subclasses Bug [message #518580 is a reply to message #518021] Thu, 04 March 2010 14:46 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Could you include the stack trace.


James : Wiki : Book : Blog : Twitter
Re: Parent Child Heirarchy with Subclasses Bug [message #518688 is a reply to message #518021] Thu, 04 March 2010 18:30 Go to previous messageGo to next message
Brendan Haverlock is currently offline Brendan HaverlockFriend
Messages: 46
Registered: July 2009
Member
Oops, sorry that would help wouldn't it Wink

EJB5018: An exception was thrown during an ejb invocation on [Bean]
javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean; nested exception is: Exception [EclipseLink-7173] (Eclipse Persistence Services - 1.2.0.v20091016-r5565): org.eclipse.persistence.exceptions.ValidationException
Exception Description: A property change event has been fired on a property with name [itemImplProperty] in [class com.test.ItemImpl].  However this property does not exist.
Local Exception Stack: 
Exception [EclipseLink-7173] (Eclipse Persistence Services - 1.2.0.v20091016-r5565): org.eclipse.persistence.exceptions.ValidationException
Exception Description: A property change event has been fired on a property with name [itemImplProperty] in [class com.test.ItemImpl].  However this property does not exist.
        at org.eclipse.persistence.exceptions.ValidationException.wrongPropertyNameInChangeEvent(ValidationException.java:2010)
        at org.eclipse.persistence.internal.descriptors.changetracking.AttributeChangeListener.internalPropertyChange(AttributeChangeListener.java:127)
        at org.eclipse.persistence.descriptors.changetracking.ObjectChangeTrackingPolicy.raiseInternalPropertyChangeEvent(ObjectChangeTrackingPolicy.java:101)
        at org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.mergeIntoObject(AbstractDirectMapping.java:1004)
        at org.eclipse.persistence.internal.descriptors.ObjectBuilder.mergeIntoObject(ObjectBuilder.java:2653)
        at org.eclipse.persistence.internal.sessions.MergeManager.mergeChangesOfCloneIntoWorkingCopy(MergeManager.java:506)
        at org.eclipse.persistence.internal.sessions.MergeManager.mergeChanges(MergeManager.java:267)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.mergeCloneWithReferences(UnitOfWorkImpl.java:3481)
        at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.mergeCloneWithReferences(RepeatableWriteUnitOfWork.java:301)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.mergeCloneWithReferences(UnitOfWorkImpl.java:3441)
        at org.eclipse.persistence.internal.jpa.EntityManagerImpl.mergeInternal(EntityManagerImpl.java:327)
        at org.eclipse.persistence.internal.jpa.EntityManagerImpl.merge(EntityManagerImpl.java:304)
        at com.sun.enterprise.util.EntityManagerWrapper.merge(EntityManagerWrapper.java:476)
Re: Parent Child Heirarchy with Subclasses Bug [message #520596 is a reply to message #518688] Sat, 13 March 2010 01:38 Go to previous messageGo to next message
Brendan Haverlock is currently offline Brendan HaverlockFriend
Messages: 46
Registered: July 2009
Member
Any clue anyone? Smile I am about to shoot myself over this issue. Every possible refactoring I try always results in the same problem.
Re: Parent Child Heirarchy with Subclasses Bug [message #522426 is a reply to message #518021] Mon, 22 March 2010 15:38 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

I can't see how this could occur.

Where is the attribute itemImplProperty defines, and what is the relation to the ItemImpl. Is it just merge() that fails, or does persist(), or other operations fail as well?

I would try the latest 2.0.1 release.

You may also be able to disable weaving of change tracking to possibly avoid the issue, as the error seems to be in change tracking. ("eclipselink.weaving.changetracking"="false")


James : Wiki : Book : Blog : Twitter
Re: Parent Child Heirarchy with Subclasses Bug [message #522486 is a reply to message #522426] Mon, 22 March 2010 18:40 Go to previous messageGo to next message
Brendan Haverlock is currently offline Brendan HaverlockFriend
Messages: 46
Registered: July 2009
Member
I am using 2.0.1 and it was still exhibiting the same problem.

The attribute itemImplProperty is in the ItemImpl class, not in the Item class. Sorry, I forgot to put that in the original code. I only use the merge() operation, so I am not sure if it happens with persist().

I disabled "eclipselink.weaving.changetracking" and so far it seems to be working. I will need to let it run a little longer before confirming this, though.

Thanks for the help! Hopefully, this info will help you isolate this obscure problem.
Re: Parent Child Heirarchy with Subclasses Bug [message #523189 is a reply to message #518021] Thu, 25 March 2010 13:30 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Still can't see how this could occur. Can you put a break-point in the exception and inspect the descriptor's mappings. For some reason it does not have a mapping for "itemImplProperty". Are you renaming your mapping's attributes or doing something unusual?


James : Wiki : Book : Blog : Twitter
Re: Parent Child Heirarchy with Subclasses Bug [message #523288 is a reply to message #523189] Thu, 25 March 2010 18:59 Go to previous messageGo to next message
Brendan Haverlock is currently offline Brendan HaverlockFriend
Messages: 46
Registered: July 2009
Member
Ok, I have done hundreds of thousands of new entities without the problem occurring once I set that property, so it definitely has to do with the version tracking.

No, I am not doing anything unusual. The problem that is occurring is that I think it has a mapping for a different entities fields. So, picture there being ItemImpl, ItemImpl2, ItemImpl3 ... ItemImplN and each of these having different fields. Now, when it comes time to persist ItemImpl2, the changetracking is firing the property change event on ItemImpl2 but for a property on one of the other ItemImpls. Of course, it doesn't exist on ItemImpl2 so it blows up with this exception and continues to do so until I restart the app server.

I am more than happy to do a gotomeeting with you to show you it in action if you are still not able to track it down.

[Updated on: Thu, 25 March 2010 19:23]

Report message to a moderator

Re: Parent Child Heirarchy with Subclasses Bug [message #523816 is a reply to message #523288] Mon, 29 March 2010 13:45 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

If you can isolate the problem, and create a simple test case for it, please log a bug.



James : Wiki : Book : Blog : Twitter
Re: Parent Child Heirarchy with Subclasses Bug [message #525545 is a reply to message #523816] Tue, 06 April 2010 20:11 Go to previous messageGo to next message
Brendan Haverlock is currently offline Brendan HaverlockFriend
Messages: 46
Registered: July 2009
Member
Hmm, I can't isolate it. I was hoping you'd be able to figure out the problem based on the exception and the scenario I set up.
Re: Parent Child Heirarchy with Subclasses Bug [message #686306 is a reply to message #525545] Wed, 22 June 2011 01:17 Go to previous messageGo to next message
darren is currently offline darrenFriend
Messages: 19
Registered: March 2011
Location: Sydney, Australia
Junior Member
EclipseLink2.2

Hi, resuming this thread, however my problem may by slightly different, as I'm hitting:

org.eclipse.persistence.exceptions.ValidationException
Exception Description: A property change event has been fired on a property with name [null]

Please advise if this should be rethreaded, however the fix eclipselink.weaving.changetracking="false" in my persistence.xml works for my problem, too.

The relevant part of the error log is:

Caused by: Exception [EclipseLink-7173] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.ValidationException
Exception Description: A property change event has been fired on a property with name [null] in [class com.greensoft.entity.greenstar.office.activity.Activity_IEQ14_1]. However this property does not exist.
at org.eclipse.persistence.exceptions.ValidationException.wrongPropertyNameInChangeEvent(ValidationException.java:2021)
at org.eclipse.persistence.internal.descriptors.changetracking.AttributeChangeListener.internalPropertyChange(AttributeChangeListener.java:127)
at org.eclipse.persistence.internal.descriptors.changetracking.AttributeChangeListener.propertyChange(AttributeChangeListener.java:111)
at org.eclipse.persistence.indirection.IndirectList.raiseAddChangeEvent(IndirectList.java:144)
at org.eclipse.persistence.indirection.IndirectList.raiseAddChangeEvent(IndirectList.java:140)
at org.eclipse.persistence.indirection.IndirectList.add(IndirectList.java:187)
at com.greensoft.entity.Parsel.addInvolvedClassName(Parsel.java:470)
at com.greensoft.entity.Parsel.addInvolvedClass(Parsel.java:478)
at com.greensoft.ejb.greenstar.GreenStarOfficeProjectBuilder.activity_IEQ14_1(GreenStarOfficeProjectBuilder.java:816)

Where Activity_IEQ14_1 extends Activity extends Parsel, and the property involvedClassName and the related methods in Parsel are:

public boolean addInvolvedClass(Class clazz) {
        return addInvolvedClassName(clazz.getName());
    }


private List<String> involvedClassNames = new ArrayList<String>();
 
    @ElementCollection()
    public List<String> getInvolvedClassNames() {
        return involvedClassNames;
    }
 
    public void setInvolvedClassNames(List<String> involvedClassNames) {
        this.involvedClassNames = involvedClassNames;
    }
 
    public boolean addInvolvedClassName(String className) {
        if (getInvolvedClassNames().contains(className)) {
            return false;
        }
        return getInvolvedClassNames().add(className);
    }

(Aside: a List with contains checking is used instead of a Set because JSF2 can't iterate over sets.)

The chain is triggered by:
activity_IEQ14_1.addInvolvedClass(Wood.class);


The class Activity_IEQ14_1 is at the end of a complex class hierarchy with lots of properties (too many to easily report here), but certainly none of them are [null].

I don't see how the class Wood could be involved, only its class name is eventually passed to a String ElementCollection.

I have no idea why this "suddenly" started to happen, I had been using this exact code for months without any trouble.

One thing that recently changed was that I upgraded from Glassfish3.0.1 to Glassfish3.1, and from EclipseLink2.2RC4 (eclipselink-2.2.0.v20110202-r8913) to EclipseLink2.2 as bundled with Glassfish3.1 (in Netbeans7 BTW).

I'm scratching my head to think of what else could have changed where, it's very difficult to isolate the problem, short of going back to revive my Glassfish3.0.1 environment and trying this newer code on it, which is a lot of effort (as there are some other aspects of the latest entire code set known not to run on my older environment for other reasons).

Glad for feedback, and whether to raise this as a bug (I think it must be),

Webel
(no subject) [message #686307 is a reply to message #525545] Wed, 22 June 2011 01:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: <forums-noreply

EclipseLink2.2

Hi, resuming this thread, however my problem may by slightly different, as I'm hitting:

org.eclipse.persistence.exceptions.ValidationException
Exception Description: A property change event has been fired on a property with name [null]

Please advise if this should be rethreaded, however the fix eclipselink.weaving.changetracking="false" in my persistence.xml works for my problem, too.

The relevant part of the error log is:

Caused by: Exception [EclipseLink-7173] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.ValidationException
Exception Description: A property change event has been fired on a property with name [null] in [class com.greensoft.entity.greenstar.office.activity.Activity_IEQ14_1]. However this property does not exist.
at org.eclipse.persistence.exceptions.ValidationException.wrongPropertyNameInChangeEvent(ValidationException.java:2021)
at org.eclipse.persistence.internal.descriptors.changetracking.AttributeChangeListener.internalPropertyChange(AttributeChangeListener.java:127)
at org.eclipse.persistence.internal.descriptors.changetracking.AttributeChangeListener.propertyChange(AttributeChangeListener.java:111)
at org.eclipse.persistence.indirection.IndirectList.raiseAddChangeEvent(IndirectList.java:144)
at org.eclipse.persistence.indirection.IndirectList.raiseAddChangeEvent(IndirectList.java:140)
at org.eclipse.persistence.indirection.IndirectList.add(IndirectList.java:187)
at com.greensoft.entity.Parsel.addInvolvedClassName(Parsel.java:470)
at com.greensoft.entity.Parsel.addInvolvedClass(Parsel.java:478)
at com.greensoft.ejb.greenstar.GreenStarOfficeProjectBuilder.activity_IEQ14_1(GreenStarOfficeProjectBuilder.java:816)

Where Activity_IEQ14_1 extends Activity extends Parsel, and the property involvedClassName and the related methods in Parsel are:


public boolean addInvolvedClass(Class clazz) {
return addInvolvedClassName(clazz.getName());
}



private List<String> involvedClassNames = new ArrayList<String>();

@ElementCollection()
public List<String> getInvolvedClassNames() {
return involvedClassNames;
}

public void setInvolvedClassNames(List<String> involvedClassNames) {
this.involvedClassNames = involvedClassNames;
}

public boolean addInvolvedClassName(String className) {
if (getInvolvedClassNames().contains(className)) {
return false;
}
return getInvolvedClassNames().add(className);
}

(Aside: a List with contains checking is used instead of a Set because JSF2 can't iterate over sets.)

The chain is triggered by:

activity_IEQ14_1.addInvolvedClass(Wood.class);


The class Activity_IEQ14_1 is at the end of a complex class hierarchy with lots of properties (too many to easily report here), but certainly none of them are [null].

I don't see how the class Wood could be involved, only its class name is eventually passed to a String ElementCollection.

I have no idea why this "suddenly" started to happen, I had been using this exact code for months without any trouble.

One thing that recently changed was that I upgraded from Glassfish3.0.1 to Glassfish3.1, and from EclipseLink2.2RC4 (eclipselink-2.2.0.v20110202-r8913) to EclipseLink2.2 as bundled with Glassfish3.1 (in Netbeans7 BTW).

I'm scratching my head to think of what else could have changed where, it's very difficult to isolate the problem, short of going back to revive my Glassfish3.0.1 environment and trying this newer code on it, which is a lot of effort (as there are some other aspects of the latest entire code set known not to run on my older environment for other reasons).

Glad for feedback, and whether to raise this as a bug (I think it must be),

Webel
Re: Parent Child Heirarchy with Subclasses Bug [message #687308 is a reply to message #518021] Wed, 22 June 2011 17:46 Go to previous messageGo to next message
Brendan Haverlock is currently offline Brendan HaverlockFriend
Messages: 46
Registered: July 2009
Member
I will tell you that I got rid of the problem by getting rid of both of the lists on the Item class. I combined them into one list and put a type attribute on them to differentiate whether they are source or target. For some reason, EclipseLink did not like me having two one to manys pointing to the same table in this situation. Very weird.
(no subject) [message #687540 is a reply to message #518021] Wed, 22 June 2011 17:46 Go to previous message
Brendan Haverlock is currently offline Brendan HaverlockFriend
Messages: 46
Registered: July 2009
Member
I will tell you that I got rid of the problem by getting rid of both of the lists on the Item class. I combined them into one list and put a type attribute on them to differentiate whether they are source or target. For some reason, EclipseLink did not like me having two one to manys pointing to the same table in this situation. Very weird.
Previous Topic:Dali Java Persistence Tools 3.0 released
Next Topic:@UnionPartitioning does not seem to be using the correct connection pool
Goto Forum:
  


Current Time: Thu Mar 28 22:50:34 GMT 2024

Powered by FUDForum. Page generated in 0.04408 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top