is it possible to make all fields of an object @Transient by default
I have a base Entity class which will be derived in more than a hundred of a subclasses.
In order to开发者_如何学运维 be sure that persisted fields will be the ones I want (and not the users of that base class), I want to declare this JPA entity as setting all fields as transient by default.
How is it possible ?
If you don't put @MappedSuperclass on your class you are extending from, the class properties will never by persisted. You can provide getter methods for certain properties, and place the annotations on the properties instead of the fields. The @Id annotation determines if you want the fields or the properties. In JPA 2 you can also use the @Access annotation.
精彩评论