Results 1 to 3 of 3

Thread: How many relationships can create in EJB?

  1. #1
    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

  2. #2
    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.

  3. #3
    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.



Similar Threads

  1. Replies: 2
    Last Post: 13-12-2011, 11:32 PM
  2. Sim's relationships keep resetting in Sims 3: Generations
    By lEON bALDWIN in forum Video Games
    Replies: 5
    Last Post: 22-06-2011, 08:21 PM
  3. Relationships in The Elder scrolls
    By Hardiyy in forum Video Games
    Replies: 5
    Last Post: 06-06-2011, 11:02 PM
  4. Relationships in java
    By Jagadamba in forum Software Development
    Replies: 3
    Last Post: 18-11-2009, 11:02 AM
  5. Database relationships problem
    By Barny in forum Software Development
    Replies: 4
    Last Post: 05-01-2009, 09:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,699,917.77877 seconds with 17 queries