Skip to content

Cannot insert an entity identified by UUID using ReactiveCrudRepository #312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
skozlov opened this issue Feb 20, 2020 · 1 comment
Closed
Labels
status: duplicate A duplicate of another issue

Comments

@skozlov
Copy link

skozlov commented Feb 20, 2020

Suppose we have an entity:

@Entity
@Table(name = "my_table")
public abstract class MyEntity {
	@Column(name = "id")
	@javax.persistence.Id
	@org.springframework.data.annotation.Id
	public UUID id;

	MyEntity() {
	}

	public MyEntity(UUID id) {
		this.id = id;
	}
}

and a repository:

@Repository
public interface MyEntityRepository extends R2dbcRepository<MyEntity, UUID> {
}

When I try to insert an entity

myEntityRepository.save(new MyEntity(UUID.randomUUID()))

I get

org.springframework.dao.TransientDataAccessResourceException: Failed to update table [message]. Row with Id [3178455a-f0ee-4051-ad92-acb8c2ad3b82] does not exist.
	at org.springframework.data.r2dbc.repository.support.SimpleR2dbcRepository.lambda$save$0(SimpleR2dbcRepository.java:91) ~[spring-data-r2dbc-1.0.0.RELEASE.jar:1.0.0.RELEASE]

The point is, SimpleR2dbcRepository decides that the entity is not new and tries UPDATE instead of INSERT.

@skozlov
Copy link
Author

skozlov commented Feb 20, 2020

Sorry, it's a duplicate of #292.

@skozlov skozlov closed this as completed Feb 20, 2020
@mp911de mp911de added the status: duplicate A duplicate of another issue label Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

2 participants