Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Business logic in Entity EJBs...? being strict

 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was wondering about something.
We are used to say to do business logic in session beans and leave the persistence layer only to actually persist data.
Nevertheless, strictly following this "rule" we would ONLY have setter and getters methods in entities ejbs (beyond the life-cicle and finder methods).
Am i correct til this point?
If remember the following Entity EJB method on the on-line j2ee tutorial at tusc.com.au.

Then, if i wanted to be strict, i'd say this method shouldn't be on a Entity Bean (?).
Could anyone give their opinions?
Thanks.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is fine. This isn't business logic specific to an application (like a particular validation rule only applicable in some cases). It's general to the bean, and thus should be OK.
Kyle
 
Roland Barcia
author
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Common methods I have on Entity Beans are things like increment or decrement methods. For an example, for an Account Entity Beans I can have a single withdraw or deposit method that adds the balance to the account, rather than having a Session Bean extract the current balance, do the math and then set the new balance.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic