File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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
Author

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

Joined: Aug 10, 2001
Posts: 3892
    
    5
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


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Roland Barcia
author
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Business logic in Entity EJBs...? being strict
 
Similar Threads
Aggregate/Composite Entity or Session Facade (Part II)
Methods in RMI and Multithreading
what is the need for home business methods?
Session & Entity Beans
Atomic operation of two entity invocations from a session bean