snimavat opened a new issue, #14611:
URL: https://github.com/apache/grails-core/issues/14611

   Given the domain classes 
   
   ```
   class Org {
   
        String name
   
        OrgMember member
   
        static mappedBy = [member: "org"]
   
        static constraints = {
                member nullable: true
        }
   
        static mapping = {
                id generator: "assigned"
        }
   
   }
   
   ```
   
   ```
   class OrgMember {
        static belongsTo = [org:Org]
   
        Org branch
        Org division
        Org region
   
        //static mappedBy = [branch:"none", division:"none", region:"none"] -- 
this also doesnt make any difference
   
        static constraints = {
                org nullable: false
                branch nullable: true
                division nullable: true
                region nullable: true
        }
        
   }
   ```
   
   The following query generates the wrong sql and fails with error (Not just 
the DetachedCriteria, Hql will fail with the same error too.)
   
   `OrgMember.where({branch == null}).updateAll(branch: branch)`
   
   Generated sql query by hibernate
   
   `update org_member set id=? where id is null`
   
   Error
   ```
   
   org.h2.jdbc.JdbcSQLException: Parameter "#1" is not set; SQL statement:
   update org_member set id=? where id is null [90012-193]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
        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:164)
        at org.h2.command.CommandContainer.update(CommandContainer.java:97)
        at org.h2.command.Command.executeUpdate(Command.java:258)
        at 
org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:160)
        at 
org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:146)
        at 
org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204)
        at 
org.hibernate.hql.internal.ast.exec.BasicExecutor.doExecute(BasicExecutor.java:91)
        at 
org.hibernate.hql.internal.ast.exec.BasicExecutor.execute(BasicExecutor.java:60)
        at 
org.hibernate.hql.internal.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:429)
        at 
org.hibernate.engine.query.spi.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:374)
        at 
org.hibernate.internal.SessionImpl.executeUpdate(SessionImpl.java:1361)
        at org.hibernate.internal.QueryImpl.executeUpdate(QueryImpl.java:102)
        at 
org.grails.orm.hibernate.HibernateSession$2.doInHibernate(HibernateSession.java:145)
        at 
org.grails.orm.hibernate.HibernateSession$2.doInHibernate(HibernateSession.java:121)
        at 
org.grails.orm.hibernate.GrailsHibernateTemplate.doExecute(GrailsHibernateTemplate.java:286)
   ```
   ### Environment Information
   
   - **Operating System**: OSX
   - **GORM Version:**  6.0.9.RELEASE
   - **Grails Version:** 3.2.8
   - **JDK Version:** 1.8
   
   ### Example Application
   
[bug-report-19052017.zip](https://github.com/grails/grails-data-mapping/files/1014925/bug-report-19052017.zip)
   
   Run the OrgSpec in above example application to reproduce the error.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to