I would like an answer to this question too.
WebSphere Appserver 5 and WSAD5 does it this way.
I have enclosed a zip file with two EJBS - AlphaBean and BetaBean.
Please consider if this is the way JBoss is going to implement foreign keys mapped to primary keys.
If you look carefully you'll notice that WebSphere uses the actual NAMES of the foreign keys and implements them as cmp fields.
The database tables used in this example are like this:
aid (pk and foreign key to Alpha.aid)
The foreign key is named (f_alpha1)
Hmm... where did that zip file go. I'll try again
When I wrote that "I would like and answer to this question too" I has misunderstood your post. Its not a question - its a pointer on how to "do it".
What I don't understand is that this seems to mean that different containers does this in different ways which breaks portability.
Could you please give me a small example on how to do this. Especially the "Relationships are assigned between ejbCreate and ejbPostCreate" I don't understand.
> Especially the "Relationships are assigned
> between ejbCreate and ejbPostCreate" I don't
"This means that relationships are accessible in ejbPostCreate and not in ejbCreate."
It is work performed by the container in between the two methods to establish the relationship.
I'm specially interested on how to do this :
> It's possible to map foreign key fields in
> one-to-many and one-to-one
> relationships to the primary key fields. All is
> needed is to assign the same
> names to the corresponding foreign and primary key
What primary key field name and primary key class do you use if you implement a relation like this ?
The entity primary key should be made of its primary key field (if any) and one or more mapped foreign keys fields. How do you represent this in the ejb-jar.xml ?
How will the findByPrimaryKey() work ?
How to you define this kind of relationship in the jbosscmp-jdbc.xml deployment descriptor ?
Do you have a working sample of all this ?
Thanks in advance.