[ http://jira.andromda.org/browse/EJB-67?page=comments#action_14651 ] 

Leandro Hermida commented on EJB-67:
------------------------------------

Hi Vance,

I need a little bit of help here (sorry - first time working with Velocity and 
andromda templates) with the patch to EntityEmbeddable.vsl.  As you suggested I 
looked at how its done for the ManyToMany associations, lines 792 - 799:

## Add the JoinTable annotation on the owning side
##
    @javax.persistence.JoinTable
    (
        name = "${associationEnd.association.tableName}",
        joinColumns = {#set ($identifiers = $entity.getIdentifiers())#foreach 
($attribute in $identifiers)@javax.persistence.JoinColumn(name = 
"$target.getForeignKeyConstraintName(${attribute.columnName})", 
referencedColumnName = "${attribute.columnName}")#if($velocityCount != 
$identifiers.size()), #end#end#**#},
        inverseJoinColumns = {#set ($identifiers = 
$target.type.getIdentifiers())#foreach ($attribute in 
$identifiers)@javax.persistence.JoinColumn(name = 
"$associationEnd.getForeignKeyConstraintName(${attribute.columnName})", 
referencedColumnName = "${attribute.columnName}")#if($velocityCount != 
$identifiers.size()), #end#end#**#}
    )

Here you have a loop to get the column name for each identifier and then using 
that you get the foreign key column name for that identifier.  But now for the 
ManyToOne section, line 565, and the OneToOne section, line 722, the present 
code is:

@javax.persistence.JoinColumn(name = 
"$stringUtils.upperCase(${target.name})"#if ($associationEnd.columnDefinition), 
columnDefinition = "${associationEnd.columnDefinition}"#end)

Taking an example many-to-one:

Document 0..* --------> 0..1 Provider

In Document.java I would want to see the annotation above the getProvider() 
method:

@javax.persistence.JoinColumn(name = "PROVIDER_IDC")

My question is, since I don't want to loop yet in all of the examples where you 
are using getForeignKeyConstraintName() you are in a loop and passing as a 
parameter to it the loop variable ${attribute.columnName} what would I need to 
do?  Would I need to do a loop any way to get the identifier for Provider so 
that I can then get the foreign key name?

Thanks,

Leandro


> Improved JoinColumn name for OneToOne and ManyToOne assocation annotations in 
> EJB3 cartridge
> --------------------------------------------------------------------------------------------
>
>          Key: EJB-67
>          URL: http://jira.andromda.org/browse/EJB-67
>      Project: EJB Cartridge
>         Type: Improvement

>     Reporter: Leandro Hermida
>     Assignee: Vance Karimi
>     Priority: Minor

>
> At present the JoinColumn name create by the EJB3 cartridge for OneToOne and 
> ManyToOne association annotations uses only the target table name as the 
> column name which is confusing since this column will hold FK data and thus 
> is an ID column.  Following discussion in the forum, 
> http://galaxy.andromda.org/forum/viewtopic.php?t=4909, we think its a good 
> idea to append an _ID suffix or similar to this JoinColumn name.

-- 
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


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

Reply via email to