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?
*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;
So, when the entity identifier and an association share the same column, you can use @MapsId to ignore the entity identifier attribute and use the association instead.
The @Basic annotation is used to map a basic attribute type to a database column.
If no @Table is defined the default values are used: the unqualified class name of the entity. For example if you have: @Entity public class MyTest{ ... Your table will have the name my_test in your database.
In hibernate we can map a model object into a relation/table with the help of @Entity annotation.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With