dimanche 29 mars 2015

What is the exact meaning of the JPA @Entity annotation?

I am studying JPA in Spring application and I have some dounts related to the @Entity annotation.


So I have a model class like this:



@Entity
@Table(name= “T_CUSTOMER”)
public class Customer {

@Id
@Column(name=“cust_id”)
private Long id;

@Column(name=“first_name”)
private String firstName;

@Transient
private User currentUser;

...........................
...........................
...........................
}


Ok, I know that the @Entity annotation is on the class level and it means that the fields of the object that are instances of this class are to be mapped to the field of the T_CUSTOMER database table.


But why in JPA is mandatory the use of @Entity annotation and I can not only use the @Table annotation to map a model object to a specific database table? It have some other meaning\behavior that actually I am missing?


What am I missing? What is the exact meaning of the @Entity annotation?


Aucun commentaire:

Enregistrer un commentaire