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.
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.
Let either the field be transient, or annotate it with the @Transient annotation.
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;
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.