Dmitri,

Dependent value classes are very much a part of the EJB 2.0 spec
(final release - section 10.3.3).

The spec itself mentions that the dependent value class should be
Serializable. But this does _not_ imply that your dependent value
class would be written to the database as a byte[] (or a clob/blob
at the database level).

The way this is provided/mapped would probably differ from one
vendor to another, but I'll provide an example to show you how
it could work:

I have a table "Person" with columns:
perId (Long) as the PK
perFirstName (varchar)
perLastName (varchar)
perStreet1 (varchar)
perStreet2 (varchar)
perCity (varchar)
perZipCode (varchar)
perState (varchar)
perCountry (varchar)

Now, your entity bean could have abstract getters and setter for each
of the above columns as per the EJB 2.0 spec. But with dependent value
classes, I could create an "Address" Java (Dependent Value) class that
looks like:

public class Address implements java.io.Serializable {
  private String perStreet1;
  private String perStreet2;
  private String perCity
  private String perZipCode;
  private String perState;
  private String perCountry;
  /* getters & setters for above - aka a JavaBean not shown */
}

And your abstract entity bean class would just have a getAddress()
and setAddress() defined in addition to abstract getters and setters
for the PK, first name and last name.

Now, your DD could just specify the mapping Address.perStreet1 -->
Person.perStreet1 etc.

At least that's the idea ...

-krish

-----Original Message-----
From: A mailing list for Enterprise JavaBeans development 
[mailto:[EMAIL PROTECTED]]On Behalf Of Dmitri Colebatch
Sent: Wednesday, February 13, 2002 9:44 PM
To: [EMAIL PROTECTED]
Subject: Re: Dependent value classes


DVC were in the PFD1 of the EJB2.0 spec, but dropped for the PFD2 and final releases.

serialization is not cheap, and I suppose you'd be well advised to avoid it if 
possible, but then again - writing to a database wont
be cheap fullstop, so it might be worth doing some perf testing.  The real issue 
though, is that you cant just get your sql client
andread your data.

cheers
dim
----- Original Message -----
From: Sunder
To: [EMAIL PROTECTED]
Sent: Thursday, February 14, 2002 5:51 AM
Subject: Dependent value classes


 Dependent value classes were introduced in the EJB 2.0 spec. I would like to know if 
it�s a good idea to use serialized java
Beans mapped to the database columns. That way, one does not need to change the EJB 
for database changes. All database
Changes can be reflected in the java bean. Of course, the primary key will not be a 
part of this bean. Are there any drawbacks in
doing this??

Sunder

===========================================================================
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