Hibernate Books

All times are UTC - 5 hours [ DST ]

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: UUID as primary key
PostPosted: Mon Aug 21, 2017 12:30 pm 

Joined: Mon Aug 21, 2017 12:07 pm
Posts: 1

I have a simple JPA repository.
The entity contains UUID as primary key.
My test is under Cassandra OGM datastore (5.2.0-SNAPSHOT) and Hibernate core is 5.1.5.Final.

I use this as my local container :
l.getJpaPropertyMap().put("hibernate.ogm.datastore.provider", "org.hibernate.ogm.datastore.cassandra.impl.CassandraDatastoreProvider");
l.getJpaPropertyMap().put("hibernate.ogm.datastore.host", cassandraHost);
l.getJpaPropertyMap().put("hibernate.ogm.datastore.database", "keyspace1");

My entity is like :
public class PERSON{
UUID id;

String name;

My repository is like :
public interface PERSONRepository extends JpaRepository<PERSON, UUID>{

When I save my entity with my repository, the database is correct.

But when I try :

UUID key = UUID.fromString("1f2504e0-4f89-11d3-9a0c-0305e82c3302");

PERSONRepository .existsById(key);

I have an exception :
org.springframework.dao.InvalidDataAccessApiUsageException: Invalid UUID string: 1; nested exception is java.lang.IllegalArgumentException: Invalid UUID string: 1

Is-it possible to use UUID as PK with Cassandra ORM ?

Best regards.

The problem seemes coming from the function ExistsById.
If I use findById(key).isPresent(), the response is correct.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours [ DST ]

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.