-
1. Re: Referential Integrity question
mkuusela Feb 2, 2002 6:42 AM (in response to dciarnie)Hi!
You didn't specify which version of JBoss you are using. In 3.0.0alpha there's a file called jbosscmp-jdbc.xml and in 2.4.X a file called jaws.xml. With one of these files, it's possible to configure your datasource to enforce referential integrity. Just create one of these files depending of your JBoss version and put it in your ejb-jar -file in META-INF -directory.
You find instructions how to create these files in the DTD:s. There's good comments in those files.
Hope this helps,
Mika -
2. Re: Referential Integrity question
ahjulsta Feb 2, 2002 6:58 AM (in response to dciarnie)You could always to something like
playerhome.create(properties, team)
and then in your entitybean have
public PlayerPK ejbCreate(Properties p, Team t) {
setProperties(p);
return null;
}
public void ejbPostCreate(Properties p, Team t) {
setTeam(t);
}
The crucial point being to set the relation in the ejbPostCreate... I do this all the time.
The other alternative, of course, is to have a createPlayer method on the Team entity bean. I chose not to do this, because this means mixing create and business methods in the local/remote interface.
Åsmund Hjulstad -
3. Re: Referential Integrity question
dciarnie Feb 3, 2002 4:45 PM (in response to dciarnie)I am using jboss 3.0 alpha so I've set up the relationships in jbosscmp-jdbc.xml. I did not realize that DTDs were even available since none of the JBoss deployment XML files that I have ever seen have a DOCTYPE element. However, I've now done some poking around and discovered that the DTDs are at http://www.jboss.org/j2ee/dtd.
It seems that I was interpreting something in the spec a little too literally. The spec states that you can set CMR fields in ejbPostCreate so I, naively, tried do so something like setTeamID(teamid) which, of course, does not work while Åsmund's does.
It is still slightly unsatisfying to me that the way the spec is written, one cannot make foreign keys NOT NULL since the insertion of the data and the setting of the foreign key are done in separate steps. However, my dissatisfaction is probably due more to my own prejudices than anything else.
Thanks,
Dan.