Hibernate Annotations - How do I exclude a bean´s field from mapping?
I´ve got a bean containing some fields, and two of them are not intended to be mapped by hibernate (errorStatus and operationResultMessage). How do I tell Hibernate (via annotations) that I don´t want to map those fields?
开发者_如何学C*The mapped table in the beans does not have the fields: errorStatus and operationResultMessage
Thanks in advance.
Code right bellow:
** Gettters and Setters ommited!
@Entity
@Table(name = "users")
public class AccountBean implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column(name = "name")
private String userName;
@Column(name = "email")
private String email;
@Column(name = "login")
private String login;
@Column(name = "password")
private String password;
private Boolean errorStatus;
private String operationResultMessage;
Use the @Transient
annotation.
/* snip... */
@Transient
private Boolean errorStatus;
@Transient
private String operationResultMessage;
Obviously, if you're annotating the getters/setters rather than the fields, that's where the @Transient
annotation would go.
精彩评论