[ http://jira.andromda.org/browse/HIB-173?page=comments#action_13200 ]
Stefan Weise commented on HIB-173: ---------------------------------- Hi Carlos. I just played around with your patch and I found out that it is not working as expected. The first issue is that you forgot to set the other end if we have an aggregation or a composition. If you are on the other side of an aggregation or composition the method still uses the lexical stuff. The other issue is that the inverse flag of a many2many aggregation/composition behaves in the opposite way than of a one2many aggregation/composition. Here is my solution how this could be fixed: protected boolean handleIsHibernateInverse() { // inverse can only be true if the relation is bidirectional boolean inverse = this.isNavigable() && this.getOtherEnd().isNavigable(); if (inverse) { inverse = this.isMany2One(); // for many-to-many we just put the flag on the side that // is aggregation or composition and on the lexically longer // fully qualified name for it's type on other types of relations if (this.isMany2Many() && !inverse) { if (this.isAggregation() || this.isComposition()) { inverse = false; } else if (this.getOtherEnd().isAggregation() || this.getOtherEnd().isComposition()) { inverse = true; } else { String endTypeName = StringUtils.trimToEmpty(this.getType().getFullyQualifiedName(true)); String otherEndTypeName = StringUtils.trimToEmpty(this.getOtherEnd().getType().getFullyQualifiedName(true)); int compareTo = endTypeName.compareTo(otherEndTypeName); .... snip .... > many2many inverse > ----------------- > > Key: HIB-173 > URL: http://jira.andromda.org/browse/HIB-173 > Project: Hibernate Cartridge > Type: Improvement > Versions: 3.1 > Reporter: Darius Schier > Assignee: Carlos Cuenca > Fix For: 3.2-RC1 > > Hi there, > until now many2many associations added the inverse flag at that side which's > side was lexically longer. By a minor change within hibernate's association > end locig implementation, the behaviour could be more deterministic: > protected boolean handleIsHibernateInverse() > { > // inverse can only be true if the relation is bidirectional > boolean inverse = this.isNavigable() && > this.getOtherEnd().isNavigable(); > if (inverse) > { > inverse = this.isMany2One(); > if (this.isMany2Many() && !inverse) > { > inverse = isAggregation() || isComposition(); > } > } > return inverse; > } > Setting the values at the "diamond's" side should be enough (which could be a > matter of discussion of course). -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.andromda.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642