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

Allow to persist cascade for non-null embedded id #1242

Merged
merged 1 commit into from Dec 13, 2021
Merged

Conversation

dstepanov
Copy link
Contributor

Fixes #1173

@Chris-V
Copy link

Chris-V commented Dec 10, 2021

@dstepanov Thanks a lot for taking charge of this. I tested your fix in my project and am now facing the second issue I described in #1173 regarding the dialect. Notice the first query quotes columns with backticks, but the second uses double quotes.

Logs:

10:01:12.658 [Test worker] DEBUG io.micronaut.data.query - Executing SQL Insert: INSERT INTO `organization` (`id`,`name`) VALUES (?,CONVERT(? USING UTF8MB4))
10:01:12.875 [Test worker] DEBUG io.micronaut.data.query - Executing Batch SQL Insert: INSERT INTO "organization_profile" ("organization_id","profile_name") VALUES (?,?)

Stack trace

SQL Error executing INSERT: SQL error executing INSERT: (conn=6) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"organization_profile" ("organization_uuid","profile_name") VAL' at line 1
io.micronaut.data.exceptions.DataAccessException: SQL Error executing INSERT: SQL error executing INSERT: (conn=6) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"organization_profile" ("organization_id","profile_name") VAL' at line 1
	at app//io.micronaut.data.runtime.operations.internal.AbstractRepositoryOperations.persistOne(AbstractRepositoryOperations.java:289)
	at app//io.micronaut.data.jdbc.operations.DefaultJdbcRepositoryOperations.lambda$persist$16(DefaultJdbcRepositoryOperations.java:753)
	at app//io.micronaut.transaction.support.AbstractSynchronousTransactionManager.executeWrite(AbstractSynchronousTransactionManager.java:175)
	at app//io.micronaut.data.jdbc.operations.DefaultJdbcRepositoryOperations.persist(DefaultJdbcRepositoryOperations.java:751)
	at app//io.micronaut.data.runtime.intercept.DefaultSaveEntityInterceptor.intercept(DefaultSaveEntityInterceptor.java:45)
	at app//io.micronaut.data.intercept.DataIntroductionAdvice.intercept(DataIntroductionAdvice.java:114)
	at app//io.micronaut.data.intercept.DataIntroductionAdvice.intercept(DataIntroductionAdvice.java:88)
	at app//io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:137)

Edit: I enabled ANSI_QUOTES on my test setup and the patch works. However this is not an option for our production environment :(

@dstepanov dstepanov merged commit fb4182c into master Dec 13, 2021
@dstepanov dstepanov deleted the cascadeem branch December 13, 2021 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Micronaut-jdbc doesn't cascade one-to-many for Embeddable entities
3 participants