The reason you're not seeing the exception is that ejbStore isn't called
(store isn't processed for entities) until the transaction commits,
which isn't until after the session bean method returns (Unless you put
the 'setData' method in a RequiresNew transaction, which I wouldn't do).
If it is invariant that field2 not be null, assert this (throw
IllegalArgumentException) in 'setData', so that you can catch that
exception in the bean. If field2 can be null according to your
requirements and domain model, then your database is simply wrong, this
is a bug that you should fix and get on with your life.
Jean-Michel DELSAUX wrote:
>
> Hi all,
>
> How can i catch a container exception generated by the container?
>
> I have an existing row in a database with [ID not null, FIELD1 not null,
> FIELD2 not null].
>
> When I perform an update, I do it by using an object with these 3 fields.
>
> So in my session bean, I have:
>
> Public void update() {
> try {
> myClass theClass = m_home.findByPrimaryKey(new PK(ID));//Use of an
> entity EJB
> theClass.setData(ID, �field1�, �field2�);
> } catch(Exception e) {
> }
> }
>
> in that case, when the ejbStore in the entity bean is performed, the update
> is done.
>
> But if a have field2 = null so
>
> Public void update() {
> try {
> myClass theClass = m_home.findByPrimaryKey(new PK(ID));//Use of an
> entity EJB
> theClass.setData(ID, �field1�, null);
> } catch(Exception e) {
> //generate an xml file containing the error message
> }
> }
> Then, an Oracle exception is generated of the kind:
> ORA-01407:cannot update ("SCHEMA"."TABLE"."FIELD2") to NULL
>
> It is ok up to now. The problem is that I want to catch the exception to
> return information to the client. For that, I have to catch the exception.
> If in the entity bean a throw explicitly an EJBException, I can catch it.
> But if it is the container that generates that error, I am unable to catch
> it. So, what can I do????
>
> Please help
>
> JMi
>
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
--
Dan Christopherson (danch)
nVisia Technical Architect (www.nvisia.com)
Opinions expressed are mine and do not neccessarily reflect any
position or opinion of nVISIA.
---------------------------------------------------------------------------
If you're a capitalist and you have the best goods and they're
free, you don't have to proselytize, you just have to wait.
-Eben Moglen
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]