geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dasun Perera" <das...@gmail.com>
Subject RE: J2EE EJB design question
Date Mon, 02 Oct 2006 10:49:59 GMT
Hi Mattias,

Whether you should go with entity beans for data persistence is a subjective
decision, but if you prefers that way then, you should have a session bean
as well as an entity bean and changeSalary method should be implemented in
Session bean which calls entity bean for data persistence.

Dasun Perera

-----Original Message-----
From: Mattias Malmgren [mailto:mattias@freefarm.se] 
Sent: Monday, October 02, 2006 1:37 PM
To: user@geronimo.apache.org
Subject: J2EE EJB design question

Hi

Perhaps out of topic, but anyway, this is my question:

As far as I can understatnd, an enity EJB can not have business methods, 
just getter/setter methods for the, in the database underlaying fileds in a 
table, along with the methods in the EntityBean interface.

Say I have an Employee object like this:

class Employee {
	int id;
	String name;
	double salary;
	
	void changeSalary(double percentage) {
		salary = salary + (salary * (precentage / 100));
	}
	void save() {
	    myDatabase.saveEmployee(this);
	}
}

Using EJB what do I do? In an enity EJB I can't have the changeSalary 
method? If I have it as a Session Bean, I can't have presistance and save 
the objects data? What is the design soulotion?

Best regards // Mattias 



Mime
View raw message