borinquenkid commented on code in PR #16686:
URL: https://github.com/apache/grails-core/pull/16686#discussion_r4355126661
##########
grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionKeyColumnUpdaterSpec.groovy:
##########
@@ -103,6 +132,47 @@ class CollectionKeyColumnUpdaterSpec extends
HibernateGormDatastoreSpec {
!key.isUpdateable()
Review Comment:
Added in 8b7515a7c0, through the public API:
`MultipleUnidirectionalHasManySpec` now has two unidirectional hasMany
associations on one join table with a key column each, a row for each put in
that table, the owner reloaded, renamed, given one more element and flushed,
then reloaded again. It asserts that each association reads the row with its
own key column, that the flush keeps both rows, which is what the non-updatable
key is for, and that the added element is not written, labelled as issue 10811
and left as it is here (#16701 changes that assertion when it lands). The
package-private flag check stays.
##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionKeyColumnUpdater.java:
##########
@@ -39,19 +40,23 @@ public CollectionKeyColumnUpdater(CollectionKeyBinder
collectionKeyBinder) {
public void bind(HibernateToManyProperty property) {
DependantValue key = collectionKeyBinder.bind(property);
key.getColumns().stream().filter(Objects::nonNull).forEach(column ->
column.setNullable(true));
+ Table collectionTable = property.getCollection().getCollectionTable();
long unidirectionalCount = property.getHibernateOwner()
.getPersistentPropertiesToBind()
.stream()
- .filter(HibernateToManyProperty.class::isInstance)
+ .filter(HibernateToManyProperty::isBoundAsCollection)
.map(HibernateToManyProperty.class::cast)
.filter(p -> !p.isBidirectional())
+ .filter(p ->
Objects.equals(p.getCollection().getCollectionTable(), collectionTable))
Review Comment:
Added in 8b7515a7c0: section 26.11 of the Grails 8 upgrade notes says an
owner with several unidirectional hasMany associations writes each join table
of its own, as under Hibernate 5, and that two associations on one shared join
table are read but not written, which is issue 10811 and not fixed by this
change; the one-to-many chapter of the GORM for Hibernate 7 guide carries the
same paragraph.
--
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]