-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: UUID as primary key
PostPosted: Mon Aug 21, 2017 12:30 pm 
Newbie

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

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 :
Code:
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 :
Code:
@Entity
@org.hibernate.search.annotations.Indexed
public class PERSON{
@Id
UUID id;

String name;
}


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


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

But when I try :

Code:
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 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.