How to do it...

  1. We first define our persistence unit:
  <persistence-unit name="ch02-batch-pu" >    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>    <jta-data-source>java:app/userDb</jta-data-source>    <exclude-unlisted-classes>false</exclude-unlisted-classes>    <properties>      <property name="javax.persistence.schema-        generation.database.action"        value="create"/>      <property name="hibernate.transaction.jta.platform"        value="org.hibernate.service.jta.platform       .internal.SunOneJtaPlatform"/>    </properties>  </persistence-unit>
  1. Then we declare a User entity:
@Entity@Table(name = "UserTab")public class User implements Serializable {    private static final long serialVersionUID = 1L;    @Id    @NotNull    private Integer id; private String name; ...

Get Java EE 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.