-
Notifications
You must be signed in to change notification settings - Fork 129
Description
I am migrating from h2 driver to mssql driver and have problem with returning the id after saving.
Problem happens also with writing foreign keys via custom write converters.
It first seemd like the id generation happens after r2dbc converters do their job but when i completely removed them and temporary adapted entities to not contain nested entities, I figured out that the generated ids are not returned at all.
How am I then supposed to gather generated id if not immediately after creation?
This all worked just fine with h2 with uuid() function in the flyway script
however with the MSSQL NEWID() function i keep getting null, however in the database values are persisted.
Flyway:
create table Foo
(
foo_id uniqueidentifier default NEWID() PRIMARY KEY,
)
Repository: public interface FooRepository extends ReactiveCrudRepository<Foo, String>{}
Entity:
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Getter
@Setter
@Table
public class Foo {
@Id
@Column(FooTable.ID) // foo_id
private String id;
And so in the pipeline it looks like this:
return fooRepository.save(foo)
.doOnNext(f -> System.out.println(f.getId()); // prints null
Not sure if it is a bug or I lack something.