geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Aufdencamp <m...@aufdencamp.com>
Subject :) EJB 2.1 CMP/CMR
Date Fri, 21 Sep 2007 16:27:28 GMT
Hi All,

I wanted to thank everyone who has helped me over the last several
months while I engaged in learning the finer points of CMP and CMR on
Geronimo 1.1.1.  I also promised to follow up with some of the knowledge
gained while engaged in this process.

I was able to successfully maintain my NOT NULL Constraints on my
Foreign Key Columns in my database. (See previous posts on EJB 2.1
CMP/CMR), with a few caveats.

1. I added <enforce-foreign-key-constraints> and appropriate transaction
definition for the EJB's.  This did not resolve my problem with setting
the Relationships and having an Exception thrown as a result of the NOT
NULL constraints.


2.  I was attempting to set relationships in the EJBPostCreate(). 
Initially, I was passing primary key strings and attempting to do a
EJBFindByPrimaryKey with a setCMRField() in the EJBPostCreate().  This
resulted in container generated exceptions from the TranQL Engine.  I
refactored this to pass the actually entity to the EJBPosttCreate() and
was able to successfuly set the relationship on the NOT NULL field in
the same INSERT transaction as the EJBCreate().  I'm guessing the
FindByPrimaryKey() busted the transactional integrity in the
EJBCreate/EJBPostCreate sequence.

Some what fragile:)  Could someone advise me as to the legality of my
initial approach within the container contract constraints?


3. The NOT NULL Foreign Key Constraint busts the Relationships
<Cascade-Delete> functionality.  The <Cascade-Delete> attempts to invoke
an UPDATE SET = null on the column and the database appropriately throws
an exception.


4.  I implemented cascading deletion in my Session Bean Code to properly
remove child entities.  Utilizing the CMR field to iterate through the
collection of entities to remove().


5.  Remove the related entity from the relationship immediately prior to
the EJB.remove() invocation and it works.  Don't remove the relationship
and attempt to remove the entity and an exception will be thrown.  This
makes since, but it did have me reaching for the EJB 3.0 book and
thinking more about Geronimo 2


I'm hitting a Sun seminar here in Columbus on Wednesday and will be
getting my first exposure to actual EJB 3 development.  I'm looking
forward to working with it on Geronimo 2.

I hope this info will be of use to others.  Once again thanks to all for
the patience and assistance.

Mark Aufdencamp
Mark@Aufdencamp.com



Mime
View raw message