Reputation: 263
Is it possible to add extra member variables in hibernate beans that are not fields in the actual database?
eg. I need to add hasComments a member variable in MyEntity, and has comments is not an actual field in the db.
Upvotes: 4
Views: 4276
Reputation: 9201
For a quick hack to move past this error during development, you can use hbm2ddl
to create the database automatically from the hibernate mappings, and it will create fields in the table for the transient
properties. This does not solve the long term problem, but it lets you continue to work on other things until you have time to resolve the underlying issue.
Upvotes: 0
Reputation: 1613
See this
@NotNull
@Column(name = "comment")
private String comment;
@Column(name = "time")
@Temporal(TemporalType.TIMESTAMP)
@DateTimeFormat(style = "M-")
private Date time;
@Transient private String information;
Upvotes: 1
Reputation: 18552
Let either the field be transient, or annotate it with the @Transient annotation.
Upvotes: 4