Java Reference
In-Depth Information
If an entity bean that has caching enabled is persisted to a database via an entity
manager, the entity bean is serialized by caches. Therefore, an entity bean is
recommended to implement the java.io.Serializable interface. In the entity bean
class, specify the POJO properties. Also, specify the serialVersionUID , which is
used by the serialization runtime to associate a version number with the serializable
class. Add the getter and setter methods for the entity bean properties. Specify the
identifier property with the @Id annotation. We have used only some of the EJB 3.0
annotations that may be specified in an entity bean. For a complete reference to EJB
3.0 annotations, refer to, EJB 3.0 specification ( http://java.sun.com/products/
ejb/docs.html ). The Catalog entity bean is listed next:
package ejb3;
import java.io.Serializable;
import javax.persistence.*;
@Entity
@Table(name="Catalog")
public class Catalog implements Serializable {
private static final long serialVersionUID = 7422574264557894633L;
private long id;
private String journal;
private String publisher;
private String date;
private String title;
private String author;
public Catalog(){ super();}
public Catalog(Integer id, String journal, String publisher, String
date, String title, String author){
super();
this.id=id;
this.journal=journal;
this.publisher=publisher;
this.date=date;
this.title=title;
this.author=author;
}
@Id
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getJournal() {
return journal;
}
public void setJournal(String journal) {
this.journal = journal; }
 
Search WWH ::




Custom Search