Laird,
With the Inprise Application Server you can have the following hypo
situation:
Order Entity Bean has many Order Item Entity Bean. Now what is declared in
the Order Item Bean is
public Order order; // this is a cmp field
Now with the Inprise Applcation Server this reference will be set before the
ejbLoad and when been made persistent (after ejbStore) the cmp will set the
column field value to that of the primary key value of the Order. What this
means is alot less code especially with regard to home lookups and finds.
How this is done is through the inprise specific deployment descriptor. I
attache a sample descriptor which I think everbody will find very
interesting. enjoy.
<entity>
<ejb-name>offer</ejb-name>
<bean-home-name>core/offer</bean-home-name>
<resource-ref>
<res-ref-name>jdbc/datasource</res-ref-name>
<jndi-name>jdbc/acorn</jndi-name>
<cmp-resource>True</cmp-resource>
</resource-ref>
<cmp-info>
<database-map>
<table>offer</table>
<column-map>
<field-name>oid</field-name>
<column-name>object_id</column-name>
</column-map>
<column-map>
<field-name>company</field-name>
<column-name>company_id</column-name>
<ejb-ref-name>ejb/company</ejb-ref-name>
</column-map>
<column-map>
<field-name>startDate</field-name>
<column-name>start_date</column-name>
</column-map>
<column-map>
<field-name>endDate</field-name>
<column-name>end_date</column-name>
</column-map>
<column-map>
<field-name>receivedDate</field-name>
<column-name>received_date</column-name>
</column-map>
<column-map>
<field-name>idCurrencyType</field-name>
<column-name>currency_type_id</column-name>
</column-map>
<column-map>
<field-name>fileName</field-name>
<column-name>file_name</column-name>
</column-map>
<column-map>
<field-name>version</field-name>
<column-name>version_number</column-name>
</column-map>
</database-map>
<finder>
<method-signature>findAll()</method-signature>
<where-clause/>
</finder>
<finder>
<method-signature>findByCompany(com.aucs.core.server.beans.entity.Company
c)</method-signature>
<where-clause>(company_id = :c[ejb/company]) order
by start_date desc</where-clause>
</finder>
<finder>
<method-signature>findByDate(java.util.Date
date)</method-signature>
<where-clause>( :date >= start_date) and (end_date
>= :date)</where-clause>
</finder>
<finder>
<method-signature>findByDateAndCompany(java.util.Date date,
com.aucs.core.server.beans.entity.Company c)</method-signature>
<where-clause> ( :date >= start_date) and (end_date
>= :date) and (company_id = :c[ejb/company])</where-clause>
</finder>
<finder>
<method-signature>findByFileName(String
filename)</method-signature>
<where-clause>(file_name = :filename)</where-clause>
</finder>
</cmp-info>
<property>
<prop-name>ejb.transactionCommitMode</prop-name>
<prop-type>String</prop-type>
<prop-value>Exclusive</prop-value>
</property>
</entity>
<entity>
<ejb-name>offeritem</ejb-name>
<bean-home-name>core/offeritem</bean-home-name>
<resource-ref>
<res-ref-name>jdbc/datasource</res-ref-name>
<jndi-name>jdbc/acorn</jndi-name>
<cmp-resource>True</cmp-resource>
</resource-ref>
<cmp-info>
<database-map>
<table>offer_item</table>
<column-map>
<field-name>oid</field-name>
<column-name>object_id</column-name>
</column-map>
<column-map>
<field-name>offer</field-name>
<column-name>offer_id</column-name>
<ejb-ref-name>ejb/offer</ejb-ref-name>
</column-map>
<column-map>
<field-name>idCountry</field-name>
<column-name>country_id</column-name>
</column-map>
<column-map>
<field-name>rate</field-name>
<column-name>rate_per_min</column-name>
</column-map>
<column-map>
<field-name>version</field-name>
<column-name>version_number</column-name>
</column-map>
</database-map>
<finder>
<method-signature>findAll()</method-signature>
<where-clause/>
</finder>
<finder>
<method-signature>findByOffer(com.aucs.core.server.beans.entity.traffic.Offe
r o)</method-signature>
<where-clause>(offer_id =
:o[ejb/offer])</where-clause>
</finder>
<finder>
<method-signature>findByOfferAndCountry(com.aucs.core.server.beans.entity.tr
affic.Offer o, int cid)</method-signature>
<where-clause>(country_id = :cid) and (offer_id =
:o[ejb/offer])</where-clause>
</finder>
</cmp-info>
<property>
<prop-name>ejb.transactionCommitMode</prop-name>
<prop-type>String</prop-type>
<prop-value>Exclusive</prop-value>
</property>
</entity>
Also notice how nice the find method are compared to web logic. I do not
know what the WL were thinking about when they came up with the limited
solution
> -----Original Message-----
> From: Laird Nelson [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, February 22, 2000 9:35 PM
> To: [EMAIL PROTECTED]
> Subject: Entities and relationships
>
> The specification states:
>
> "The current EJB architecture does not specify how one Entity bean
> should store an object reference of another Entity bean. The desirable
> strategy is application-dependent. The enterprise bean...can use any of
> the following strategies for maintaining persistently a relationship
> between entities (the list is not inclusive of all possible strategies):
> * Object's primary key. This is applicable if the target object's Home
> is known and fixed.
> * Home name and object's primary key.
> * Home object reference and object's primary key.
> * Object's handle."
>
> I have an entity bean, whose bean class is named OrgUnitBean and whose
> remote interface is named OrgUnit, that must notionally have an
> Organization passed to it when it is created. Organization is, however,
> another entity bean (its remote interface is named Organization and its
> bean class is named OrganizationBean). What should my ejbCreate()
> method in OrgUnitBean look like, and what should the member variables in
> OrgUnitBean look like?
>
> Can I have an ejbCreate method like this:
>
> public String ejbCreate(Organization owner, String name) {
> this.org = owner;
> this.name = name;
> return name;
> }
>
> ...and can OrgUnitBean keep a reference to Organization in it like this:
>
> private Organization org = null; // assigned by ejbCreate; see above
>
> ...?
>
> Cheers,
> Laird
>
> ==========================================================================
> =
> 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".
***********************************************************************
Bear Stearns is not responsible for any recommendation, solicitation,
offer or agreement or any information about any transaction, customer
account or account activity contained in this communication.
***********************************************************************
===========================================================================
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".