Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Modelling an object as Session Bean or Entity Bean ?

Reply
Thread Tools

Modelling an object as Session Bean or Entity Bean ?

 
 
Francesco
Guest
Posts: n/a
 
      12-07-2006
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

 
Reply With Quote
 
 
 
 
wesley.hall@gmail.com
Guest
Posts: n/a
 
      12-07-2006

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.

 
Reply With Quote
 
 
 
 
Danno
Guest
Posts: n/a
 
      12-07-2006

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).

 
Reply With Quote
 
wesley.hall@gmail.com
Guest
Posts: n/a
 
      12-07-2006

> 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".

 
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
Saving request scope bean reference to session scone bean gallas.robert@gmail.com Java 1 03-19-2008 01:09 PM
[ejb][jboss]Bean inside a serialized object in another bean carlg@libertybasic.com Java 1 09-13-2006 08:10 PM
EJB Transaction (Session Bean - Entitiy Bean) X3 Java 0 10-01-2004 07:41 AM
can a session bean return a local entity bean object? David Thielen Java 2 09-12-2003 07:45 AM



Advertisments