Modelling an object as Session Bean or Entity Bean ?

Discussion in 'Java' started by Francesco, Dec 7, 2006.

  1. Francesco

    Francesco Guest

    Hi all !
    I'm modelling an application for selling tickets on-line.
    Tickets are booked on-line then the user navigates to the payment page
    and pays with credit card.

    The business analyst decided to allow a 30 minutes reservation time for
    people who booked the ticket to pay with credit card.

    If time elapses the seat "lock" is released.

    I think there should be an EJB responsible to keep up with Seat
    reservations.

    My dilemma is : should I model it as Session Bean or Entity Bean ?
    I initially modelled it as Session Bean with plain (Insert/Update) of
    the Seats Table when the ticket is booked / paid / time elapsed

    On the other hand I think, if there's multi-user access of the PK
    (SeatId),
    an Entity Bean should be used.

    What do you say to it ? Session Bean or Entity Bean ?
    Thanks in advance
    Francesco
     
    Francesco, Dec 7, 2006
    #1
    1. Advertising

  2. Francesco

    Guest

    Francesco wrote:
    > Hi all !
    > I'm modelling an application for selling tickets on-line.
    > Tickets are booked on-line then the user navigates to the payment page
    > and pays with credit card.
    >
    > The business analyst decided to allow a 30 minutes reservation time for
    > people who booked the ticket to pay with credit card.
    >
    > If time elapses the seat "lock" is released.
    >
    > I think there should be an EJB responsible to keep up with Seat
    > reservations.
    >
    > My dilemma is : should I model it as Session Bean or Entity Bean ?
    > I initially modelled it as Session Bean with plain (Insert/Update) of
    > the Seats Table when the ticket is booked / paid / time elapsed
    >
    > On the other hand I think, if there's multi-user access of the PK
    > (SeatId),
    > an Entity Bean should be used.
    >
    > What do you say to it ? Session Bean or Entity Bean ?
    > Thanks in advance
    > Francesco


    It should be an entity bean.
     
    , Dec 7, 2006
    #2
    1. Advertising

  3. Francesco

    Danno Guest

    Francesco wrote:
    > Hi all !
    > I'm modelling an application for selling tickets on-line.
    > Tickets are booked on-line then the user navigates to the payment page
    > and pays with credit card.
    >
    > The business analyst decided to allow a 30 minutes reservation time for
    > people who booked the ticket to pay with credit card.
    >
    > If time elapses the seat "lock" is released.
    >
    > I think there should be an EJB responsible to keep up with Seat
    > reservations.
    >
    > My dilemma is : should I model it as Session Bean or Entity Bean ?
    > I initially modelled it as Session Bean with plain (Insert/Update) of
    > the Seats Table when the ticket is booked / paid / time elapsed
    >
    > On the other hand I think, if there's multi-user access of the PK
    > (SeatId),
    > an Entity Bean should be used.
    >
    > What do you say to it ? Session Bean or Entity Bean ?
    > Thanks in advance
    > Francesco


    Wesley is correct, the ticket should be an entity bean. I just want to
    also mention that session beans are verbs (reserveTicket, buyTicket,
    surrenderTicket, isAvailable) and entity beans are nouns (customer,
    ticket, creditCard, address).
     
    Danno, Dec 7, 2006
    #3
  4. Francesco

    Guest


    > Wesley is correct, the ticket should be an entity bean. I just want to
    > also mention that session beans are verbs (reserveTicket, buyTicket,
    > surrenderTicket, isAvailable) and entity beans are nouns (customer,
    > ticket, creditCard, address).


    Danno,

    I feel really bad disagreeing with you after you so nicely called me
    'correct' but disagree I must :)

    While I see where you are coming from, it can be dangerous to think in
    this way. Firstly, every item in your list of 'session beans' would not
    be a bean in it's own right, just a method on a bean.

    Your examples of entitities are OK, but it is not correct to say
    'entity beans are nouns'. What about ShoppingCart? This is a noun, but
    I certainly wouldn't fault anyone for implementing it at a stateful
    session bean (infact, I would have a few questions if they used an
    entity).

    If you want a general rule to follow, then yes generally nouns are
    usually modelled as entities (but certainly not all nouns).

    A general rule for session beans is much harder to pin down, they might
    also be nouns (ShoppingCart) or roles (BookingAgent), or just a generic
    collection of related functions (LogHandler).

    The only real rule you can follow is... "Session beans hold no state or
    state private to the user (stateless/stateful) and do not support
    concurrency. Entity beans hold shared state and are fully concurrent".
     
    , Dec 7, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Thielen
    Replies:
    2
    Views:
    835
    Marek Lange
    Sep 12, 2003
  2. X3
    Replies:
    0
    Views:
    433
  3. Samuel van Laere

    Entity Name or Entity Number?

    Samuel van Laere, Feb 24, 2007, in forum: HTML
    Replies:
    4
    Views:
    1,743
    Jukka K. Korpela
    Feb 24, 2007
  4. Replies:
    1
    Views:
    730
  5. markla
    Replies:
    1
    Views:
    581
    Steven Cheng
    Oct 6, 2008
Loading...

Share This Page