Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How many relationships can create in EJB?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 30-03-2009
Member
 
Join Date: Feb 2009
Posts: 69
How many relationships can create in EJB?
  

Hello,

Can anyone suggest me in how many ways can we create an relationships in EJB, I am little bit aware about some of them but want to know more about it, this may help me to create some relationships in my project work.

Any suggestions would be appreciated.

Thanks

Reply With Quote
  #2  
Old 30-03-2009
Member
 
Join Date: Dec 2008
Posts: 202
Re: How many relationships can create in EJB?

There are three main types of relationship:
  • one-to-one
  • one-to-many
  • and many-to-many

In a one-to-one (1:1) relationship, a CMP entity bean is associated with a single instance of another CMP entity bean. For example, an Employee bean could be associated with only a single instance of an EmployeeID bean, because an employee can have only one employee identifier on file.

In a one-to-many (1:M) relationship, a CMP entity bean is associated with multiple instances of another CMP entity bean. For example, a Department bean could be associated with multiple instances of an Employee bean, because most departments are made up of more than one employee.

In a many-to-many (M:M) relationship, multiple instances of a CMP entity bean are associated with multiple instances of another CMP entity bean. For example, multiple instances of a Customer bean could be associated with multiple instances of a Restaurant bean, because restaurants serve many customers, and customers patronize many different restaurants. For EJB 1.1 CMP entity beans, a many-to-many relationship requires the use of a link bean. This link bean is placed in the middle of the two enterprise beans by creating a 1:M relationship from each bean to the link bean. For EJB 2.0 CMP beans, the creation of the link bean is not required because the creation of the link table is handled automatically during the execution of a top-down mapping.
Reply With Quote
  #3  
Old 30-03-2009
Member
 
Join Date: Mar 2008
Posts: 258
Re: How many relationships can create in EJB?

In EJB's ManyToMany Relationships Following Entities are coded:
  • Home
  • Person
  • Role
  • UserRole

Home Entity

Home has a many to many relationship with Person. A person can have zero or more homes, and a home can have zero or more persons.

Person Entity

Person has a one to many relationship with UserRole. A person can have zero or more UserRoles's. A user role has one person associated with it.

UserRole Entity

UserRole has a many to one relationship with Role. A Role can have zero or more UserRole's, but a UserRole has only one Role.


Entity Relationships

In essence the Home - Person is a many to many relationship, where the link table is left to the EJB container to work out. The Person - Role relationship, is also a many to many relationship, but in this case, the link table is implemented manually, and the relationships are broken down using one to many and many to one relationships.

Below is the diagram of the resulting database tables.


Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How many relationships can create in EJB?"
Thread Thread Starter Forum Replies Last Post
How to add Birthdays and Relationships for Contacts in Android ICS Ramanujan Portable Devices 2 13-12-2011 10:32 PM
Sim's relationships keep resetting in Sims 3: Generations lEON bALDWIN Video Games 5 22-06-2011 08:21 PM
Relationships in The Elder scrolls Hardiyy Video Games 5 06-06-2011 11:02 PM
Relationships in java Jagadamba Software Development 3 18-11-2009 10:02 AM
Database relationships problem Barny Software Development 4 05-01-2009 08:05 AM


All times are GMT +5.5. The time now is 03:33 AM.