Hi please tell me! Why? my entity not updated in d...
# spring
s
Hi please tell me! Why? my entity not updated in db
Copy code
if (checkEmailStatusVerification.first == description) { // it's ok
    verification.verificationState = description
    verificationRepository.run { save(verification) } // this code doesn't work
    throw EmailVerificationException("emailAlreadyVerified  ${verification.email}")
}
i am use
Copy code
//reactive postgre
implementation("org.springframework.boot:spring-boot-starter-data-r2dbc")
runtimeOnly("io.r2dbc:r2dbc-postgresql:0.8.13.RELEASE")
runtimeOnly("org.postgresql:postgresql:42.5.1")
t
One thing that could be happening here is that this method is transactional. Which means that if the method throws an exception, the transaction is rolled back, and you throw an exception right after the save method. Just as a test, can you not throw that exception and see if the object get's saved then? (also, maybe a question for the other kotlin people here, what would the .run{} add above just calling verificationRepository.save(verification)?)
s
.run{} add above just calling verificationRepository.save(verification)?)
this call method without publisher
i try without throw Exception - doesn’t work(
t
How are you testing it? and can you add a log statement there (within the .run{}), to make sure that the code is actually executed (since with reactive stack, that can also be a thing..)
s
i check my db record
t
Then a quick extra check would be to add a log statement just above the save(verification) just to see if that bit of code actually gets executed
s
Ok. I try. Write message here after check.
Copy code
println("This state start" + verification.verificationState)
verification.verificationState = conDescription
println("START UPDATE state " + verification.verificationState)
verificationRepository.run { save(verification) }
println("FINISH UPDATE")
throw EmailVerificationException("emailAlreadyVerified  ${verification.email}")
i see records in log but db record not updated
i add to config
Copy code
logging:
  level:
    io.r2dbc.postgresql.QUERY: DEBUG # for queries
    io.r2dbc.postgresql.PARAM: DEBUG # for parameters
and my query not start, i am not see qery in log
Copy code
kotlin.run { verificationRepository.save(verification).subscribe() }
this good)
t
So it turned out that your code was not executed 😛
s
Yes. Without subscriber not working