I have recently upgraded spring and hibernate jars of my project and After upgrading i am always getting mapping exception saying “Unable to find column with logical name” in table ". I have explicitly mentioned logical name on entity classes but while SQLs are generated. physical names are of variable name.
New Versions
hibernate --> 5.4.9
spring jars(core,aop,web,orm ....)--> 5.2.1
spring-data-jpa-->2.2.1
point balance entity class.
@Entity
@Table(name = "pointbal")
public class PointBalance extends AbstractTrackableEntity<Long> {
private static final long serialVersionUID = 2495698617037810698L;
@Audited
@Column(name = "employeeid", nullable = false, precision = 12)
private Long employeeId;
@Column(name = "enddtm", nullable = false)
@Convert(converter = LocalDateTimePersistenceConverter.class)
private LocalDateTime endDateTime;
@Audited
@Column(name = "pointendbalamt", precision = 16, scale = 6)
private BigDecimal pointEndBalanceAmount;
@Column(name = "pointstartbalamt", precision = 16, scale = 6)
private BigDecimal pointStartBalanceAmount;
@Audited
@Column(name = "startdtm")
private LocalDateTime startDateTime;
@Version
@Column(name = "versioncnt", precision = 12)
private long versioncnt;
@ManyToOne (fetch=FetchType.LAZY)
@JoinColumn(name = "transtatusid")
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
private TransactionStatus transactionStatus;
@ManyToOne
@JoinColumn(name = "pointtypeid", nullable = false)
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
private PointBalanceType pointBalanceType;
@Override
@Id
@Column(name = "pointbalid")
@Access(AccessType.PROPERTY)
@GeneratedValue(generator = "pointBalanceSequence", strategy = GenerationType.SEQUENCE)
public Long getId() {
return id;
}
}
@Entity
@Table(name = "pointtype")
public class PointBalanceType extends AbstractReferenceDataEntity<Long> {
private static final long serialVersionUID = -3732362787488510501L;
@Column(nullable = false, precision = 1)
private BigDecimal decimalPlaceNum;
@Column(name = "ispointexpiredsw", nullable = false)
private boolean isPointExpiredSw;
@Column(name = "istimeexpiredsw", nullable = false)
private boolean isTimeExpiredSw;
@Column(name = "maxbalanceamt", nullable = false, precision = 16, scale = 6)
private BigDecimal maxBalanceAmount;
@Column(name = "minbalanceamt", nullable = false, precision = 16, scale = 6)
private BigDecimal minBalanceAmount;
@Column(name = "startbalanceamt", nullable = false, precision = 3)
private BigDecimal startBalanceAmount;
@Column(name = "ordernum", precision = 12)
private long orderNumber;
@Version
@Column(name = "versioncnt", precision = 12)
private long versioncnt;
@Override
@Id
@Column(name = "pointtypeid")
@Access(AccessType.PROPERTY)
public Long getId() {
return id;
}
}
SQLS Generated for finding all entities:
select pointbalan0_.pointbalid as pointbal1_0_, pointbalan0_.endDateTime as endDateT2_0_, pointbalan0_.pointBalanceType as pointBal3_0_, pointbalan0_.pointEndBalanceAmount as pointEnd4_0_, pointbalan0_.pointStartBalanceAmount as pointSta5_0_, pointbalan0_.startDateTime as startDat6_0_, pointbalan0_.transactionStatus as transact7_0_, pointbalan0_.versioncnt as versionc8_0_ from pointbal pointbalan0_
The physical names are different in Database and the sqls generated are different.
On further check found that Naming Strategy has been changed in hibernate 5. But as far as i know hibernate puts same logical name as physical names or has that been changed in hibernate 5?
How can i have same logical name and physical name in hibernate 5?