Entity Beans are uniquely idnetified by its primary key. And it is very often we
notice that we use domain objects or tables (with other objects and non-objects)
existing with out primary keys. So it is must and should that an EntityBean have a
primary key class (but it doesn't imply that this should be the primary key of the
table)
There are two ways(may be there are more..but these are the ones I used for my thesis)
to deal with it.
1 Make a compound primary key class using the fields of the table.
Example if TABLE Enrollment contains the columns for student ids (this can also be
simple reference in EJB) and the course number( this is also is a reference in EJB)
Make a Compound Primary Key class EnrollmentPK
class EnrollmentPK implements Serializable{
Student student;
Course course;
hashCode...
equals..
}
2. Use a unique key generator that increments the PrimaryKey for the table. And use
this in your PrimaryKey class.
It should be noted here that the create method of the EntityBean can be without any
arguments and sometimes it is possible not to have a create method .. like when the
entity beans reference(as collections) are just being returned using finder methods.
Hope that helps ....
Sesh
On Mon, 27 Mar 2000 10:43:14 -0500, Amaresh Rajasekharan <[EMAIL PROTECTED]> wrote:
>Hello All,
> I have a question on Entity Beans and table mapping. If there is a
>table with no primary key (none of the columns are unique and non null),
>how can one write an entity bean that maps to that table? Basically,
>I am not sure about writing an entity bean with no key fields. Is that
>possible? In which case what about the PrimaryKey class?
>Would be grateful for any suggestions.
>Thanks and Regards
>Amaresh
>
> ==========================================================================
>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".