-
1. Re: setting up relationships without specifying foreign key?
dsundstrom Jun 27, 2002 5:27 PM (in response to gzhong)I'm sorry, I can't follow your post. Can you try rewriting it? What exactally are you trying to do that doesn't work?
-
2. Re: setting up relationships without specifying foreign key?
gzhong Jun 27, 2002 11:34 PM (in response to gzhong)OK, let me simplify the problem.
I have a User bean and a Group bean. For each Group bean object there are N User bean objects. In the table user, there is a group_id foreign key (a column) that links to the id column of the group table. In the User bean, I declare get/set for Group (and not GroupId). But this is not a column but a relationship. I declare this relationship in the ejb-jar.xml. In spite of this, when I try to create a User bean object, I get a sql exception. I checked the log and found out that the insert statement is attempting to insert some info into a column called "group"; I don't have a <cmp-field> called "group", so I believe that jboss is misled into believing that my get/setGroup implies existence of a group column. There is no group column (because there is no group field), there's a group_id column.
So how do I have a User bean declare a relationship with Group class, but I don't have a "group" column in the user table; I have a group_id column that would help the User bean retrieve info about a Group.
So it's hard for me to explain in a message that doesn't bore people to death. Is there an example somewhere for JBoss3.0 using CMP2.x indicating how to create relationships based on foreign keys? I don't want to get the docs yet until I know they are for JBoss3.0. I looked for examples on the Net but they don't meet my specific needs.
Thanks -
3. Re: setting up relationships without specifying foreign key?
dsundstrom Jun 30, 2002 1:59 PM (in response to gzhong)JBossCMP will automatically geneate a database mapping in order to store the entity in the database. If you want a specific mapping, which is what you are asking for, then you must specify it with a jbosscmp-jdbcm.xml file. The structure of this file is detailed in the for pay JBossCMP documentation and in the jbosscmp-jdbc_3_0.dtd file in the docs/dtd directory of the jboss distribution.
If you get the JBoss test suite from cvs you can find some working files.