Problems mapping UUID in JPA/hibernate

前端 未结 6 1151
既然无缘
既然无缘 2020-12-05 10:20

According to the documentation, hibernate 3.6 should have support for the java.util.UUID type. But when I map it like:

@Id protected UUID uuid;
6条回答
  •  感动是毒
    2020-12-05 10:56

    Extending Mike Lively's answer with a code sample & referring to Oracle too.

    I had this problem with the OracleDialect (Oracle10gDialect). Adding an annotation @Type to the UUID field fixed it for me.

    @Id
    @Type(type="uuid-char")
    private UUID id;
    

    Note: also used a TwoWayStringBridge on this field, using the @FieldBridge annotation.

    Note: type="uuid-binary" did not work; got the same, unknown type error.

提交回复
热议问题