Skip to content
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

Unable to intially save an entity with a non-null custom @Id identifier. #292

Closed
jackdpeterson opened this issue Jan 30, 2020 · 1 comment
Labels
status: duplicate A duplicate of another issue

Comments

@jackdpeterson
Copy link
Contributor

jackdpeterson commented Jan 30, 2020

Given an entity with a structure roughly as follows:

@AllArgsConstructor
@NoArgsConstructor
@Data
final class SomeItem {
    @Id
    private String id;

    private string someOtherField;
}        
SomeItem si = new SomeItem('myCustomId','anotherField');
this.repository.save(si).block();

It doesn't appear that there is way to save an entity if the ID is pre-computed in Java land.

The exception looks like:
java.lang.IllegalStateException: Failed to execute ApplicationRunner at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:778) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE] at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:765) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE] at com.example.MyApplication.main(MyApplication.java:27) ~[classes/:na] Caused by: org.springframework.dao.TransientDataAccessResourceException: Failed to update table [example]. Row with Id [myCustomId] does not exist.

The backing Driver I'm working with is

     <!-- R2DBC MySQL driver -->
        <dependency>
            <groupId>dev.miku</groupId>
            <artifactId>r2dbc-mysql</artifactId>
            <version>0.8.0.RELEASE</version>
        </dependency>
@mp911de mp911de added the status: duplicate A duplicate of another issue label Jan 31, 2020
@mp911de
Copy link
Member

mp911de commented Jan 31, 2020

That's a duplicate of #253 and #275.

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