[ http://jira.andromda.org/browse/HIB-184?page=comments#action_13703 ]
Ronald Tschalär commented on HIB-184: ------------------------------------- This is probably due to a bug in the patch resulting from the fact that velocity variables are not scoped. From a quick re-reading of the code we have: #macro (renderPropertiesAndAssociations3 $entity $paramSqlPrefix $indent) ... #set ($sqlPrefix = $attribute.concatColumnName($paramSqlPrefix, $attribute.columnName)) #renderPropertiesAndAssociations3($attribute.type $sqlPrefix "$indent ") because $paramSqlPrefix effectively becomes an alias for $sqlPrefix, $sqlPrefix will grow with each "call" of the macro. The fix is to save the $sqlPrefix before the call and restore it afterwards. Probably something like (untested): #set ($sqlPrefix = $attribute.concatColumnName($paramSqlPrefix, $attribute.columnName)) #set ($_x = $varStack.add($sqlPrefix)) #renderPropertiesAndAssociations3($attribute.type $sqlPrefix "$indent ") #set ($_x = $varStack.size() - 1) #set ($sqlPrefix = $varStack.remove($_x)) and add this at the top, outside of the macro: #set ($varStack = []) > Duplicate Column names generated if EmbeddedValue containing another > EmbeddedValue is referenced twice > ------------------------------------------------------------------------------------------------------ > > Key: HIB-184 > URL: http://jira.andromda.org/browse/HIB-184 > Project: Hibernate Cartridge > Type: Bug > Versions: 3.2-RC1 > Environment: All > Reporter: Ronald Tschalär > Assignee: Carlos Cuenca > Fix For: 3.2-RC1 > Attachments: hibernate.patch.zip, hibernate_bug.jpg > > Assume you have an Entity A with two attributes, a1 and a2, both with > the same type which is an EmbeddedValue B; furthermore, assume that B > contains an attribute b1 of type another EmbeddedValue C (with some > attribute c1). Andromda will then generate two columns in the > hibernate descriptor for a1.b1.c1 and a2.b1.c1 but give them both the > same column name b1.c1 . > The problem is that the prefix used for to generate the column names > only contains the parent-attribute's name, but needs to include the > complete ancestor list in order to make it unique. Attached is a > simple patch, plus modified test case (see the SecondLevelEmbeddedType > class). > Attached is also a diagram excerpt from the test-case showing the > three relevant classes. Before the patch the column names generated > were both ATTR4_ATTR, and with the patch the names are > FIRST_EMBEDDED_ATTR4_ATTR and SECOND_EMBEDDED_ATTR4_ATTR. -- 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 ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV