Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Modelling an object as Session Bean or Entity Bean ? (http://www.velocityreviews.com/forums/t389254-modelling-an-object-as-session-bean-or-entity-bean.html)

Francesco 12-07-2006 08:35 AM

Modelling an object as Session Bean or Entity Bean ?
 
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.hall@gmail.com 12-07-2006 10:59 AM

Re: Modelling an object as Session Bean or Entity Bean ?
 

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.


Danno 12-07-2006 03:34 PM

Re: Modelling an object as Session Bean or Entity Bean ?
 

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


wesley.hall@gmail.com 12-07-2006 04:22 PM

Re: Modelling an object as Session Bean or Entity Bean ?
 

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



All times are GMT. The time now is 11:13 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.