Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JTS - Hibernate + Postgres + UUID conflict

I'm using Hibernate 5.0 + Postgres 9.4

My entities use UUIDs as indentifier.

The project also uses hibernate-spatial.

The id property is annotated simply as

@Id
@GeneratedValue
private UUID id;

After persisting any entity (not only the ones with geometrical data), I get the following error:

column "id" is of type geometry but expression is of type uuid

Looks like there is some conflict in types mapping to me; though I'm not an expert of Hibernate types mapping.

Is there anyone who can help me overcome this issue?

like image 688
Stefano Cazzola Avatar asked Nov 19 '16 08:11

Stefano Cazzola


1 Answers

Check out this answer and the original discussion thread

Specifying columnDefinition = "uuid" solved exactly the same issue for me.

@Entity
public class MyEntity {
    @Id
    @GeneratedValue
    @Column( columnDefinition = "uuid", updatable = false )
    public UUID getId() {
        return id;
    }
}
like image 76
Johnny Doe Avatar answered Oct 02 '22 12:10

Johnny Doe