Not sure I understood you completely.
Yes, you can implement relationship between the two.
And then you can execute select statement with JDBC.
But it won't work as EJB-QL. In EJB-QL results of select can be beans' local interface or cmp field.
Or what did you mean?
I wanted to setup a one to many between customer and customertrans. In SQL I would join the two with the above mentioned sql join. How do I define the join criteria in the CMR delcaration. I see where I can specify customerid=id for FK, but where do I tie in the extra type column?
You need to implement relationships between two entities?
Declare CMR accessors in beans and configure relationships in ejb-jar.xml and jbosscmp-jdbc.xml.
Be more specific in questions, please.
Sorry, this kind of hard to describe. I understand how to setup relationships in ejb-jar.xml and jbosscmp-jdbc.xml. However not all underlying customertrans records in the database relate to the customer records, only those with a type of "1". In other words if I just setup a relationship between customer and customertrans jbosscmp will give me customertrans entries that have a type of "1","2","3", etc.. The only ones that "relate" to the customer are ones with type of "1". does this make sense? thanks for your help and patients.
I hope I understood you correctly. You don't want to have customertrans with type != 1 among customer CMR fields, right? Then just don't add them to customer's cmr.
Or use EJB-QL to fetch cutomertrans with type=1.
Did you mean that?
Yes, that is what I mean. I don't understand what you are saying though by don't add them to the customer's cmr? Won't the container automtically add them?
In EJB-QL, isn't that only for finders. If the container is managing the relationship, then how am I going to have control over that?
CMR fields are configured with foreign keys. But if you want to fetch some entities that have a foreign key and some specific cmp field value, then you have to write a query for it.
Does it solve your problem?
By wrtting a query, I meant implementing a finder or select method. It won't be a CMR accessor.
That makes sense. Thanks for all your help. I suppose the only other option would be to add a "hardcoded" type field to the customer EJB and have a compound foreign key, so that type would always = 1.