Java Persistence API - annotations - I
26 July 2008The Java Persistence API heavily depends on the metadata annotations. The API consists of:
Java Persistence API
The Java Persistence query language
Metadata annotations
An entity is a persistence object. It is coded as a POJO, and marked as an entity with the @Entity (javax.persistence.Entity) annotation. By default, all properties/fields are persisted into the datastore, except those marked with the @Transient annotation. Following example shows few annotations that are used with entity beans.
package university; import java.io.Serializable; import javax.persistence.Entity; import javax.persistence.Table; import javax.persistence.Column; import javax.persistence.Id; @Entity @Table (name="Dept") public class Department implements Serializable { @Id @Column(name="id", nullable=false) private String deptId; @Column(name="name") private String deptName; private String location; public void setDeptId(String deptId) { this.deptId = deptId; } public String getDeptId() { return this.deptId; } public void setDeptName(String deptName) { this.deptName = deptName; } public String getDeptName() { return this.deptName; } public void setLocation(String location) { this.location = location; } public String getLocation() { return location; } .................. .................. }
continued …
Related Posts:
- Java Persistence API - annotations - II
- No Persistence provider for EntityManager
- Java Persistence API - annotations - III
- Categories of annotations
- Categories of annotations
- JDO – Byte Code Enhancement
- Custom annotations - default values - I
- Defining annotations
- Custom annotations - default values - III
- Custom annotations - Adding a member - I
Top Of Page | Trackback
If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.
It will look like this: Java Persistence API - annotations - I