File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Business logic in Entity EJBs...? being strict Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Business logic in Entity EJBs...? being strict" Watch "Business logic in Entity EJBs...? being strict" New topic

Business logic in Entity EJBs...? being strict

Leandro Melo
Ranch Hand

Joined: Mar 27, 2004
Posts: 401
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

Then, if i wanted to be strict, i'd say this method shouldn't be on a Entity Bean (?).
Could anyone give their opinions?
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
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 Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
Roland Barcia
Ranch Hand

Joined: Apr 15, 2004
Posts: 181
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.

Roland Barcia: IBM Distinguished Engineer, CTO Mobile for Lab Services
Consider Paul's rocket mass heater.
subject: Business logic in Entity EJBs...? being strict
It's not a secret anymore!