[ http://jira.andromda.org/browse/HIB-159?page=comments#action_12480 ] Tomasz Bech commented on HIB-159: ---------------------------------
There is a second bug related to this topic (major as well). Scenario: B inherits from A (with 'class' type). C reference to B (the association end is called c2b and its multiplicity is set to 1. The $otherEnd.required is resolved to 'false' - should be 'true' (inheritance on the other end never shoud have impact on mandatory - I'm talking of class C here). Problematic code: HibernateAssociationEndLogicImpl.java /** * Overridden to provide handling of inheritance. * * @see org.andromda.metafacades.uml.AssociationEndFacade#isRequired() */ public boolean isRequired() { boolean required = super.isRequired(); Object type = this.getType(); if ((type != null) && HibernateEntity.class.isAssignableFrom(type.getClass())) { HibernateEntity entity = (HibernateEntity)type; if (entity.isHibernateInheritanceClass() && (entity.getGeneralization() != null)) { required = false; } } return required; } Here is is checked if the class 'onTheOtherEnd' has 'inheritance class'. It should be if the class 'onTheSourceEnd' has 'inheritance class'. (+ the same remark as above, detecting of 'inheritance class' is wrong) > not-null for 'class' inheritance set to false wrongly > ----------------------------------------------------- > > Key: HIB-159 > URL: http://jira.andromda.org/browse/HIB-159 > Project: Hibernate Cartridge > Type: Bug > Reporter: Tomasz Bech > Assignee: Carlos Cuenca > Fix For: 3.2-RC1 > > Scenario: Entity A - inheritance type'interface', Entity B : extends A - > inheritance type 'class'. > In B there is an attribute which is required. In generated hibernate xml file > 'not-null' is set to false (should be true). The buggy part of code: > public boolean isRequired() > { > boolean required = super.isRequired(); > if (this.getOwner() instanceof HibernateEntity) > { > HibernateEntity entity = (HibernateEntity)this.getOwner(); > //BUG: here should be "if any of Generalization.type != > 'interface')" > if (entity.isHibernateInheritanceClass() && > entity.getGeneralization() != null) > { > required = false; > } > } > return required; > } > Additionaly, imho it is not good to handle it in java code, the better place > is the velocity template. If the same bean is used for mapping both Hibernate > and Struts/WEB presentation layer, the information about not-null is lost (it > is overriden to 'false' by AndroMDA for sublcasses). So there is a need to > add additional tagged value to mark not-null field for presentation layer - > it is kinda awkward. ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642