Parent Child Heirarchy with Subclasses Bug [message #518021] |
Tue, 02 March 2010 19:28 |
Brendan Haverlock 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 #522426 is a reply to message #518021] |
Mon, 22 March 2010 15:38 |
|
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 #523288 is a reply to message #523189] |
Thu, 25 March 2010 18:59 |
Brendan Haverlock 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 #686306 is a reply to message #525545] |
Wed, 22 June 2011 01:17 |
darren 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 |
Eclipse User |
|
|
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06409 seconds