You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "borinquenkid (via GitHub)" <gi...@apache.org> on 2026/10/05 14:44:05 UTC

[PR] Hibernate 7: honour insertable and updatable false in a mapping [grails-core]

borinquenkid opened a new pull request, #16523:
URL: https://github.com/apache/grails-core/pull/16523

   ## Problem
   `insertable: false` / `updatable: false` in a mapping were ignored. `PropertyBinder` set the flags from the mapping and then overwrote them with `value.hasAnyInsertableColumns()` / `hasAnyUpdatableColumns()`, which are true for any normal column. A column with a DB default was written by the app anyway, and an `updatable: false` column changed on update.
   
   ## Fix
   `insertable && value.hasAnyInsertableColumns()` (likewise for updatable): an explicit false is honoured, and a value with no writable columns stays non-writable. The bidirectional-list many-to-one case keeps its effective behaviour (left to its columns); its dead false/false branch is not made live here, since that would be a separate behaviour change.
   
   ## Tests
   New `InsertableUpdatableMappingSpec` through the GORM API with native reads, plus rows in `PropertyBinderSpec`. They failed before. `cfg.*`, `grails.gorm.*`, `org.grails.orm.hibernate.*`: 3067 passed; no existing spec relied on the old behaviour.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: honour insertable and updatable false in a mapping [grails-core]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #16523:
URL: https://github.com/apache/grails-core/pull/16523#discussion_r4185445039


##########
grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/InsertableUpdatableMappingSpec.groovy:
##########
@@ -0,0 +1,81 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.grails.orm.hibernate.cfg.domainbinding
+
+import grails.gorm.annotation.Entity
+import grails.gorm.tests.HibernateGormDatastoreSpec
+
+/**
+ * Proves, through the GORM API, that {@code insertable: false} and {@code updatable: false} in the mapping keep the
+ * column out of the INSERT and the UPDATE statements. The database is read with a native query because the in-memory
+ * entity still holds the value the application assigned.
+ */
+class InsertableUpdatableMappingSpec extends HibernateGormDatastoreSpec {
+
+    void setupSpec() {
+        manager.registerDomainClasses(IUMColumns)
+    }
+
+    private String column(Long id, String name) {
+        sessionFactory.currentSession
+                .createNativeQuery("select ${name} from ium_columns where id = :id".toString(), String)
+                .setParameter('id', id)
+                .uniqueResult()
+    }

Review Comment:
   This helper uses `sessionFactory.currentSession` while the tests elsewhere use `session` (e.g., `session.clear()`). For consistency and to avoid any mismatch if the backing session changes, consider using the same `session` instance throughout (e.g., `session.createNativeQuery(...)`) or passing the session explicitly into the helper.



##########
grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/InsertableUpdatableMappingSpec.groovy:
##########
@@ -0,0 +1,81 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.grails.orm.hibernate.cfg.domainbinding
+
+import grails.gorm.annotation.Entity
+import grails.gorm.tests.HibernateGormDatastoreSpec
+
+/**
+ * Proves, through the GORM API, that {@code insertable: false} and {@code updatable: false} in the mapping keep the
+ * column out of the INSERT and the UPDATE statements. The database is read with a native query because the in-memory
+ * entity still holds the value the application assigned.
+ */
+class InsertableUpdatableMappingSpec extends HibernateGormDatastoreSpec {
+
+    void setupSpec() {
+        manager.registerDomainClasses(IUMColumns)
+    }
+
+    private String column(Long id, String name) {
+        sessionFactory.currentSession
+                .createNativeQuery("select ${name} from ium_columns where id = :id".toString(), String)
+                .setParameter('id', id)
+                .uniqueResult()
+    }

Review Comment:
   The column name is interpolated directly into the SQL string, which is susceptible to SQL injection if `name` ever becomes non-constant (even in tests, it’s a sharp edge and easy to copy/paste into production code). Since identifiers can’t be bound as parameters, consider whitelisting `name` (e.g., switch/Map of allowed logical names to literal column identifiers) and interpolating only the vetted identifier.



-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: honour insertable and updatable false in a mapping [grails-core]

Posted by "borinquenkid (via GitHub)" <gi...@apache.org>.
borinquenkid commented on code in PR #16523:
URL: https://github.com/apache/grails-core/pull/16523#discussion_r4190732374


##########
grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/InsertableUpdatableMappingSpec.groovy:
##########
@@ -0,0 +1,81 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.grails.orm.hibernate.cfg.domainbinding
+
+import grails.gorm.annotation.Entity
+import grails.gorm.tests.HibernateGormDatastoreSpec
+
+/**
+ * Proves, through the GORM API, that {@code insertable: false} and {@code updatable: false} in the mapping keep the
+ * column out of the INSERT and the UPDATE statements. The database is read with a native query because the in-memory
+ * entity still holds the value the application assigned.
+ */
+class InsertableUpdatableMappingSpec extends HibernateGormDatastoreSpec {
+
+    void setupSpec() {
+        manager.registerDomainClasses(IUMColumns)
+    }
+
+    private String column(Long id, String name) {
+        sessionFactory.currentSession
+                .createNativeQuery("select ${name} from ium_columns where id = :id".toString(), String)
+                .setParameter('id', id)
+                .uniqueResult()
+    }

Review Comment:
   The column name is always a fixed literal in this spec, so I did not add whitelisting; c960175fed adds a comment saying so.



##########
grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/InsertableUpdatableMappingSpec.groovy:
##########
@@ -0,0 +1,81 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.grails.orm.hibernate.cfg.domainbinding
+
+import grails.gorm.annotation.Entity
+import grails.gorm.tests.HibernateGormDatastoreSpec
+
+/**
+ * Proves, through the GORM API, that {@code insertable: false} and {@code updatable: false} in the mapping keep the
+ * column out of the INSERT and the UPDATE statements. The database is read with a native query because the in-memory
+ * entity still holds the value the application assigned.
+ */
+class InsertableUpdatableMappingSpec extends HibernateGormDatastoreSpec {
+
+    void setupSpec() {
+        manager.registerDomainClasses(IUMColumns)
+    }
+
+    private String column(Long id, String name) {
+        sessionFactory.currentSession
+                .createNativeQuery("select ${name} from ium_columns where id = :id".toString(), String)
+                .setParameter('id', id)
+                .uniqueResult()
+    }

Review Comment:
   `session` in this harness is the GORM `HibernateSession`, which has no `createNativeQuery`; `sessionFactory.currentSession` is the Hibernate session it wraps, the same one `session.clear()` clears. Documented in the helper comment in c960175fed.



-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: honour insertable and updatable false in a mapping [grails-core]

Posted by "borinquenkid (via GitHub)" <gi...@apache.org>.
borinquenkid merged PR #16523:
URL: https://github.com/apache/grails-core/pull/16523


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: honour insertable and updatable false in a mapping [grails-core]

Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #16523:
URL: https://github.com/apache/grails-core/pull/16523#issuecomment-6008858146

   ## ✅ All tests passed ✅
   
   🏷️ Commit: c960175fed89b5d685d9d0f2f698fde724790467
   ▶️ Tests:  94783 executed
   ⚪️ Checks: 92/92 completed
   
   ---
   _Learn more about TestLens at [testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
   


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: honour insertable and updatable false in a mapping [grails-core]

Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #16523:
URL: https://github.com/apache/grails-core/pull/16523#issuecomment-5997464657

   ## 🚨 TestLens detected 1 failed test 🚨
   
   Here is what you can do:
   
   1) Inspect the test failures carefully.
   2) If you are convinced that some of the tests are flaky, you can mute them below.
   3) Finally, trigger a rerun by checking the rerun checkbox.
   
   ### Test Summary
   
   #### [CI / Build Grails-Core \(Windows JDK 25 shard 2\)](https://github.com/apache/grails-core/actions/runs/37327094217/job/111820506621?pr=16523) > :grails-shell-cli:test
   
   | Test | Runs | Flakiness |
   |---|---|--:|
   | SpringApplicationRunnerSpec > ROOT OFF prints <span>#</span>failureMode failures to stderr > ROOT OFF prints launch failures to stderr | ❌ | 0%&nbsp;🟢 |
   
   🏷️ Commit: d1043345089440712c360dd3cef25d49e087418d
   ▶️ Tests:  17518 executed
   🟡 Checks: 5/77 completed
   
   ### Test Failures
   
   <details><summary><strong>SpringApplicationRunnerSpec > ROOT OFF prints <span>#</span>failureMode failures to stderr > ROOT OFF prints launch failures to stderr</strong> (:grails-shell-cli:test in <a href="https://github.com/apache/grails-core/actions/runs/37327094217/job/111820506621?pr=16523">CI / Build Grails-Core (Windows JDK 25 shard 2)</a>)</summary>
   
   ```
   Condition failed with Exception:
   
   runFixture(failureMode, false) == 'verified'
   |          |
   |          launch
   java.lang.AssertionError: Spring application runner fixture timed out after 30 seconds
   	at org.grails.cli.command.run.SpringApplicationRunnerSpec.awaitProcess(SpringApplicationRunnerSpec.groovy:85)
   	at org.grails.cli.command.run.SpringApplicationRunnerSpec.runFixture(SpringApplicationRunnerSpec.groovy:63)
   	at org.grails.cli.command.run.SpringApplicationRunnerSpec.ROOT OFF prints #failureMode failures to stderr(SpringApplicationRunnerSpec.groovy:34)
   
   	at org.grails.cli.command.run.SpringApplicationRunnerSpec.ROOT OFF prints #failureMode failures to stderr(SpringApplicationRunnerSpec.groovy:34)
   Caused by: java.lang.AssertionError: Spring application runner fixture timed out after 30 seconds
   	at org.grails.cli.command.run.SpringApplicationRunnerSpec.awaitProcess(SpringApplicationRunnerSpec.groovy:85)
   	at org.grails.cli.command.run.SpringApplicationRunnerSpec.runFixture(SpringApplicationRunnerSpec.groovy:63)
   	... 1 more
   ```
   
   </details>
   
   ### Rerun Controls
   > [!NOTE]
   > Checks are currently running using the configuration below.
   
   Select tests to mute in this pull request:
   
   🔲 SpringApplicationRunnerSpec > ROOT OFF prints <span>#</span>failureMode failures to stderr <!-- uniqueId=[engine:spock]/[spec:org.grails.cli.command.run.SpringApplicationRunnerSpec]/[feature:$spock_feature_0_0] -->
   
   Reuse successful test results:
   
   🔲 ♻️ Only rerun the tests that failed or were muted before
   
   Click the checkbox to trigger a rerun:
   
   🔲 **Rerun jobs**
   
   ---
   _Learn more about TestLens at [testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
   


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: honour insertable and updatable false in a mapping [grails-core]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #16523:
URL: https://github.com/apache/grails-core/pull/16523#issuecomment-5999224826

   ## [Codecov](https://app.codecov.io/gh/apache/grails-core/pull/16523?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 59.5414%. Comparing base ([`df80e81`](https://app.codecov.io/gh/apache/grails-core/commit/df80e8128b03c029c6e9b40158d9a9b95c6a8110?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`d104334`](https://app.codecov.io/gh/apache/grails-core/commit/d1043345089440712c360dd3cef25d49e087418d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 4 commits behind head on 8.0.x.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/grails-core/pull/16523/graphs/tree.svg?width=650&height=150&src=pr&token=qJrryhpk7u&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/grails-core/pull/16523?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##                8.0.x     #16523        +/-   ##
   ==================================================
   + Coverage     59.5377%   59.5414%   +0.0037%     
   - Complexity      25019      25020         +1     
   ==================================================
     Files            2175       2175                
     Lines          108637     108637                
     Branches        19823      19823                
   ==================================================
   + Hits            64680      64684         +4     
   + Misses          35002      34997         -5     
   - Partials         8955       8956         +1     
   ```
   [see 4 files with indirect coverage changes](https://app.codecov.io/gh/apache/grails-core/pull/16523/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org