Is it possible to somehow force Hibernate to conditionally ignore a missing column in the database table when performing CRUD operations?
I have a Java application using Hibernate as a persistence layer. I would like to tell Hibernate somehow: if the database version is <50, then ignore this column annotation (or install it with a transient).
This situation arises due to different versions of the database on different clients, but the same entity code for all sites. For example, I have a class where a column description2
may not be present in some databases.
@Entity
@Table(name = "MY_TABLE")
public class MyTable implements java.io.Serializable {
private Integer serialNo;
private String pickCode;
private String description1;
private String description2;
@Id
@Column(name = "Serial_No", nullable = false)
@GenericGenerator(name = "generator", strategy = "increment")
@GeneratedValue(generator = "generator")
public Integer getSerialNo() {
return this.serialNo;
}
@Column(name = "Pick_Code", length = 25)
public String getPickCode() {
return this.pickCode;
}
@Column(name = "Description1")
public String getDescription1() {
return this.description1;
}
@Column(name = "Description2")
public String getDescription2() {
return this.description2;
}
}
: . , ( 500 500) , (, ). , . , . , ( ), .