Hibernate JoinColumn Error on not null constraint

前端 未结 1 458
春和景丽
春和景丽 2021-01-15 22:45

Here\'s a list of my classes

@MappedSuperclass
public abstract class JpaModel {

    @Id
    @Column(name =\"ID\", columnDefinition = \"serial\")
    @Genera         


        
1条回答
  •  清酒与你
    2021-01-15 23:11

    From your log, it shows id=null, which is not related to inventoryItemPicture at all.

    The issue is at @GeneratedValue(strategy = GenerationType.IDENTITY)

    Your log shows you are using postgresql, but "IDENTITY" can only be used for these dbs:

    • Sybase, My SQL, MS SQL Server, DB2 and HypersonicSQL.

    You should use GenerationType.SEQUENCE, which is supported by:

    • Oracle, DB2, SAP DB, Postgre SQL or McKoi.

    Try change your code to this:

    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    

    0 讨论(0)
提交回复
热议问题