[
https://issues.apache.org/jira/browse/OPENJPA-2805?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Patrice DUROUX updated OPENJPA-2805:
------------------------------------
Attachment: node.zip
> unable to map self-related class with discrepancy between the annotation and
> XML ORMs
> -------------------------------------------------------------------------------------
>
> Key: OPENJPA-2805
> URL: https://issues.apache.org/jira/browse/OPENJPA-2805
> Project: OpenJPA
> Issue Type: Bug
> Affects Versions: 2.4.3, 3.0.0
> Reporter: Patrice DUROUX
> Priority: Major
> Attachments: node.zip
>
>
> Dear OpenJPA developers,
> I've been beating around the bush for a long time and hesitating to repport a
> bug until now.
> My problem is a much larger project but it can be summed up in the following
> situation. I would like to map such a class using an XML ORM onto a specific
> relational schema (I mean to not have any preferred column names for the
> corresponding join table).
>
> {noformat}
> public class Node2 implements Serializable {
> private static final long serialVersionUID = -3038751343463495553L;
> private Long id;
> public Long getId() {
> return id;
> }
> public void setId(Long id) {
> this.id = id;
> }
> private Node2 parent;
> public Node2 getParent() {
> return parent;
> }
> public void setParent(Node2 parent) {
> this.parent = parent;
> }
> private Set<Node2> childs;
> public Set<Node2> getChilds() {
> return childs;
> }
> public void setChilds(Set<Node2> childs) {
> this.childs = childs;
> }
> @Override
> public int hashCode() {
> final int prime = 31;
> int result = 1;
> result = prime * result + ((id == null) ? 0 : id.hashCode());
> return result;
> }
> @Override
> public boolean equals(Object obj) {
> if (this == obj)
> return true;
> if (obj == null)
> return false;
> if (getClass() != obj.getClass())
> return false;
> Node2 other = (Node2) obj;
> if (id == null) {
> if (other.id != null)
> return false;
> } else if (!id.equals(other.id))
> return false;
> return true;
> }
> public Node2() {
> this.childs = new LinkedHashSet<>();
> }
> }
> {noformat}
> I have a small Maven project with many persistence units as cases that are
> not given me the expected result (working or not). But doing this, I am also
> facing strange discrepancy between the annotation and the XML approaches
> (that are supposed to be equivalent to me for case1 and case2 if I am not
> wrong).
> Also I tried both using a runtime enhancement and a static one.
> I am have a zip of a small Maven project with a JUnit test for the different
> cases to check.
> In the larger project, I created a view to solve part of the problem. But
> then sure I cannot use the mapping to it to modify the persisted objects.
> Regards,
> Patrice
--
This message was sent by Atlassian Jira
(v8.3.4#803005)