Make Hibernate Ignore Instance Variables That Are Not Mapped

Make Hibernate ignore instance variables that are not mapped

JPA will use all properties of the class, unless you specifically mark them with @Transient:

@Transient
private String agencyName;

The @Column annotation is purely optional, and is there to let you override the auto-generated column name. Furthermore, the length attribute of @Column is only used when auto-generating table definitions, it has no effect on the runtime.

What is the easiest way to ignore a JPA field during persistence?

@Transient complies with your needs.

How to make Hibernate ignore a method?

Add @Transient to the method then Hibernate should ignore it.

To quote the Hibernate Documentation:

Every non static non transient property (field or method depending on the access type) of an entity is considered persistent, unless you annotate it as @Transient.



Related Topics



Leave a reply



Submit