I am new to the meta model internals of Hibernate, please bear with me.
I am working in processElementAnnotations to use the new VersionColumnSupport to add
Dialect based defaults to the meta model – but I seem to be looking at this wrong.
Is there a test case, commit, or other documentation I can review to review as an
example?
Basically, if the Dialect says so (e.g. SQL Server @Version on Long) and the author of the
Entity does not specify conflicting configuration
Add to the meta model:
@Source(value = SourceType.DBLONG)
@ColumnTransformer(read = "CAST(… as BIGINT)")
@Column(columnDefinition = "rowversion", nullable = false, insertable = false,
updatable = false)
@Generated(GenerationTime.ALWAYS)
I was updating the Column in the SimpleValue, but that did not get reflected in the
runtime behavior – it only helped with schema generation.
commit 682fcbab75b8b055c676c7a4de1247a888b23e9c (HEAD -> HHH-14736,
pdinc-oss/HHH-14736) -
https://github.com/pdinc-oss/hibernate-orm/tree/HHH-14736
Author: Jason Pyeron <jpyeron(a)pdinc.us>
Date: Tue Jul 20 00:56:38 2021 -0400
HHH-14736 WIP: SQL Server @Version test cases (fails as expected)
* SQL Server 2016 dialect defaults to the new behavior, older version require it to be
turned on
* added VersionColumnSupport to Dialect
* added SQLServerLongRowVersionType / SQLServerBinaryRowVersionType (was:
SQLServerRowVersionType)
* when non-JPA annotations are allied, all tests pass
TODO:
1: update meta model to imply @ColumnTransformer(read = "CAST(...columnName... as
BIGINT)")
2: update meta model to imply @Column(columnDefinition = "rowversion"), the
create SQL already works
3: update meta model to imply @Column(nullable = false)
4: update meta model to imply @Column(insertable = false, updatable = false)
5: update meta model to imply @Generated(GenerationTime.ALWAYS)
6: need test case for setting SQLServer2012 dialect to use new features
7: address HqlSqlWalker.isDatabaseGeneratedTimestamp() - needs test case and possible
code
M hibernate-core/src/main/java/org/hibernate/annotations/SourceType.java
M hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
M hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java
M hibernate-core/src/main/java/org/hibernate/dialect/SQLServer2005Dialect.java
M hibernate-core/src/main/java/org/hibernate/dialect/SQLServer2016Dialect.java
M hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java
A
hibernate-core/src/main/java/org/hibernate/dialect/version/DefaultNoOpVersionColumnSupportImpl.java
A
hibernate-core/src/main/java/org/hibernate/dialect/version/SQLServerVersionColumnSupport.java
A
hibernate-core/src/main/java/org/hibernate/dialect/version/VersionColumnSupport.java
M hibernate-core/src/main/java/org/hibernate/hql/internal/ast/HqlSqlWalker.java
M
hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java
M hibernate-core/src/main/java/org/hibernate/type/BasicTypeRegistry.java
M hibernate-core/src/main/java/org/hibernate/type/RowVersionType.java
A
hibernate-core/src/main/java/org/hibernate/type/SQLServerBinaryRowVersionType.java
A hibernate-core/src/main/java/org/hibernate/type/SQLServerLongRowVersionType.java
M
hibernate-core/src/test/java/org/hibernate/test/annotations/various/TimestampTest.java
A
hibernate-core/src/test/java/org/hibernate/test/optlock/OptimisticLockHHH14736SQLServerJPAOnlyTest.java
A
hibernate-core/src/test/java/org/hibernate/test/optlock/OptimisticLockHHH14736Test.java
-Jason
--
Jason Pyeron | Architect
Contractor |
PD Inc | Certified SBA 8(a)
10 w 24th St | Certified SBA HUBZone
Baltimore, MD | CAGE Code: 1WVR6
.com: <mailto:jpyeron@pdinc.us> jpyeron(a)pdinc.us
tel : 202-741-9397