• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design decision, Order entity bean and Order POJO

 
Jose Op
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on the assigment and I have a shopping cart implemented as a stateful session bean.

In my design the stateful session bean handles the minimum information to create an order, Order entity bean and OrderLine entity bean, both CMP entity bean.

On the other hand I have an OrderPOJO similar to entity bean Order, created in the web tier after saving the order, which I use for sending a request to the shipping company and send an email to the customer. OrderPOJO contains the order information (Session EJB), customer information (HTTP Session) and the Shipping company (Cache).

I do not know if it's a good solution to have two objects "Order", a entity bean that contains references (id Shipping Company, id Client , id Product) and basic data and another with more information and contains other POJO objects (POJO Order).

An Assembler object would create the POJO in the Web tier persistence after saving the order and I do not know if it's a good solution. This request would be passed to two facades made ​​to send the order to the shipping company and send the email to the customer.

Thanks !!
 
Arnold Reuser
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As long as your entity class is not part of your presentation tier you are probably doing just fine.
The context of an order is used in multiple tiers. Therefore, based on separation of concerns, it would be strange if you wouldn't have multiple classes that more or less reflect an order.

 
Rishi Shehrawat
Ranch Hand
Posts: 218
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the advantages of JPA is that the entities are simple POJO's that can be used across all layers. In my opinion you should use the Order entity in the presentation layer also instead of creating another OrderPOJO.
 
Jose Op
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Arnold !!, 7 years ago I do not use EJB and I'm afraid to commit a grave error. I think like you.

Rishi, the problem is that I need a more complex structure in the web tier, the order data (entity bean), customer data, data from the shipping company, and product data that go into the order but not in the entity bean (only stores product identifiers).

I need to send all this information to the bussines tier for implementing a few use cases.
 
Igor Malkovich
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may use JPA bean. Non-persistence field annotate with @Transient. Also you may use DTO to transfer data, but as you said part of the code will be duplicated. Only advantage if you return DTO to the controller is that you dont have to worry about lazy loading issues nor considering implementing open session in view pattern...So it is all depending on the case. Good luck.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic