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

Grails 3.3 - OneToOne mapping not working #1173

Closed
4 tasks done
jglapa opened this issue Jun 12, 2018 · 6 comments
Closed
4 tasks done

Grails 3.3 - OneToOne mapping not working #1173

jglapa opened this issue Jun 12, 2018 · 6 comments
Assignees

Comments

@jglapa
Copy link

jglapa commented Jun 12, 2018

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

  1. download and start the example project: https://github.com/jglapa/g335-oneToOne
  • ./gradlew bootRun
  1. navigate to http://localhost:8080/body/create
  • should succeed and create Face and Nose objects in H2 db
  1. navigate to http://localhost:8080/body/update
  • will fail:
        ... 14 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLException: Parameter "#2" is not set; SQL statement:
select this_.id as y0_ from face this_ where this_.id=? limit ? [90012-197]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
        at org.h2.message.DbException.get(DbException.java:179)
        at org.h2.message.DbException.get(DbException.java:155)
        at org.h2.expression.Parameter.checkSet(Parameter.java:81)
        at org.h2.command.Prepared.checkParameters(Prepared.java:170)
        at org.h2.command.CommandContainer.query(CommandContainer.java:113)
        at org.h2.command.Command.executeQuery(Command.java:202)
        at org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:114)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:70)
        ... 50 common frames omitted

Expected Behaviour

update operation works

Actual Behaviour

update operation fails with exception

Observation:

  • the unique constract for nose in Face domain seems to be the problem
  • this example is coming from the official GORM guide : http://gorm.grails.org/6.1.x/hibernate/manual/#gormAssociation - 5.1.1. Many-to-one and one-to-one - Examples C
  • the example works fine under Grails 3.2.13
  • the example fails already on create operation under Grails 3.3.0

Environment Information

  • Operating System: Ubuntu 18
  • Grails Version: 3.3.5
  • JDK Version: 1.8

Example Application

@patmagauran
Copy link

This also occurs in a many to one setup

@patmagauran
Copy link

I have done some debugging: it appears that the normal flow is for a Statement, along with query parameters to be set onto a PreparedStatement. For a OneToOne relationship, the OneToOneType is applied to it. To set the value a function of the type is called: nullSafeSet(...).
Here is the declaration for the nullSafeSet in OneToOneType of Hibernate:

@Override
	public void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SharedSessionContractImplementor session) {
		//nothing to do
	}

@jglapa
Copy link
Author

jglapa commented Oct 31, 2018

any plans to fix this?

@jameskleeh jameskleeh transferred this issue from grails/grails-core Nov 1, 2018
@bassmartin
Copy link

I'm having issues with this also.

@ilopmar ilopmar self-assigned this Apr 4, 2019
@ilopmar
Copy link
Contributor

ilopmar commented Apr 4, 2019

I'm able to reproduce the issue with your sample application but after upgrading it to Grails 3.3.9 and GORM 6.1.11 I can't reproduce it anymore and everything works as expected.

This is the patch you can apply:

diff --git a/gradle.properties b/gradle.properties
index 3b7b524..1365cec 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,3 +1,3 @@
-grailsVersion=3.3.5
-gormVersion=6.1.9.RELEASE
+grailsVersion=3.3.9
+gormVersion=6.1.11.RELEASE
 gradleWrapperVersion=3.5

@ilopmar ilopmar closed this as completed Apr 4, 2019
@jglapa
Copy link
Author

jglapa commented Apr 5, 2019

yay! thanks @ilopmar !

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

No branches or pull requests

4 participants