On Monday 22 October 2001 17:54, Dain Sundstrom wrote:
> > The following issues apply to foreign-key-mapping ..
> >
> >
> > 1) problems with unidirectional relations:
> >
> > deployment does not work, because the
> > JDBCCMRFieldBridge.initRelatedData
> > does not find the related cmrField -> throws DeploymentException
>
> I just fixed a bug in this code last night, where the self-relationships
> would not initialize properly. Try the newest code.
>

If I remember correctly and if I'm not wrong here (I hadn't established that 
for sure), I had the same problem and found out that it was because JBoss 
presumably expects that ejb-relationship-role-name elements are unique across 
the whole jbosscmp-jdbc.xml file. I had two equal ejb-relationship-role-name 
elements in two different relationships and it gave me the same error. When I 
renamed one of them to be unique it worked. Of course you have to be very 
carefull to sync entries between ejb-jar.xml and jbosscmp-jdbc.xml files. If 
names between those two files don't match you can get the same error (It is 
possible that that was the case with me also). Since you brought this issue 
you can test this hypothesis and tell us what you find...

> > 2) problems with "not null" constraints on foreign keys:
> >
> > the JDBCCreateEntityCommand builds an insert statement with
> > the cmp fields
> > but without the cmr fields .. as far as I know, createEntity
> > is the only
> > affected command
>
> I don't think this is correct.  Are you trying to create an EJB that has a
> foreign key relationship to another bean that is guaranteed not be null.
> The only way I can think of to do this is to set the cmr fiend in the
> ejbCreate method, which would give the fk a value during the initial sql
> insert statement.  Unfortunately, it is not legal to set a cmr field during
> the ejbCreate method; You have to wait until ejbPostCreate. Did I
> misinterpret you?
>

As it currently is the case in JBoss (RH) You can not do anything more in 
ejbPostCreate() that you can do in ejbCreate(). ejbPostCreate() was meant to 
be used for setting up relationships. But as I pointed out in my previous 
postings (Re: [JBoss-dev] Bug in cache) you can not call business methods of 
other beans from ejbPostCreate, since at that time the context of the bean is 
not put into the cache yet and you get into trouble later...

The work around is to not put anything into ejbPostCreate() but instead use 
special business method (can be a home method) that in turn calls create() on 
home interface followed by your intended pos-create processing. Although this 
is portable, JBoss will have to address this issue and allow arbitrary 
processing in ejbPostCreate() method to be EJB 2.0 compliant...

Peter

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to