This is an automated email from the ASF dual-hosted git repository. borinquenkid pushed a commit to branch 8.0.x-hibernate7 in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 18ca442d475990088f9f77191638a4966a064d0c Author: Walter B Duque de Estrada <[email protected]> AuthorDate: Fri Jan 9 00:05:30 2026 -0600 a better roadmap --- grails-data-hibernate7/core/HIBERNATE7-TESTS.csv | 38 ++++++ grails-data-hibernate7/core/HIBERNATE7-TESTS.md | 140 --------------------- .../cfg/domainbinding/ManyToOneBinder.java | 5 +- .../cfg/domainbinding/NaturalIdentifierBinder.java | 9 +- ...idirectionalManyToOneWithListMappingSpec.groovy | 20 ++- .../ColumnConfigToColumnBinderSpec.groovy | 40 +++--- .../cfg/domainbinding/IndexBinderSpec.groovy | 2 +- .../cfg/domainbinding/ManyToOneBinderSpec.groovy | 18 +-- .../domainbinding/ManyToOneValuesBinderSpec.groovy | 6 +- .../NaturalIdentifierBinderSpec.groovy | 51 ++++---- .../NumericColumnConstraintsBinderSpec.groovy | 25 ++-- .../StringColumnConstraintsBinderSpec.groovy | 21 ++-- .../domainbinding/UniqueNameGeneratorSpec.groovy | 18 +-- 13 files changed, 157 insertions(+), 236 deletions(-) diff --git a/grails-data-hibernate7/core/HIBERNATE7-TESTS.csv b/grails-data-hibernate7/core/HIBERNATE7-TESTS.csv new file mode 100644 index 0000000000..0b23eff3ae --- /dev/null +++ b/grails-data-hibernate7/core/HIBERNATE7-TESTS.csv @@ -0,0 +1,38 @@ + Test File , Status , Notes + `src/test/groovy/org/grails/orm/hibernate/HibernateGormStaticApiSpec.groovy` , FAILED , withSession fails with persistence context issue; HQL escape test fails. + `src/test/groovy/org/grails/orm/hibernate/HibernateGormInstanceApiSpec.groovy` , FAILED , delete() method missing/renamed? remove() called instead. + `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinderSpec.groovy` , FAILED , Generator binding issues. + `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnConfigToColumnBinderSpec.groovy` , FAILED , Sealed class org.hibernate.mapping.Column cannot be mocked. + `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/UniqueNameGeneratorSpec.groovy` , FAILED , Sealed class org.hibernate.mapping.Column cannot be mocked. + `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CascadeBehaviorPersisterSpec.groovy` , FAILED , Unsupported cascade style: save-update. + `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinderSpec.groovy` , FAILED , Final class org.hibernate.mapping.ManyToOne cannot be mocked. + `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CascadeBehaviorFetcherSpec.groovy` , FAILED , Expected save-update but got all. + `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/StringColumnConstraintsBinderSpec.groovy` , FAILED , Sealed class org.hibernate.mapping.Column cannot be mocked. + `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneValuesBinderSpec.groovy` , FAILED , Final class org.hibernate.mapping.ManyToOne cannot be mocked. + `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/NaturalIdentifierBinderSpec.groovy` , FAILED , Final/Sealed class issues with RootClass and Column. + `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnBinderSpec.groovy` , FAILED ," Column name mismatch: got ""test"" instead of expected. " + `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/IndexBinderSpec.groovy` , FAILED , Sealed class org.hibernate.mapping.Column cannot be mocked. + `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/NamespaceNameExtractorSpec.groovy` , FAILED , Final class org.hibernate.boot.model.relational.Namespace$Name cannot be mocked. + `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/NumericColumnConstraintsBinderSpec.groovy` , FAILED , Sealed class org.hibernate.mapping.Column cannot be mocked. + `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/DefaultColumnNameFetcherSpec.groovy` , FAILED , Package/class name parts in generated column names use dots instead of underscores? + `src/test/groovy/org/grails/orm/hibernate/compiler/HibernateEntityTransformationSpec.groovy` , FAILED , Compilation error: Can't have an abstract method in a non-abstract class. + `src/test/groovy/org/grails/orm/hibernate/BidirectionalManyToOneWithListMappingSpec.groovy` , FAILED , Final class org.hibernate.mapping.ManyToOne cannot be mocked. + `src/test/groovy/grails/gorm/specs/HibernateGormDatastoreSpec.groovy` , PENDING , + `src/test/groovy/grails/gorm/specs/ExecuteQueryWithinValidatorSpec.groovy` , FAILED , Hibernate 7 removal: Session.save() method missing. + `src/test/groovy/grails/gorm/specs/proxy/Hibernate6GroovyProxySpec.groovy` , FAILED , Hibernate 7 change: location.isInitialized() method missing. + `src/test/groovy/grails/gorm/specs/hasmany/TwoUnidirectionalHasManySpec.groovy` , FAILED , SQL Syntax error: Qualified column names in DDL. + `src/test/groovy/grails/gorm/specs/CompositeIdWithManyToOneAndSequenceSpec.groovy` , FAILED , NPE in Hibernate 7 SequenceStyleGenerator. + `src/test/groovy/grails/gorm/specs/SubqueryAliasSpec.groovy` , SKIPPED , + `src/test/groovy/grails/gorm/specs/multitenancy/MultiTenancyBidirectionalManyToManySpec.groovy` , FAILED , Found two representations of same collection. + `src/test/groovy/grails/gorm/specs/inheritance/TablePerConcreteClassAndDateCreatedSpec.groovy` , FAILED , NPE in Hibernate 7 IncrementGenerator. + `src/test/groovy/grails/gorm/specs/dirtychecking/HibernateDirtyCheckingSpec.groovy` , FAILED , Dirty checking issues in Hibernate 7. + `src/test/groovy/grails/gorm/specs/dirtychecking/HibernateUpdateFromListenerSpec.groovy` , FAILED , Dirty checking issues in Hibernate 7. + `src/test/groovy/grails/gorm/specs/dirtychecking/PropertyFieldSpec.groovy` , FAILED , Dirty checking issues in Hibernate 7. + `src/test/groovy/grails/gorm/specs/NullableAndLengthSpec.groovy` , FAILED , Mapping/Constraint issues. + `src/test/groovy/grails/gorm/specs/SubclassMultipleListCollectionSpec.groovy` , FAILED , SQL Syntax error: Qualified column names in DDL. + `src/test/groovy/grails/gorm/specs/perf/JoinPerfSpec.groovy` , FAILED , Unique constraint violation. + `src/test/groovy/grails/gorm/specs/uuid/UuidInsertSpec.groovy` , FAILED , Logic error: name mismatch after insert/update. + `src/test/groovy/grails/gorm/specs/validation/CascadeValidationSpec.groovy` , FAILED , SQL Syntax error: Qualified column names in DDL. + `src/test/groovy/grails/gorm/specs/validation/SaveWithInvalidEntitySpec.groovy` , FAILED , Hibernate 7 change: got EntityActionVetoException instead of IllegalStateException. + `src/test/groovy/grails/gorm/specs/validation/DeepValidationSpec.groovy` , FAILED , SQL Syntax error: Qualified column names in DDL. +`grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/NamedQuerySpec.groovy` , FAILED , "No signature of method: static org.grails.datastore.gorm.GormEnhancer.createNamedQuery()" \ No newline at end of file diff --git a/grails-data-hibernate7/core/HIBERNATE7-TESTS.md b/grails-data-hibernate7/core/HIBERNATE7-TESTS.md deleted file mode 100644 index 74b2ad2deb..0000000000 --- a/grails-data-hibernate7/core/HIBERNATE7-TESTS.md +++ /dev/null @@ -1,140 +0,0 @@ -# Hibernate 7 Test Status - -| Test File | Status | Notes | -|-----------|--------|-------| -| `src/test/groovy/org/grails/datastore/mapping/model/PersistentPropertySpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/DefaultConstraintsSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/HibernateGormStaticApiSpec.groovy` | FAILED | withSession fails with persistence context issue; HQL escape test fails. | -| `src/test/groovy/org/grails/orm/hibernate/HibernateGormInstanceApiSpec.groovy` | FAILED | delete() method missing/renamed? remove() called instead. | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ForeignKeyColumnCountCalculatorSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinderSpec.groovy` | FAILED | Generator binding issues. | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/NamingStrategyProviderSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnConfigToColumnBinderSpec.groovy` | FAILED | Sealed class org.hibernate.mapping.Column cannot be mocked. | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/BackTigsTrimmerSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/UniqueNameGeneratorSpec.groovy` | FAILED | Sealed class org.hibernate.mapping.Column cannot be mocked. | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ClassBinderSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnNameForPropertyAndPathFetcherSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CascadeBehaviorPersisterSpec.groovy` | FAILED | Unsupported cascade style: save-update. | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinderSpec.groovy` | FAILED | Final class org.hibernate.mapping.ManyToOne cannot be mocked. | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/NamingStrategyWrapperSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CascadeBehaviorFetcherSpec.groovy` | FAILED | Expected save-update but got all. | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/TableNameFetcherSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/StringColumnConstraintsBinderSpec.groovy` | FAILED | Sealed class org.hibernate.mapping.Column cannot be mocked. | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueColumnBinderSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/HibernateEntityWrapperSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneValuesBinderSpec.groovy` | FAILED | Final class org.hibernate.mapping.ManyToOne cannot be mocked. | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/NaturalIdentifierBinderSpec.groovy` | FAILED | Final/Sealed class issues with RootClass and Column. | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/TypeNameProviderSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnBinderSpec.groovy` | FAILED | Column name mismatch: got "test" instead of expected. | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/BackticksRemoverSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/IndexBinderSpec.groovy` | FAILED | Sealed class org.hibernate.mapping.Column cannot be mocked. | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CompositeIdentifierToManyToOneBinderSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/TableForManyCalculatorSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/PropertyBinderSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/NamespaceNameExtractorSpec.groovy` | FAILED | Final class org.hibernate.boot.model.relational.Namespace$Name cannot be mocked. | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/UniqueKeyForColumnsCreatorSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CollectionForPropertyConfigBinderSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ShouldCollectionBindWithJoinColumnSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/NumericColumnConstraintsBinderSpec.groovy` | FAILED | Sealed class org.hibernate.mapping.Column cannot be mocked. | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/DefaultColumnNameFetcherSpec.groovy` | FAILED | Package/class name parts in generated column names use dots instead of underscores? | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/EnumTypeBinderSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CreateKeyForPropsSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/HibernateMappingContextSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/GrailsDomainBinderSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/cfg/MappingSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/connections/MultipleDataSourceConnectionsSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/connections/SecondLevelCacheSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/connections/HibernateConnectionSourceSettingsSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/connections/DataSourceConnectionSourceFactorySpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/connections/SingleTenantSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/connections/MultipleDataSourcesWithEventsSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/connections/MultipleDataSourceMetadataSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/connections/PartitionedMultiTenancySpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/connections/HibernateConnectionSourceFactorySpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/connections/MultipleDataSourcesWithCachingSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/connections/SchemaMultiTenantSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/support/HibernateVersionSupportSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/HibernateDatastoreSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/HibernateCriteriaBuilderSpec.groovy` | PASSED | | -| `src/test/groovy/org/grails/orm/hibernate/compiler/HibernateEntityTransformationSpec.groovy` | FAILED | Compilation error: Can't have an abstract method in a non-abstract class. | -| `src/test/groovy/org/grails/orm/hibernate/BidirectionalManyToOneWithListMappingSpec.groovy` | FAILED | Final class org.hibernate.mapping.ManyToOne cannot be mocked. | -| `src/test/groovy/grails/gorm/specs/UniqueConstraintHibernateSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/WhereQueryWithAssociationSortSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/HibernateGormDatastoreSpec.groovy` | PENDING | | -| `src/test/groovy/grails/gorm/specs/CompositeIdWithJoinTableSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/CascadeToBidirectionalAsssociationSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/SizeConstraintSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/TwoBidirectionalOneToManySpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/ExecuteQueryWithinValidatorSpec.groovy` | FAILED | Hibernate 7 removal: Session.save() method missing. | -| `src/test/groovy/grails/gorm/specs/proxy/Hibernate6GroovyProxySpec.groovy` | FAILED | Hibernate 7 change: location.isInitialized() method missing. | -| `src/test/groovy/grails/gorm/specs/proxy/ByteBuddyProxySpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/WithNewSessionAndExistingTransactionSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/txs/TransactionalWithinReadOnlySpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/txs/TransactionPropagationSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/txs/CustomIsolationLevelSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/TablePerSubClassAndEmbeddedSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/traits/TraitPropertySpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/traits/InterfacePropertySpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/hasmany/TwoUnidirectionalHasManySpec.groovy` | FAILED | SQL Syntax error: Qualified column names in DDL. | -| `src/test/groovy/grails/gorm/specs/hasmany/ListCollectionSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/hasmany/HasManyWithInQuerySpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/detachedcriteria/DetachedCriteriaProjectionAliasSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/detachedcriteria/DetachedCriteriaProjectionSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/detachedcriteria/DetachedCriteriaJoinSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/detachedcriteria/DetachCriteriaSubquerySpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/IdentityEnumTypeSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/mappedby/MultipleOneToOneSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/ImportFromConstraintSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/SchemaNameSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/CompositeIdWithManyToOneAndSequenceSpec.groovy` | FAILED | NPE in Hibernate 7 SequenceStyleGenerator. | -| `src/test/groovy/grails/gorm/specs/belongsto/BidirectionalOneToOneWithUniqueSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/SubqueryAliasSpec.groovy` | SKIPPED | | -| `src/test/groovy/grails/gorm/specs/jpa/SimpleJpaEntitySpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/LastUpdateWithDynamicUpdateSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/Hibernate6OptimisticLockingSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/EnumMappingSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/autoimport/AutoImportSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/UniqueWithMultipleDataSourcesSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/SaveWithExistingValidationErrorSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/multitenancy/MultiTenancyBidirectionalManyToManySpec.groovy` | FAILED | Found two representations of same collection. | -| `src/test/groovy/grails/gorm/specs/multitenancy/MultiTenancyUnidirectionalOneToManySpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/inheritance/SubclassToOneProxySpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/inheritance/TablePerConcreteClassImportedSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/inheritance/TablePerConcreteClassAndDateCreatedSpec.groovy` | FAILED | NPE in Hibernate 7 IncrementGenerator. | -| `src/test/groovy/grails/gorm/specs/MultiColumnUniqueConstraintSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/dirtychecking/HibernateDirtyCheckingSpec.groovy` | FAILED | Dirty checking issues in Hibernate 7. | -| `src/test/groovy/grails/gorm/specs/dirtychecking/HibernateUpdateFromListenerSpec.groovy` | FAILED | Dirty checking issues in Hibernate 7. | -| `src/test/groovy/grails/gorm/specs/dirtychecking/PropertyFieldSpec.groovy` | FAILED | Dirty checking issues in Hibernate 7. | -| `src/test/groovy/grails/gorm/specs/NullableAndLengthSpec.groovy` | FAILED | Mapping/Constraint issues. | -| `src/test/groovy/grails/gorm/specs/HibernateEntityTraitGeneratedSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/ToOneProxySpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/SubclassMultipleListCollectionSpec.groovy` | FAILED | SQL Syntax error: Qualified column names in DDL. | -| `src/test/groovy/grails/gorm/specs/hibernatequery/HibernateQuerySpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/softdelete/SoftDeleteSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/AutoTimestampSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/RLikeSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/events/UpdatePropertyInEventListenerSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/DeleteAllWhereSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/CountByWithEmbeddedSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/DomainGetterSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/SequenceIdSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/perf/JoinPerfSpec.groovy` | FAILED | Unique constraint violation. | -| `src/test/groovy/grails/gorm/specs/uuid/UuidInsertSpec.groovy` | FAILED | Logic error: name mismatch after insert/update. | -| `src/test/groovy/grails/gorm/specs/ReadOperationSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/ManyToOneSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/services/DataServiceSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/validation/BeanValidationSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/validation/SkipValidationSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/validation/CascadeValidationSpec.groovy` | FAILED | SQL Syntax error: Qualified column names in DDL. | -| `src/test/groovy/grails/gorm/specs/validation/SaveWithInvalidEntitySpec.groovy` | FAILED | Hibernate 7 change: got EntityActionVetoException instead of IllegalStateException. | -| `src/test/groovy/grails/gorm/specs/validation/UniqueFalseConstraintSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/validation/DeepValidationSpec.groovy` | FAILED | SQL Syntax error: Qualified column names in DDL. | -| `src/test/groovy/grails/gorm/specs/validation/UniqueWithHasOneSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/validation/UniqueWithinGroupSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/validation/UniqueInheritanceSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/validation/EmbeddedWithValidationExceptionSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/compositeid/CompositeIdWithDeepOneToManyMappingSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/compositeid/GlobalConstraintWithCompositeIdSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/specs/NullValueEqualSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/hibernate/mapping/HibernateOptimisticLockingStyleMappingSpec.groovy` | PASSED | | -| `src/test/groovy/grails/gorm/hibernate/mapping/MappingBuilderSpec.groovy` | PASSED | | diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinder.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinder.java index 614261fcf5..d2bf5b5b74 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinder.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinder.java @@ -8,6 +8,7 @@ import org.hibernate.mapping.ManyToOne; import org.grails.datastore.mapping.model.PersistentEntity; import org.grails.datastore.mapping.model.types.Association; import org.grails.datastore.mapping.model.types.ManyToMany; +import org.grails.datastore.mapping.model.types.OneToOne; import org.grails.orm.hibernate.cfg.ColumnConfig; import org.grails.orm.hibernate.cfg.CompositeIdentity; import org.grails.orm.hibernate.cfg.JoinTable; @@ -96,7 +97,9 @@ public class ManyToOneBinder { } PropertyConfig config = persistentPropertyToPropertyConfig.toPropertyConfig(property); - if ((property instanceof org.grails.datastore.mapping.model.types.OneToOne) && !isComposite) { + boolean isOneToOne = property instanceof OneToOne; + boolean notComposite = !isComposite; + if (isOneToOne && notComposite) { manyToOne.setAlternateUniqueKey(true); Column c = simpleValueColumnFetcher.getColumnForSimpleValue(manyToOne); if (c == null) { diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/NaturalIdentifierBinder.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/NaturalIdentifierBinder.java index 847db06caf..beea74f3df 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/NaturalIdentifierBinder.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/NaturalIdentifierBinder.java @@ -6,7 +6,10 @@ import org.grails.orm.hibernate.cfg.Mapping; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.UniqueKey; +import java.util.List; +import java.util.Objects; import java.util.Optional; +import java.util.stream.Stream; public class NaturalIdentifierBinder { @@ -31,10 +34,12 @@ public class NaturalIdentifierBinder { } var uk = new UniqueKey(); uk.setTable(persistentClass.getTable()); - Integer pks = naturalId.getPropertyNames() + Stream<String> stringStream = naturalId.getPropertyNames() .stream() + .filter(persistentClass::hasProperty); + List<String> list = stringStream.toList(); + Integer pks = list.stream() .map(persistentClass::getProperty) - .filter(property -> property != null) .map(property -> { property.setNaturalIdentifier(true); property.setUpdateable(naturalId.isMutable()); diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/BidirectionalManyToOneWithListMappingSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/BidirectionalManyToOneWithListMappingSpec.groovy index 3a376115d2..947c39d9dd 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/BidirectionalManyToOneWithListMappingSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/BidirectionalManyToOneWithListMappingSpec.groovy @@ -1,9 +1,11 @@ package org.grails.orm.hibernate +import org.hibernate.boot.Metadata +import org.hibernate.mapping.PersistentClass + import grails.gorm.annotation.Entity import grails.gorm.specs.HibernateGormDatastoreSpec import org.grails.datastore.mapping.model.PersistentProperty -import org.grails.orm.hibernate.cfg.HibernatePersistentEntity import org.grails.orm.hibernate.cfg.domainbinding.BidirectionalManyToOneWithListMapping import org.hibernate.mapping.ManyToOne import org.hibernate.mapping.OneToMany @@ -12,6 +14,10 @@ import org.hibernate.mapping.Property class BidirectionalManyToOneWithListMappingSpec extends HibernateGormDatastoreSpec { + void setupSpec() { + manager.addAllDomainClasses([Spec4_OneToOneParent]) + } + void "test that it is not an association property"() { given: @@ -33,7 +39,9 @@ class BidirectionalManyToOneWithListMappingSpec extends HibernateGormDatastoreSp def belongsToClass = createPersistentEntity(Spec1_BidirListChild, grailsDomainBinder) PersistentProperty grailsProperty = belongsToClass.getPropertyByName("parent") def hibernateProperty = new Property() - hibernateProperty.setValue(Mock(ManyToOne)) + + def manyToOne = new ManyToOne(getGrailsDomainBinder().getMetadataBuildingContext(),null) + hibernateProperty.setValue(manyToOne) def mapping = new BidirectionalManyToOneWithListMapping() when: @@ -80,7 +88,13 @@ class BidirectionalManyToOneWithListMappingSpec extends HibernateGormDatastoreSp def parentClass = createPersistentEntity(Spec4_OneToOneParent, grailsDomainBinder) PersistentProperty grailsProperty = parentClass.getPropertyByName("child") def hibernateProperty = new Property() - hibernateProperty.setValue(Mock(OneToOne)) + + def metadata = manager.hibernateDatastore.getMetadata() + def rootClass = metadata.getEntityBinding(Spec4_OneToOneParent.name) + + + def one = new OneToOne(getGrailsDomainBinder().getMetadataBuildingContext(), null, rootClass) + hibernateProperty.setValue(one) def mapping = new BidirectionalManyToOneWithListMapping() when: diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnConfigToColumnBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnConfigToColumnBinderSpec.groovy index 7babe4c636..e9b6ab95f8 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnConfigToColumnBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnConfigToColumnBinderSpec.groovy @@ -5,10 +5,11 @@ import org.grails.orm.hibernate.cfg.PropertyConfig import org.hibernate.mapping.Column import spock.lang.Specification +//TODO Check logic class ColumnConfigToColumnBinderSpec extends Specification { def binder = new ColumnConfigToColumnBinder() - def column = Mock(Column, name: "test") + def column = new Column("test") def "should bind column properties when values are valid"() { given: @@ -23,11 +24,11 @@ class ColumnConfigToColumnBinderSpec extends Specification { binder.bindColumnConfigToColumn(column, columnConfig, null) then: - 1 * column.setLength(100) - 1 * column.setPrecision(10) - 1 * column.setScale(2) - 1 * column.setSqlType("VARCHAR") - 0 * column.setUnique(_) + column.length == 100 + column.precision == 10 + column.scale == 2 + column.sqlType == "VARCHAR" + column.unique } def "should not bind properties when values are -1"() { @@ -41,10 +42,11 @@ class ColumnConfigToColumnBinderSpec extends Specification { binder.bindColumnConfigToColumn(column, columnConfig, null) then: - 0 * column.setLength(_) - 0 * column.setPrecision(_) - 0 * column.setScale(_) - 0 * column.setUnique(_) + column.length == null + column.precision == null + column.scale == null + column.sqlType == null + !column.unique } def "column config honors uniqueness property"() { @@ -60,10 +62,11 @@ class ColumnConfigToColumnBinderSpec extends Specification { binder.bindColumnConfigToColumn(column, columnConfig, mappedForm) then: - 0 * column.setLength(_) - 0 * column.setPrecision(_) - 0 * column.setScale(_) - 0 * column.setUnique(_) + column.length == null + column.precision == null + column.scale == null + column.sqlType == null + !column.unique } def "column config honors uniqueness property"() { @@ -78,9 +81,10 @@ class ColumnConfigToColumnBinderSpec extends Specification { binder.bindColumnConfigToColumn(column, columnConfig, mappedForm) then: - 0 * column.setLength(_) - 0 * column.setPrecision(_) - 0 * column.setScale(_) - 1 * column.setUnique(_) + column.length == null + column.precision == null + column.scale == null + column.sqlType == null + !column.unique } } \ No newline at end of file diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/IndexBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/IndexBinderSpec.groovy index 492b93889d..bb74e1d7b1 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/IndexBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/IndexBinderSpec.groovy @@ -10,7 +10,7 @@ class IndexBinderSpec extends Specification { def indexBinder = new IndexBinder() def table = Mock(Table) - def column = Mock(Column, name: "test_column") + def column = new Column("test_column") def index = Mock(Index) diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinderSpec.groovy index 714692ab07..175e3100d2 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinderSpec.groovy @@ -1,5 +1,6 @@ package org.grails.orm.hibernate.cfg.domainbinding +import grails.gorm.specs.HibernateGormDatastoreSpec import org.grails.datastore.mapping.model.PersistentEntity import org.grails.datastore.mapping.model.types.Association import org.grails.datastore.mapping.model.types.ManyToMany @@ -15,7 +16,7 @@ import org.hibernate.mapping.ManyToOne import spock.lang.Specification import spock.lang.Unroll -class ManyToOneBinderSpec extends Specification { +class ManyToOneBinderSpec extends HibernateGormDatastoreSpec { @Unroll def "Test bindManyToOne orchestration for #scenario"() { @@ -34,7 +35,8 @@ class ManyToOneBinderSpec extends Specification { // 3. Set up mocks for method arguments def association = Mock(Association) - def manyToOne = Mock(ManyToOne) + + def manyToOne = new ManyToOne(getGrailsDomainBinder().getMetadataBuildingContext(),null) def path = "/test" def refDomainClass = Mock(PersistentEntity) def mapping = Mock(Mapping) @@ -79,7 +81,7 @@ class ManyToOneBinderSpec extends Specification { def binder = new ManyToOneBinder(namingStrategy, simpleValueBinder, propertyConfigConverter, manyToOneValuesBinder, compositeBinder, columnFetcher, entityWrapper) def property = Mock(ManyToMany) - def manyToOne = Mock(ManyToOne) + def manyToOne = new ManyToOne(getGrailsDomainBinder().getMetadataBuildingContext(),null) def ownerEntity = Mock(PersistentEntity) def mapping = new Mapping() mapping.setColumns(new HashMap<String, PropertyConfig>()) @@ -117,11 +119,11 @@ class ManyToOneBinderSpec extends Specification { def binder = new ManyToOneBinder(namingStrategy, simpleValueBinder, propertyConfigConverter, manyToOneValuesBinder, compositeBinder, columnFetcher, entityWrapper) def property = Mock(OneToOne) - def manyToOne = Mock(ManyToOne) + def manyToOne = new ManyToOne(getGrailsDomainBinder().getMetadataBuildingContext(),null) def refDomainClass = Mock(PersistentEntity) def mapping = Mock(Mapping) def propertyConfig = Mock(PropertyConfig) - def column = Mock(Column, name: 'test') + def column = new Column('test') def inverseSide = Mock(Association) property.getAssociatedEntity() >> refDomainClass @@ -143,9 +145,9 @@ class ManyToOneBinderSpec extends Specification { then: 1 * manyToOne.setAlternateUniqueKey(true) if (expectedUniqueValue != null) { - 1 * column.setUnique(expectedUniqueValue) + assert column.isUnique() == expectedUniqueValue } else { - 0 * column.setUnique(_) + assert !column.isUnique() } where: @@ -170,7 +172,7 @@ class ManyToOneBinderSpec extends Specification { def binder = new ManyToOneBinder(namingStrategy, simpleValueBinder, propertyConfigConverter, manyToOneValuesBinder, compositeBinder, columnFetcher, entityWrapper) def property = Mock(OneToOne) - def manyToOne = Mock(ManyToOne) + def manyToOne = new ManyToOne(getGrailsDomainBinder().getMetadataBuildingContext(),null) def refDomainClass = Mock(PersistentEntity) def mapping = Mock(Mapping) def propertyConfig = new PropertyConfig() diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneValuesBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneValuesBinderSpec.groovy index 2dcf9d4810..91538e7def 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneValuesBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneValuesBinderSpec.groovy @@ -1,14 +1,14 @@ package org.grails.orm.hibernate.cfg.domainbinding +import grails.gorm.specs.HibernateGormDatastoreSpec import org.grails.datastore.mapping.model.PersistentEntity import org.grails.datastore.mapping.model.types.Association import org.grails.orm.hibernate.cfg.PropertyConfig import org.hibernate.FetchMode import org.hibernate.mapping.ManyToOne -import spock.lang.Specification import spock.lang.Unroll -class ManyToOneValuesBinderSpec extends Specification { +class ManyToOneValuesBinderSpec extends HibernateGormDatastoreSpec { @Unroll def "Test bindManyToOneValues with #scenario"() { @@ -19,7 +19,7 @@ class ManyToOneValuesBinderSpec extends Specification { // 2. Set up mocks for the method arguments def association = Mock(Association) - def manyToOne = Mock(ManyToOne) + def manyToOne = new ManyToOne(getGrailsDomainBinder().getMetadataBuildingContext(),null) def associatedEntity = Mock(PersistentEntity) // 3. Create the config object that the converter will return diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/NaturalIdentifierBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/NaturalIdentifierBinderSpec.groovy index 588fa28c84..0c58e59fbd 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/NaturalIdentifierBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/NaturalIdentifierBinderSpec.groovy @@ -1,5 +1,6 @@ package org.grails.orm.hibernate.cfg.domainbinding +import grails.gorm.specs.HibernateGormDatastoreSpec import org.grails.orm.hibernate.cfg.Identity import org.grails.orm.hibernate.cfg.Mapping import org.grails.orm.hibernate.cfg.NaturalId @@ -13,7 +14,7 @@ import org.hibernate.mapping.Value import spock.lang.Specification import spock.lang.Unroll -class NaturalIdentifierBinderSpec extends Specification { +class NaturalIdentifierBinderSpec extends HibernateGormDatastoreSpec { @Unroll("test bindNaturalIdentifier with a single property and mutable=#isMutable") void "test bindNaturalIdentifier with a single property"(boolean isMutable) { @@ -21,18 +22,19 @@ class NaturalIdentifierBinderSpec extends Specification { def mapping = Mock(Mapping.class) def identity = Mock(Identity) def naturalId = Mock(NaturalId) - def property = Mock(Property) + def property = new Property() + property.setName("id1") def value = Mock(Value) + property.setValue(value) Table table = Mock(Table) def id1 = "id1" mapping.getIdentity() >> identity identity.getNatural() >> naturalId naturalId.getPropertyNames() >> [id1] naturalId.isMutable() >> isMutable - def rootClass = Mock(RootClass) - rootClass.getProperty(id1) >> property - rootClass.getTable() >> table - property.getValue() >> value + def rootClass = new RootClass(getGrailsDomainBinder().getMetadataBuildingContext()) + rootClass.setIdentifierProperty(property) + rootClass.setTable(table) value.getSelectables() >> [] def uniqueNameGenerator = Mock(UniqueNameGenerator) def binder = new NaturalIdentifierBinder(uniqueNameGenerator) @@ -42,8 +44,8 @@ class NaturalIdentifierBinderSpec extends Specification { then: 1 * uniqueNameGenerator.setGeneratedUniqueName(_) - 1 * property.setNaturalIdentifier(true) - 1 * property.setUpdateable(isMutable) + property.isNaturalIdentifier() + property.isUpdatable() == isMutable 1 * table.addUniqueKey(_) where: @@ -55,12 +57,16 @@ class NaturalIdentifierBinderSpec extends Specification { def mapping = Mock(Mapping.class) def identity = Mock(Identity) def naturalId = Mock(NaturalId) - def property1 = Mock(Property) + def property1 =new Property() + property1.setName("id1") def value1 = Mock(Value) - def column1 = Mock(Column, name: 'id1') - def property2 = Mock(Property) + property1.setValue(value1) + def column1 = new Column('id1') + def property2 = new Property() + property2.setName("id2") def value2 = Mock(Value) - def column2 = Mock(Column, name: 'id2') + property2.setValue(value2) + def column2 = new Column('id2') Table table = Mock(Table) mapping.getIdentity() >> identity @@ -68,14 +74,13 @@ class NaturalIdentifierBinderSpec extends Specification { naturalId.getPropertyNames() >> ["id1", "id2"] naturalId.isMutable() >> true - def rootClass = Mock(RootClass) - rootClass.getProperty("id1") >> property1 - rootClass.getProperty("id2") >> property2 + def rootClass = new RootClass(getGrailsDomainBinder().getMetadataBuildingContext()) + rootClass.setTable(table) + rootClass.addProperty(property1) + rootClass.addProperty(property2) rootClass.getTable() >> table - property1.getValue() >> value1 value1.getSelectables() >> [column1] - property2.getValue() >> value2 value2.getSelectables() >> [column2] def uniqueNameGenerator = Mock(UniqueNameGenerator) @@ -85,8 +90,8 @@ class NaturalIdentifierBinderSpec extends Specification { binder.bindNaturalIdentifier(mapping, rootClass) then: - 1 * property1.setNaturalIdentifier(true) - 1 * property2.setNaturalIdentifier(true) + property1.isNaturalIdentifier() + property2.isNaturalIdentifier() 1 * table.addUniqueKey(_) >> { uks -> def uk = uks.get(0) as UniqueKey assert uk.getColumnSpan() == 2 @@ -99,7 +104,7 @@ class NaturalIdentifierBinderSpec extends Specification { given: def mapping = Mock(Mapping.class) def identity = Mock(Identity) - def rootClass = Mock(RootClass) + def rootClass = new RootClass(getGrailsDomainBinder().getMetadataBuildingContext()) def uniqueNameGenerator = Mock(UniqueNameGenerator) def binder = new NaturalIdentifierBinder(uniqueNameGenerator) @@ -110,7 +115,6 @@ class NaturalIdentifierBinderSpec extends Specification { binder.bindNaturalIdentifier(mapping, rootClass) then: - 0 * rootClass._ 0 * uniqueNameGenerator._ } @@ -119,15 +123,14 @@ class NaturalIdentifierBinderSpec extends Specification { def mapping = Mock(Mapping.class) def identity = Mock(Identity) def naturalId = Mock(NaturalId) - def rootClass = Mock(RootClass) + def rootClass = new RootClass(getGrailsDomainBinder().getMetadataBuildingContext()) def uniqueNameGenerator = Mock(UniqueNameGenerator) def binder = new NaturalIdentifierBinder(uniqueNameGenerator) Table table = Mock(Table) mapping.getIdentity() >> identity identity.getNatural() >> naturalId naturalId.getPropertyNames() >> ["nonExistentProperty"] - rootClass.getProperty("nonExistentProperty") >> null - rootClass.getTable() >> table + rootClass.setTable(table) when: binder.bindNaturalIdentifier(mapping, rootClass) diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/NumericColumnConstraintsBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/NumericColumnConstraintsBinderSpec.groovy index 94115936d3..d7cd89b2b1 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/NumericColumnConstraintsBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/NumericColumnConstraintsBinderSpec.groovy @@ -17,7 +17,7 @@ class NumericColumnConstraintsBinderSpec extends Specification { void "should use scale and precision from ColumnConfig when provided"() { given: "A column config with explicit scale and precision" - def column = Mock(Column, name: 'test') + def column = new Column('test') def property = Mock(PersistentProperty) def columnConfig = new ColumnConfig(scale: 4, precision: 12) @@ -25,14 +25,13 @@ class NumericColumnConstraintsBinderSpec extends Specification { binder.bindNumericColumnConstraints(column, columnConfig, Mock(PropertyConfig)) then: "The column's scale and precision are set directly from the column config" - 1 * column.setScale(4) - 1 * column.setPrecision(12) - 0 * column.setPrecision(org.hibernate.engine.jdbc.Size.DEFAULT_PRECISION) + column.scale == 4 + column.precision == 12 } void "should use scale from PropertyConfig when ColumnConfig is not provided"() { given: "A property config with a scale constraint" - def column = Mock(Column, name: 'test') + def column = new Column('test') def propertyConfig = Mock(PropertyConfig) propertyConfig.getScale() >> 3 @@ -40,13 +39,13 @@ class NumericColumnConstraintsBinderSpec extends Specification { binder.bindNumericColumnConstraints(column, null, propertyConfig) then: "The column's scale is set from the property config" - 1 * column.setScale(3) + column.scale == 3 } @Unroll void "should calculate precision based on min=#minVal, max=#maxVal, and scale=#scale"() { given: "A property config with various min/max/scale constraints" - def column = Mock(Column, name: 'test') + def column = new Column('test') def propertyConfig = Mock(PropertyConfig) propertyConfig.getScale() >> scale @@ -57,14 +56,11 @@ class NumericColumnConstraintsBinderSpec extends Specification { binder.bindNumericColumnConstraints(column, null, propertyConfig) then: "The precision is calculated correctly and set on the column" - 1 * column.setPrecision(expectedPrecision) + column.precision == expectedPrecision and: "the scale is set correctly based on whether it was provided" if (scale > -1) { - 1 * column.setScale(scale) - } - else { - 0 * column.setScale(_) + assert column.scale == scale } where: @@ -90,7 +86,7 @@ class NumericColumnConstraintsBinderSpec extends Specification { void "should use default precision and scale when no constraints are provided"() { given: "A property config with no relevant constraints" - def column = Mock(Column, name: 'test') + def column = new Column('test') def propertyConfig = Mock(PropertyConfig) def defaultPrecision = org.hibernate.engine.jdbc.Size.DEFAULT_PRECISION // 19 def defaultScale = org.hibernate.engine.jdbc.Size.DEFAULT_SCALE // 0 @@ -103,12 +99,11 @@ class NumericColumnConstraintsBinderSpec extends Specification { binder.bindNumericColumnConstraints(column, null, propertyConfig) then: "The column's precision and scale are set to their defaults" - 1 * column.setPrecision(defaultPrecision) + column.precision == defaultPrecision // The code sets the default scale only if no other scale is found. // The initial value of the local 'scale' variable is the default. // The code doesn't explicitly call setScale(DEFAULT_SCALE). // This is a subtle point, the test should reflect what the code *does*. // The code only calls setScale if a constraint is found. - 0 * column.setScale(_) } } diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/StringColumnConstraintsBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/StringColumnConstraintsBinderSpec.groovy index 1d06e1e605..0650ed515c 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/StringColumnConstraintsBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/StringColumnConstraintsBinderSpec.groovy @@ -12,7 +12,7 @@ class StringColumnConstraintsBinderSpec extends Specification { def setup() { binder = new StringColumnConstraintsBinder() - column = Mock(Column, name: "test") + column = new Column("test") mappedForm = Mock(Property) } @@ -20,24 +20,26 @@ class StringColumnConstraintsBinderSpec extends Specification { given: mappedForm.getMaxSize() >> null mappedForm.getInList() >> null + int originalLength = column.length when: binder.bindStringColumnConstraints(column, mappedForm) then: - 0 * column.setLength(_) + column.length == originalLength } def "should not set column length when empty list"() { given: mappedForm.getMaxSize() >> null mappedForm.getInList() >> [] + int originalLength = column.length when: binder.bindStringColumnConstraints(column, mappedForm) then: - 0 * column.setLength(_) + column.length == originalLength } def "should set column length when maxSize is provided"() { @@ -49,7 +51,7 @@ class StringColumnConstraintsBinderSpec extends Specification { binder.bindStringColumnConstraints(column, mappedForm) then: - 1 * column.setLength(255) + column.length == 255 } def "should set column length to longest inList value when maxSize is null"() { @@ -61,7 +63,7 @@ class StringColumnConstraintsBinderSpec extends Specification { binder.bindStringColumnConstraints(column, mappedForm) then: - 1 * column.setLength(4) // length of "very long string" + column.length == 4 // length of "very long string" - preserving original expectation } def "should set column length to longest valid int inList value when maxSize is null"() { @@ -73,7 +75,7 @@ class StringColumnConstraintsBinderSpec extends Specification { binder.bindStringColumnConstraints(column, mappedForm) then: - 1 * column.setLength(4) // length of "very long string" + column.length == 4 // length of "very long string" - preserving original expectation } @@ -86,19 +88,20 @@ class StringColumnConstraintsBinderSpec extends Specification { binder.bindStringColumnConstraints(column, mappedForm) then: - 1 * column.setLength(1) + column.length == 1 } def "should handle zero maxSize"() { given: mappedForm.getMaxSize() >> 0 mappedForm.getInList() >> null + int originalLength = column.length when: binder.bindStringColumnConstraints(column, mappedForm) then: - 0 * column.setLength(_) + column.length == originalLength } @@ -111,6 +114,6 @@ class StringColumnConstraintsBinderSpec extends Specification { binder.bindStringColumnConstraints(column, mappedForm) then: - 1 * column.setLength(50) + column.length == 50 } } \ No newline at end of file diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/UniqueNameGeneratorSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/UniqueNameGeneratorSpec.groovy index 143c278122..97ab3574ee 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/UniqueNameGeneratorSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/UniqueNameGeneratorSpec.groovy @@ -20,13 +20,11 @@ class UniqueNameGeneratorSpec extends Specification { def "should generate a unique name based on table and column names and truncate it"() { given: "A unique key with a table and several columns" def table = Mock(Table) - def column1 = Mock(Column, name: 'first_name') - def column2 = Mock(Column, name: 'last_name') + def column1 = new Column('first_name') + def column2 = new Column('last_name') def uniqueKey = Mock(UniqueKey) table.getName() >> "person" - column1.getName() >> "first_name" - column2.getName() >> "last_name" uniqueKey.getTable() >> table uniqueKey.getColumns() >> [column1, column2] @@ -44,11 +42,10 @@ class UniqueNameGeneratorSpec extends Specification { def "should not truncate a generated name that is 30 characters or less"() { given: "A unique key whose hash results in a short name" def table = Mock(Table) - def column = Mock(Column, name: 'short_col') + def column = new Column('short_col') def uniqueKey = Mock(UniqueKey) table.getName() >> "short_table" - column.getName() >> "short_col" uniqueKey.getTable() >> table uniqueKey.getColumns() >> [column] @@ -99,15 +96,12 @@ class UniqueNameGeneratorSpec extends Specification { def "should filter out columns with blank or null names"() { given: "A unique key with valid, blank, and null column names" def table = Mock(Table) - def column1 = Mock(Column, name: 'sku') - def column2 = Mock(Column, name: '') - def column3 = Mock(Column, name: null) + def column1 = new Column('sku') + def column2 = new Column('') + def column3 = new Column(null) def uniqueKey = Mock(UniqueKey) table.getName() >> "product" - column1.getName() >> "sku" - column2.getName() >> "" // Blank name - column3.getName() >> null // Null name uniqueKey.getTable() >> table uniqueKey.getColumns() >> [column1, column2, column3]
