Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.hibernate.LockOptions;
import org.hibernate.boot.model.FunctionContributions;
import org.hibernate.boot.model.TypeContributions;
import org.hibernate.community.dialect.sequence.LegacyDB2SequenceSupport;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.DB2GetObjectExtractor;
import org.hibernate.dialect.DB2StructJdbcType;
Expand All @@ -47,7 +48,6 @@
import org.hibernate.dialect.pagination.LegacyDB2LimitHandler;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.sequence.DB2SequenceSupport;
import org.hibernate.dialect.sequence.LegacyDB2SequenceSupport;
import org.hibernate.dialect.sequence.SequenceSupport;
import org.hibernate.dialect.unique.AlterTableUniqueIndexDelegate;
import org.hibernate.dialect.unique.SkipNullableUniqueDelegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import org.hibernate.boot.model.FunctionContributions;
import org.hibernate.dialect.DatabaseVersion;
import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.identity.DB2390IdentityColumnSupport;
import org.hibernate.dialect.identity.DB2IdentityColumnSupport;
import org.hibernate.dialect.identity.DB2zIdentityColumnSupport;
import org.hibernate.dialect.identity.IdentityColumnSupport;
import org.hibernate.dialect.pagination.FetchLimitHandler;
import org.hibernate.dialect.pagination.LegacyDB2LimitHandler;
Expand Down Expand Up @@ -129,7 +129,7 @@ public LimitHandler getLimitHandler() {
public IdentityColumnSupport getIdentityColumnSupport() {
return getVersion().isSameOrAfter(7, 3)
? DB2IdentityColumnSupport.INSTANCE
: DB2390IdentityColumnSupport.INSTANCE;
: DB2zIdentityColumnSupport.INSTANCE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.hibernate.dialect.DatabaseVersion;
import org.hibernate.dialect.TimeZoneSupport;
import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.identity.DB2390IdentityColumnSupport;
import org.hibernate.dialect.identity.DB2zIdentityColumnSupport;
import org.hibernate.dialect.identity.IdentityColumnSupport;
import org.hibernate.dialect.pagination.FetchLimitHandler;
import org.hibernate.dialect.pagination.LimitHandler;
Expand Down Expand Up @@ -146,7 +146,7 @@ public LimitHandler getLimitHandler() {

@Override
public IdentityColumnSupport getIdentityColumnSupport() {
return DB2390IdentityColumnSupport.INSTANCE;
return DB2zIdentityColumnSupport.INSTANCE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ private static boolean isAnsiNull(DatabaseMetaData databaseMetaData) {
return false;
}

@Override
public boolean isAnsiNullOn() {
return ansiNull;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ protected void renderComparison(Expression lhs, ComparisonOperator operator, Exp
}
}
// I think intersect is only supported in 16.0 SP3
if ( getDialect().isAnsiNullOn() ) {
if ( ( (SybaseASELegacyDialect) getDialect() ).isAnsiNullOn() ) {
if ( isLob ) {
switch ( operator ) {
case DISTINCT_FROM:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.dialect.sequence;
package org.hibernate.community.dialect.sequence;

import org.hibernate.MappingException;
import org.hibernate.dialect.sequence.SequenceSupport;

/**
* Sequence support for {@link org.hibernate.dialect.DB2Dialect}.
*
* @author Gavin King
*
* @deprecated use {@code DB2SequenceSupport}
*/
@Deprecated(since="6.4")
public class LegacyDB2SequenceSupport implements SequenceSupport {

public static final SequenceSupport INSTANCE = new LegacyDB2SequenceSupport();
Expand Down Expand Up @@ -42,4 +40,4 @@ public String getSequencePreviousValString(String sequenceName) throws MappingEx
public String getDropSequenceString(String sequenceName) {
return "drop sequence " + sequenceName + " restrict";
}
}
}
14 changes: 0 additions & 14 deletions hibernate-core/src/main/java/org/hibernate/annotations/Cache.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,4 @@
* @see LazyGroup
*/
boolean includeLazy() default true;

/**
* When bytecode enhancement is used, and {@linkplain LazyGroup
* field-level lazy fetching} is enabled, specifies which attributes
* of the entity are included in the second-level cache, either:
* <ul>
* <li>{@code "all"} properties, the default, or
* <li>only {@code "non-lazy"} properties.
* </ul>
*
* @deprecated Use {@link #includeLazy()} for the sake of typesafety.
*/
@Deprecated(since="6.4")
String include() default "all";
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -127,7 +126,6 @@
import jakarta.persistence.PrimaryKeyJoinColumns;
import jakarta.persistence.SecondaryTable;
import jakarta.persistence.SecondaryTables;
import jakarta.persistence.SharedCacheMode;
import jakarta.persistence.UniqueConstraint;

import static jakarta.persistence.InheritanceType.SINGLE_TABLE;
Expand Down Expand Up @@ -1639,24 +1637,24 @@ public void setWrapIdsInEmbeddedComponents(boolean wrapIdsInEmbeddedComponents)
}

private void bindNaturalIdCache() {
naturalIdCacheRegion = null;
final NaturalIdCache naturalIdCacheAnn =
annotatedClass.getAnnotationUsage( NaturalIdCache.class, getSourceModelContext() );
if ( naturalIdCacheAnn == null ) {
return;
}

final String region = naturalIdCacheAnn.region();
if ( region.isBlank() ) {
final Cache explicitCacheAnn = annotatedClass.getAnnotationUsage( Cache.class, getSourceModelContext() );

naturalIdCacheRegion =
explicitCacheAnn != null && isNotBlank( explicitCacheAnn.region() )
? explicitCacheAnn.region() + NATURAL_ID_CACHE_SUFFIX
: annotatedClass.getName() + NATURAL_ID_CACHE_SUFFIX;
if ( naturalIdCacheAnn != null ) {
final String region = naturalIdCacheAnn.region();
if ( region.isBlank() ) {
final Cache explicitCacheAnn =
annotatedClass.getAnnotationUsage( Cache.class, getSourceModelContext() );
naturalIdCacheRegion =
explicitCacheAnn != null && isNotBlank( explicitCacheAnn.region() )
? explicitCacheAnn.region() + NATURAL_ID_CACHE_SUFFIX
: annotatedClass.getName() + NATURAL_ID_CACHE_SUFFIX;
}
else {
naturalIdCacheRegion = naturalIdCacheAnn.region();
}
}
else {
naturalIdCacheRegion = naturalIdCacheAnn.region();
naturalIdCacheRegion = null;
}
}

Expand All @@ -1666,16 +1664,15 @@ private void bindCache() {
cacheRegion = null;
cacheLazyProperty = true;
queryCacheLayout = null;
final SharedCacheMode sharedCacheMode = context.getBuildingOptions().getSharedCacheMode();
if ( persistentClass instanceof RootClass ) {
bindRootClassCache( sharedCacheMode, context );
if ( isRootEntity() ) {
bindRootClassCache();
}
else {
bindSubclassCache( sharedCacheMode );
bindSubclassCache();
}
}

private void bindSubclassCache(SharedCacheMode sharedCacheMode) {
private void bindSubclassCache() {
if ( annotatedClass.hasAnnotationUsage( Cache.class, getSourceModelContext() ) ) {
final String className = persistentClass.getClassName() == null
? annotatedClass.getName()
Expand All @@ -1691,46 +1688,30 @@ private void bindSubclassCache(SharedCacheMode sharedCacheMode) {
? persistentClass.getSuperclass().isCached()
//TODO: is this even correct?
// Do we even correctly support selectively enabling caching on subclasses like this?
: isCacheable( sharedCacheMode, cacheable );
: isCacheable( cacheable );
}

private void bindRootClassCache(SharedCacheMode sharedCacheMode, MetadataBuildingContext context) {
final Cache cache = annotatedClass.getAnnotationUsage( Cache.class, getSourceModelContext() );
final Cacheable cacheable = annotatedClass.getAnnotationUsage( Cacheable.class, getSourceModelContext() );
final Cache effectiveCache;
if ( cache != null ) {
// preserve legacy behavior of circumventing SharedCacheMode when Hibernate's @Cache is used.
isCached = true;
effectiveCache = cache;
}
else {
effectiveCache = buildCacheMock( annotatedClass, context );
isCached = isCacheable( sharedCacheMode, cacheable );
}
private void bindRootClassCache() {
final SourceModelBuildingContext sourceModelContext = getSourceModelContext();

final Cache cache = annotatedClass.getAnnotationUsage( Cache.class, sourceModelContext );
final Cacheable cacheable = annotatedClass.getAnnotationUsage( Cacheable.class, sourceModelContext );

// preserve legacy behavior of circumventing SharedCacheMode when Hibernate @Cache is used
final Cache effectiveCache = cache != null ? cache : buildCacheMock( annotatedClass );
isCached = cache != null || isCacheable( cacheable );

cacheConcurrentStrategy = getCacheConcurrencyStrategy( effectiveCache.usage() );
cacheRegion = effectiveCache.region();
cacheLazyProperty = isCacheLazy( effectiveCache, annotatedClass );
cacheLazyProperty = effectiveCache.includeLazy();

final QueryCacheLayout queryCache =
annotatedClass.getAnnotationUsage( QueryCacheLayout.class, getSourceModelContext() );
annotatedClass.getAnnotationUsage( QueryCacheLayout.class, sourceModelContext );
queryCacheLayout = queryCache == null ? null : queryCache.layout();
}

private static boolean isCacheLazy(Cache effectiveCache, ClassDetails annotatedClass) {
if ( !effectiveCache.includeLazy() ) {
return false;
}
return switch ( effectiveCache.include().toLowerCase( Locale.ROOT ) ) {
case "all" -> true;
case "non-lazy" -> false;
default -> throw new AnnotationException(
"Class '" + annotatedClass.getName()
+ "' has a '@Cache' with undefined option 'include=\"" + effectiveCache.include() + "\"'" );
};
}

private static boolean isCacheable(SharedCacheMode sharedCacheMode, Cacheable explicitCacheableAnn) {
return switch ( sharedCacheMode ) {
private boolean isCacheable(Cacheable explicitCacheableAnn) {
return switch ( context.getBuildingOptions().getSharedCacheMode() ) {
case ALL ->
// all entities should be cached
true;
Expand All @@ -1747,15 +1728,15 @@ private static boolean isCacheable(SharedCacheMode sharedCacheMode, Cacheable ex
};
}

private static Cache buildCacheMock(ClassDetails classDetails, MetadataBuildingContext context) {
private Cache buildCacheMock(ClassDetails classDetails) {
final CacheAnnotation cacheUsage =
HibernateAnnotations.CACHE.createUsage( context.getMetadataCollector().getSourceModelBuildingContext() );
HibernateAnnotations.CACHE.createUsage( getSourceModelContext() );
cacheUsage.region( classDetails.getName() );
cacheUsage.usage( determineCacheConcurrencyStrategy( context ) );
cacheUsage.usage( determineCacheConcurrencyStrategy() );
return cacheUsage;
}

private static CacheConcurrencyStrategy determineCacheConcurrencyStrategy(MetadataBuildingContext context) {
private CacheConcurrencyStrategy determineCacheConcurrencyStrategy() {
return CacheConcurrencyStrategy.fromAccessType( context.getBuildingOptions().getImplicitCacheAccessType() );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ public class CacheAnnotation implements Cache {
private org.hibernate.annotations.CacheConcurrencyStrategy usage;
private String region;
private boolean includeLazy;
private String include;

/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public CacheAnnotation(SourceModelBuildingContext modelContext) {
this.region = "";
this.includeLazy = true;
this.include = "all";
}

/**
Expand All @@ -34,7 +32,6 @@ public CacheAnnotation(Cache annotation, SourceModelBuildingContext modelContext
this.usage = annotation.usage();
this.region = annotation.region();
this.includeLazy = annotation.includeLazy();
this.include = annotation.include();
}

/**
Expand All @@ -44,7 +41,6 @@ public CacheAnnotation(Map<String, Object> attributeValues, SourceModelBuildingC
this.usage = (org.hibernate.annotations.CacheConcurrencyStrategy) attributeValues.get( "usage" );
this.region = (String) attributeValues.get( "region" );
this.includeLazy = (boolean) attributeValues.get( "includeLazy" );
this.include = (String) attributeValues.get( "include" );
}

@Override
Expand Down Expand Up @@ -81,15 +77,4 @@ public void includeLazy(boolean value) {
this.includeLazy = value;
}


@Override
public String include() {
return include;
}

public void include(String value) {
this.include = value;
}


}
11 changes: 0 additions & 11 deletions hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java
Original file line number Diff line number Diff line change
Expand Up @@ -3820,17 +3820,6 @@ public boolean supportsNullPrecedence() {
return true;
}

/**
* A setting specific to {@link SybaseASEDialect}.
*
* @deprecated This is only called from {@link SybaseASESqlAstTranslator}
* so it doesn't need to be declared here.
*/
@Deprecated(since = "6")
public boolean isAnsiNullOn() {
return true;
}

/**
* Does this dialect/database require casting of non-string arguments
* in the {@code concat()} function?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1052,11 +1052,6 @@ public boolean supportsNullPrecedence() {
return wrapped.supportsNullPrecedence();
}

@Override
@Deprecated(since = "6")
public boolean isAnsiNullOn() {
return wrapped.isAnsiNullOn();
}

@Override
public boolean requiresCastForConcatenatingNonStrings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ private int pageSize(DialectResolutionInfo info) {
return getInt( SYBASE_PAGE_SIZE, info.getConfigurationValues(), MAX_PAGE_SIZE );
}

@Override
public boolean isAnsiNullOn() {
return ansiNull;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ protected void renderComparison(Expression lhs, ComparisonOperator operator, Exp
}
}
// I think intersect is only supported in 16.0 SP3
if ( getDialect().isAnsiNullOn() ) {
if ( ( (SybaseASEDialect) getDialect() ).isAnsiNullOn() ) {
if ( isLob ) {
switch ( operator ) {
case DISTINCT_FROM:
Expand Down

This file was deleted.

Loading
Loading