1

Spring Boot: 2.0.2

Hibernate Core: 5.2.17

dialect: SQLServer2012Dialect

When trying to save entity whose id is a generated GUID into SQL Server using JpaRepository save() method the operation fails with the following messages:

SQL Error: 8169, SQLState: S0002

Conversion failed when converting from a character string to uniqueidentifier

HHH000327: Error performing load command : org.hibernate.exception.SQLGrammarException: could not load an entity

com.microsoft.sqlserver.jdbc.SQLServerException: Conversion failed when converting from a character string to uniqueidentifier

@Id
@GenericGenerator(name = "generator", strategy = "guid", parameters = {})
@GeneratedValue(generator = "generator" , strategy = GenerationType.AUTO)
@Column(name = "ActivityID" , columnDefinition="uniqueidentifier")
private String ActivityID;

Another description of the problem: Conversion failed from a character string to uniqueidentifier

asabd
  • 299
  • 1
  • 5
  • 9

1 Answers1

0

Well, after some digging, here is what solved it for me:

Basically change the mapping to:

    private UUID id;

    @Id
    @GeneratedValue
    @Column( columnDefinition = "uuid", updatable = false )
    public UUID getId() {
        return id;
    }

And don't forget to send a (not) friendly email to the DBA that decided to use that id type -.-

Regards