Hibernate returns BigIntegers instead of longs

后端 未结 5 1349
猫巷女王i
猫巷女王i 2021-01-07 23:21

This is my Sender entity

@Entity
public class Sender {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long senderId;
...


...

    p         


        
5条回答
  •  有刺的猬
    2021-01-07 23:47

    Object database mapping is wrong. There is a casting exception here saying database field is BigInteger, but object property is long.

    BigInteger is a special class to hold unlimited size integer values. Furthermore, BigInteger can not cast to long implicitly.

    To avoid this error database field which is BigInteger should be change to long compatible type. Change it to a int type where int can be casted to long implicitly. See BigInteger.

提交回复
热议问题