Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Relationship fields in entity beans

Reply
Thread Tools

Relationship fields in entity beans

 
 
Taras_96
Guest
Posts: n/a
 
      04-29-2008
Hi all

I'm reading Enterprise JavaBeans, 4th Edition. To explain relationship
fields, they use the example of a CustomerBean having a 1-1
relationship with an AddressBean.

In Chapter 6.5, the book states that:

"The Address EJB is a fine-grained business object that should always
be accessed in the context of another entity bean, which means it
should have only local interfaces and not remote interfaces"

What does the author mean by fine grained?

The CustomerBean defines:

public abstract AddressLocal getHomeAddress( );

public abstract void setHomeAddress(AddressLocal address);

Later the book states that:

" The remote interface of a bean is not allowed to expose its
relationship fields. In the case of the homeAddress field, we have
declared the type to be AddressLocal, which is a local interface, so
the setHomeAddress( )/getHomeAddress( ) accessors cannot be declared
in the remote interface of the Customer EJB"

Now, is it not allowed to expose the relationship fields because
that's the way it was defined (the accessor methods take and return
AddressLocal interfaces), or because it is a requirement that *no*
remote interfaces expose relationship fields?

Thanks

Taras

 
Reply With Quote
 
 
 
 
Arved Sandstrom
Guest
Posts: n/a
 
      04-30-2008
"Taras_96" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi all
>
> I'm reading Enterprise JavaBeans, 4th Edition. To explain relationship
> fields, they use the example of a CustomerBean having a 1-1
> relationship with an AddressBean.
>
> In Chapter 6.5, the book states that:
>
> "The Address EJB is a fine-grained business object that should always
> be accessed in the context of another entity bean, which means it
> should have only local interfaces and not remote interfaces"
>
> What does the author mean by fine grained?


Fine-grained is a relative term. Think of fine-grained and coarse-grained as
meaning lightweight and heavyweight, in terms of functionality. At one end
of the spectrum, an Address object having fields for street number, street
name, municipality, state/province and zip/postal code, with accessor
methods, is a typical fine-grained object. Near the other end might be a
Customer object, with a need to define personal information, contact info
(including addresses), account information (many possible accounts),
purchasing preferences etc etc etc, with many methods. Customer is a typical
coarse-grained object.

The other feature of many fine-grained/lightweight objects is that often
they have little or no logical identity. That is, they are dependent on
other objects to define a context in which they make sense. An address just
by itself isn't exactly telling you very much...an address linked to a
customer is much more meaningful.

Note that in EJB 3.0 fine-grained objects would typically be entities, not
EJBs.

> The CustomerBean defines:
>
> public abstract AddressLocal getHomeAddress( );
>
> public abstract void setHomeAddress(AddressLocal address);
>
> Later the book states that:
>
> " The remote interface of a bean is not allowed to expose its
> relationship fields. In the case of the homeAddress field, we have
> declared the type to be AddressLocal, which is a local interface, so
> the setHomeAddress( )/getHomeAddress( ) accessors cannot be declared
> in the remote interface of the Customer EJB"
>
> Now, is it not allowed to expose the relationship fields because
> that's the way it was defined (the accessor methods take and return
> AddressLocal interfaces), or because it is a requirement that *no*
> remote interfaces expose relationship fields?


The latter.

AHS


 
Reply With Quote
 
 
 
 
Taras_96
Guest
Posts: n/a
 
      05-04-2008
On Apr 30, 1:56 pm, "Arved Sandstrom" <(E-Mail Removed)>
wrote:
> "Taras_96" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
> Fine-grained is a relative term. Think of fine-grained and coarse-grained as
> meaning lightweight and heavyweight, in terms of functionality. At one end
> of the spectrum, an Address object having fields for street number, street
> name, municipality, state/province and zip/postal code, with accessor
> methods, is a typical fine-grained object. Near the other end might be a
> Customer object, with a need to define personal information, contact info
> (including addresses), account information (many possible accounts),
> purchasing preferences etc etc etc, with many methods. Customer is a typical
> coarse-grained object.
>
> The other feature of many fine-grained/lightweight objects is that often
> they have little or no logical identity. That is, they are dependent on
> other objects to define a context in which they make sense. An address just
> by itself isn't exactly telling you very much...an address linked to a
> customer is much more meaningful.


Thanks, this is an excellent explanation.
>


>
> > Later the book states that:

>
> > " The remote interface of a bean is not allowed to expose its
> > relationship fields. In the case of the homeAddress field, we have
> > declared the type to be AddressLocal, which is a local interface, so
> > the setHomeAddress( )/getHomeAddress( ) accessors cannot be declared
> > in the remote interface of the Customer EJB"

>
> > Now, is it not allowed to expose the relationship fields because
> > that's the way it was defined (the accessor methods take and return
> > AddressLocal interfaces), or because it is a requirement that *no*
> > remote interfaces expose relationship fields?

>
> The latter.


Is there a reason for this? A possible reason that comes to mind is
that the resulting action that needs to be taken if relationship
fields are changed becomes too complicated/slow.

Taras
 
Reply With Quote
 
Taras_96
Guest
Posts: n/a
 
      05-04-2008
On Apr 30, 1:56 pm, "Arved Sandstrom" <(E-Mail Removed)>
wrote:
> "Taras_96" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
> Fine-grained is a relative term. Think of fine-grained and coarse-grained as
> meaning lightweight and heavyweight, in terms of functionality. At one end
> of the spectrum, an Address object having fields for street number, street
> name, municipality, state/province and zip/postal code, with accessor
> methods, is a typical fine-grained object. Near the other end might be a
> Customer object, with a need to define personal information, contact info
> (including addresses), account information (many possible accounts),
> purchasing preferences etc etc etc, with many methods. Customer is a typical
> coarse-grained object.
>
> The other feature of many fine-grained/lightweight objects is that often
> they have little or no logical identity. That is, they are dependent on
> other objects to define a context in which they make sense. An address just
> by itself isn't exactly telling you very much...an address linked to a
> customer is much more meaningful.


Thanks, this is an excellent explanation.
>


>
> > Later the book states that:

>
> > " The remote interface of a bean is not allowed to expose its
> > relationship fields. In the case of the homeAddress field, we have
> > declared the type to be AddressLocal, which is a local interface, so
> > the setHomeAddress( )/getHomeAddress( ) accessors cannot be declared
> > in the remote interface of the Customer EJB"

>
> > Now, is it not allowed to expose the relationship fields because
> > that's the way it was defined (the accessor methods take and return
> > AddressLocal interfaces), or because it is a requirement that *no*
> > remote interfaces expose relationship fields?

>
> The latter.


Is there a reason for this? A possible reason that comes to mind is
that the resulting action that needs to be taken if relationship
fields are changed becomes too complicated/slow.

Taras
 
Reply With Quote
 
Taras_96
Guest
Posts: n/a
 
      05-04-2008
On Apr 30, 1:56 pm, "Arved Sandstrom" <(E-Mail Removed)>
wrote:
> "Taras_96" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
> Fine-grained is a relative term. Think of fine-grained and coarse-grained as
> meaning lightweight and heavyweight, in terms of functionality. At one end
> of the spectrum, an Address object having fields for street number, street
> name, municipality, state/province and zip/postal code, with accessor
> methods, is a typical fine-grained object. Near the other end might be a
> Customer object, with a need to define personal information, contact info
> (including addresses), account information (many possible accounts),
> purchasing preferences etc etc etc, with many methods. Customer is a typical
> coarse-grained object.
>
> The other feature of many fine-grained/lightweight objects is that often
> they have little or no logical identity. That is, they are dependent on
> other objects to define a context in which they make sense. An address just
> by itself isn't exactly telling you very much...an address linked to a
> customer is much more meaningful.


Thanks, this is an excellent explanation.
>


>
> > Later the book states that:

>
> > " The remote interface of a bean is not allowed to expose its
> > relationship fields. In the case of the homeAddress field, we have
> > declared the type to be AddressLocal, which is a local interface, so
> > the setHomeAddress( )/getHomeAddress( ) accessors cannot be declared
> > in the remote interface of the Customer EJB"

>
> > Now, is it not allowed to expose the relationship fields because
> > that's the way it was defined (the accessor methods take and return
> > AddressLocal interfaces), or because it is a requirement that *no*
> > remote interfaces expose relationship fields?

>
> The latter.


Is there a reason for this? A possible reason that comes to mind is
that the resulting action that needs to be taken if relationship
fields are changed becomes too complicated/slow.

Taras
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to relate a SQL based entity with an Object based entity in Entity Framework markla ASP .Net 1 10-06-2008 09:42 AM
handy access to attributes of entity beans from session beans Torsten Schmeissel Java 0 04-29-2005 05:19 PM
Entity beans Tim Java 4 01-26-2004 01:19 PM
Design Question: Session vs. Entity Beans MP Java 2 11-11-2003 07:09 PM
The difference between Session and Entity Beans? <see body> Kabal Java 0 07-22-2003 07:35 PM



Advertisments