Entity Bean of EJB 3

The taste of beans in EJB are Session, Entity and Message driven Bean. Entity Bean is persistent. Persistent means being written the hard disk or another kind storage media. Entity bean is close to Database, what we create it and make it persist just like insert into database.

EJB 3 used annotation feature that belong to java 5 or above. Entity Bean 3 is simpler then EJB 2. Before EJB 3, developver have to declare all setting in xml file, to map the entity and the table is teh example. Also required extends EJBObject and create interfaces for all of them.

Now it is simpler for developer. Just create PAJO(Plain Annotation Java Object) , then add @Entity above of the class.

example
@Entity
public class Customer implements Serializable{
@Id
private Long myID;
private String name;
private String address;
:
:

}
The three member variable of Customer is mapped as the field of Customer Table by default. The name of the table, if not declared @Table(name=”” ),will use Class name, in this case Customer table. Don’t forget to add setter and getter for each member variable.

Implement serializable why? now we’re working in many JVM or client and server is separated. then we cannt use passing by reference anymore. Object is passing by value and remote client can have object that exactly same as in the container.

One thought on “Entity Bean of EJB 3

  1. ks_uk July 31, 2008 at 2:51 pm Reply

    So simple!😀

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: