[Beginner Question] Entity Bean Implementation

L

Last Timer

I'm following Sam's Teach Yourself J2EE. I just can't seem to
understand the entity bean chapter. Here is how the book lays out the
entity bean:

import java.rmi.*;
import java.util.*;
import java.ejb.*;
public interface JobLocalHome extends EJBLocalHome
{

JobLocal create(String ref, String customer) throws CreateException;
....
}

public class JobBean implements EntityBean
{
...
}

public interface JobLocal extends EJFLocalObject
{
String getRef();
String getCustomer();
CustomerLocal getCustomerObj(); //derived
...
void setLocation(LocaltionLocal location);
LocationLocal getLocation();
...
}

And the authors say "note that the setLocation() method accepts a
LocationLocal reference rather than say a String containing the name of
a location. In other words, the Job bean is defining its relationship
to the Location bean directly, effectively enforcing referential
integrity"

I'm thinking LocationLocalHome a la aforementioned JobLocalHome
interface must've been left out of the book. Am I right?

public interface LocatonLocalHome extends EJBLocalHome
{

JobLocal create(String ref, String customer) throws CreateException;
....
}

Your help is appreciated.
Thank you
 
T

The Abrasive Sponge

Last said:
I'm following Sam's Teach Yourself J2EE. I just can't seem to
understand the entity bean chapter. Here is how the book lays out the
entity bean:

import java.rmi.*;
import java.util.*;
import java.ejb.*;
public interface JobLocalHome extends EJBLocalHome
{

JobLocal create(String ref, String customer) throws CreateException;
...
}

public class JobBean implements EntityBean
{
...
}

public interface JobLocal extends EJFLocalObject
{
String getRef();
String getCustomer();
CustomerLocal getCustomerObj(); //derived
...
void setLocation(LocaltionLocal location);
LocationLocal getLocation();
...
}

And the authors say "note that the setLocation() method accepts a
LocationLocal reference rather than say a String containing the name of
a location. In other words, the Job bean is defining its relationship
to the Location bean directly, effectively enforcing referential
integrity"

I'm thinking LocationLocalHome a la aforementioned JobLocalHome
interface must've been left out of the book. Am I right?

public interface LocatonLocalHome extends EJBLocalHome
{

JobLocal create(String ref, String customer) throws CreateException;
...
}

Your help is appreciated.
Thank you
No the Home interface is used to get references to beans either by
creation or finding.

Home are not beans. You use locals when dealing with the bean
implementation. In other words once you deploy the entity bean you
never deal with it directly. You either use the Local or Remote as a
Bean representative. And you use the LocalHome interface, again, to get
Local refrerences (same VM), and you use RemoteHome interface to get
Remote References (different VM);
 
L

Last Timer

My question: what is LocationLocal? It was not defined in the book. It
seems the entity bean somehow infers that LocationLocal is another
entity bean with EJBLocalHome interface implementation. Please clarify.
Thanks.
 
T

The Abrasive Sponge

Last said:
My question: what is LocationLocal? It was not defined in the book. It
seems the entity bean somehow infers that LocationLocal is another
entity bean with EJBLocalHome interface implementation. Please clarify.
Thanks.

LocationLocal is the Local(same VM) reference the Location Entity Bean.
The LocationBean probably has things like city, state, street, etc. :)

So from what you posted, one job has one customer, and one job has one
location.

To clarify LocationLocal IS ANOTHER entity bean.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top