Different representation of UUID in Java Hibernate and SQL Server

后端 未结 3 1690
星月不相逢
星月不相逢 2020-12-03 21:26

I am trying to map a UUID column in POJO to SQL Server table column using Hibernate.

The annotations are applied as follows:

@Id
@Genera         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-03 21:58

    You need to specify the @Type(type = "uuid-char") in addition to @Column(name="...", columnDefinition = "uniqueidentifier"), see also Problems mapping UUID in JPA/hibernate .

    Alternatively you can use a String field for the id in Java and still keep uniqueidentifier in SQL Server.

提交回复
热议问题