We have migrated one springboot project from 2.3.4-RELEASE to 3.0.1 . The application is running fine but when we hit the request , we are getting below error -
Entity relationship:
@Data
@Entity
@Table(name = "tableA ")
public class tableA {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
@Column(name = “pk”)
private long objectId;
@OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
@JoinColumn(name = “reference_code”,referencedColumnName = “reference_code”)
private Set tableBList = new HashSet<>();
//Other columns of TableA
}
@Data
@Entity
@Table(name = “TableB”)
public class tableB {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
@Column(name = “pk1”)
private long objectId;
//Other columns of TableB
}
java.lang.ClassCastException: class classname cannot be cast to class java.lang.String (classname is in unnamed module of loader ‘app’; java.lang.String is in module java.base of loader ‘bootstrap’)
at org.hibernate.type.descriptor.java.StringJavaType.unwrap(StringJavaType.java:27) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.type.descriptor.jdbc.VarcharJdbcType$1.doBind(VarcharJdbcType.java:97) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.type.descriptor.jdbc.BasicBinder.bind(BasicBinder.java:63) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.sql.exec.internal.AbstractJdbcParameter.bindParameterValue(AbstractJdbcParameter.java:108) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.sql.exec.internal.AbstractJdbcParameter.bindParameterValue(AbstractJdbcParameter.java:98) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.sql.results.jdbc.internal.DeferredResultSetAccess.executeQuery(DeferredResultSetAccess.java:188) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.sql.results.jdbc.internal.DeferredResultSetAccess.getResultSet(DeferredResultSetAccess.java:146) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.sql.results.jdbc.internal.JdbcValuesResultSetImpl.advanceNext(JdbcValuesResultSetImpl.java:205) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.sql.results.jdbc.internal.JdbcValuesResultSetImpl.processNext(JdbcValuesResultSetImpl.java:85) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.sql.results.jdbc.internal.AbstractJdbcValues.next(AbstractJdbcValues.java:29) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]