3.5.4.2. Field Based Entity Bean Class Example (EJB 3)
@Entity public class AnEntity
{
// With field based access fields are persistent by default.
private int someField;
private String someOtherField;
// Relationships among entities must be annotated.
@OneToMany private Collection<AnotherEntity> relatedEntities;
// Every entity must have a primary key.
@Id private long aKeyField;
// Field that is not persistent
@Transient private String aTransientString;
// Obligatory constructor with no arguments
public AnEntity () { ... }
// Additional business methods ...
public void myMethodOne (int iArgument) { ... }
public int myMethodTwo (Object oArgument) { ... }
}