Hello
You can set the relational fields on the ejbPostCreate() method.
Say that you are inserting a State, and your state table has an
idCountry Field, you can do:
ejbCreate(Country country, String stateName) {
// setCountry(country); <- DO NOT SET IT HERE
setStateName(stateName);
}
ejbPostCreate(Country country, String stateName) {
setCountry(country); <- SET IT HERE INSTEAD
}
I hope I'm being clear. Let me know if you need a more detailed example.
- Efrén
Mark Aufdencamp escribió:
Added the <enforce-foreign-key-constraints/> to the openejb-jar.xml
Changed the Table FK Column back to a NOT NULL Constraint
Redeployed the application
Throws a SQLException (Column 'ColumnName' cannot be null) on the INSERT
SQL Statement when the EJBCreate is executed
Anyone else have an idea on how to influence the EJBCreate/EJBPostCreate
Transaction?
-------- Original Message --------
Subject: Re: EJB 2.1 CMR Question
From: "David Carew" <[EMAIL PROTECTED]>
Date: Sat, September 01, 2007 7:41 pm
To: [email protected]
Check out the EJB section in Aaron Mulder's book here.
http://www.chariotsolutions.com/geronimo/geronimo-1.1/ejb-structure.html#id2594234
There's a element in the EJB deployment plan called
<enforce-foreign-key-constraints> that may be applicable to your scenario.
On 9/1/07, Mark Aufdencamp <[EMAIL PROTECTED]> wrote:
I've done some more homework on my own regarding this one.
It appears both JBoss and WebLogic have identified this issue and resolved
it by allowing the containers Insert Transaction to be delayed until after
the EJB PostCreate method. This appears to be set in both flavors via a
container configuration command.
JBoss - <insert-after-ejb-post-create>true</insert-after-ejb-post-create>
WebLogic -
<delay-database-insert-until>ejbPostCreate</delay-database-insert-until>
How can one configure Geroimo 1.1.1 to engage in similar behavior?
-------- Original Message --------
Subject: EJB 2.1 CMR Question
From: Mark Aufdencamp <[EMAIL PROTECTED]>
Date: Fri, August 31, 2007 12:14 pm
To: [email protected]
Hi All,
I'm working on some CMR EJB's and had a more general question on EJB
architecture rather than specifically with Geronimo's implementation.
I have a pair of entity beans with a 1:M relationship. I'm attempting to
set the parent object with a CMR,
setParentEntityLocal(ParentEntityLocal parent), on the many object during
the creation of the many. I've tried to do this in the PostCreate and the
Create.
Problem is the Foreign Key Column on the Child table has a NOT NULL
constraint. How does one typically deal with this? Is it possible, or do
I need to modify the DDL on the database? Can the FK column be defined as a
CMP and set without messing up the CMR field?
I have the freedom to change the DDL, but was a bit curious how one would
deal with this if they were working in a more structured environment where
the DBA might not be so willing to change th DDL.
Thanks, as always:)
Mark Aufdencamp
[EMAIL PROTECTED]
BTW - I'm pretty close to migrating to Geronimo 2.0 (a couple of
iterations). How does this same scenario work out with JPA?
begin:vcard
fn;quoted-printable:Efr=C3=A9n Gonz=C3=A1lez
n;quoted-printable;quoted-printable:Gonz=C3=A1lez;Efr=C3=A9n
adr;quoted-printable;quoted-printable:;;;Ciudad de M=C3=A9xico;DF;11410;M=C3=A9xico
email;internet:[EMAIL PROTECTED]
x-mozilla-html:FALSE
version:2.1
end:vcard