Java Reference
In-Depth Information
@Produces
@PersistenceContext(unitName="pu3")
@TestDatabase
EntityManager customerDatabasePersistenceContext;
@Produces
@PersistenceUnit(unitName="pu4")
@Documents
EntityManagerFactory customerDatabasePersistenceUnit;
@Produces
@PersistenceContext(unitName="pu4")
@Documents
EntityManager docDatabaseEntityManager;"
}
The EntityManagerFactory declarations
also
allow
applications
to
use
an
application-managed entity manager.
The producerfields Entity and Session Bean
The producerfields example contains a simple entity class, entity.ToDo , and a
stateful session bean, ejb.RequestBean , that uses it.
The entity class contains three fields: an autogenerated id field, a string specifying the
task, and a timestamp. The timestamp field, timeCreated , is annotated with @Tem-
poral , which is required for persistent Date fields.
Click here to view code image
@Entity
public class ToDo implements Serializable {
...
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
protected String taskText;
@Temporal(TIMESTAMP)
protected Date timeCreated;
public ToDo() {
}
public ToDo(Long id, String taskText, Date timeCreated) {
Search WWH ::




Custom Search