Krish,

I agree to your observation and its the container that decides when to
insert the data. However, if only create is called in a single transaction,
after the transaction is over the container should have inserted the record
in the database. I also think vendor-specific configuration is required to
solve this problem.

Regards,
Hemant
www.pramati.com

----- Original Message -----
From: "Krishnan Subramanian" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 22, 2002 9:58 PM
Subject: Re: CMP 2.0 and database defaults


Hemant,

In EJB 2.0, I do not believe you can control when the Container will
hit the database (in this case, perform a SQL INSERT). It could be that
the Container:
(a) defers the write to the database till the end of the transaction
(b) or writes to the database in the midst of the transaction whenever
    other concurrent transactions/finders execute against this bean
    and request for data. (In which case, isolation levels determine
    the outcome)
(c) or does not defer writes to the database (sql insert) - that is,
    the Container performs an sql insert when the create() is invoked.

The correct way to solve the problem below is vendor specific. So is
this a valid observation?

<vendor>
Borland Enterprise Server allows the bean deployer to specify columns
(CMP 1.1 or 2.0 fields in entity beans) to be ignored when the
Container performs an SQL insert. As a part of the same transaction,
that column can be retrieved from the database and made available to
the bean instance without having to re-sync the entire entity bean
state (call to the ejbLoad()).
</vendor>

-krish

> If the following behaviour is correct / configurable,
>
> 1. Create the record in a single transaction. (no stores should
> happen in
> this transaction)
> 2. While calling business method on the same entity, make sure
> that the bean
> state is again loaded. (something similar to a write bean should
> work?)3. Now the cmp-field date_last_updated is loaded with the
> default value that
> db has inserted while creating the record. So subsequent stores
> would not
> set the value to null.
>
> Is this observation valid?
>
> <vendor>
> Pramati Server allows the user to specify the default value for
> selectedtypes for the database column. These values are available
> in the
> ejbPostCreate<METHOD> and subsequently.
> </vendor>
>
> Regards,
> Hemant
> www.pramati.com
>
> ----- Original Message -----
> From: "Vaidya Krishnamurthy" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, May 22, 2002 11:44 AM
> Subject: CMP 2.0 and database defaults
>
>
> Hi ,
>
>     I am trying to create a CMP 2.0 ( WLS 6.1 sp2 )  bean which
> has a
> column  managed by the database. How can I handle create/ update...
>
>     In my bean the create method looks like this...
>
>          create ( ValueObject x )
>          {
>               setattr1 ( x.getattr1() )
>               .
>               .
>               setattrn( x.getattrn() )
>
>               // setdate_last_updated is not called specifically
>    bcos
> I don't know the timestamp yet
>          }
>
>          The date_last_updated column is for further use in case of
> updates...
>
>          But I suspect that the container calls the
> setdate_last_updatedmethod with null parameter when the row is
> created... ( ofcourse after the
> database sets it )
>
>          In other words, How can I flag the container/persistence
> managerto ignore setXXX during create time.
>
> Thanks much for ur thoughts,
> Vaidya
>
>
========================================================================
===
> To unsubscribe, send email to [EMAIL PROTECTED] and include in
> the body
> of the message "signoff EJB-INTEREST".  For general help, send
> email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
>
========================================================================
===
> To unsubscribe, send email to [EMAIL PROTECTED] and include in
> the body
> of the message "signoff EJB-INTEREST".  For general help, send
> email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
>

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to