Skip to content

Commit 66a030e

Browse files
committed
misc minor code changes
1 parent 7a7910c commit 66a030e

File tree

9 files changed

+35
-39
lines changed

9 files changed

+35
-39
lines changed

hibernate-core/src/main/java/org/hibernate/action/internal/EntityIncrementVersionProcess.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public EntityIncrementVersionProcess(Object object) {
3535
@Override
3636
public void doBeforeTransactionCompletion(SharedSessionContractImplementor session) {
3737
final var entry = session.getPersistenceContext().getEntry( object );
38-
// Don't increment the version for an entity that is not in the PersistenceContext;
38+
// Don't increment the version for an entity that is not in the PersistenceContext
3939
if ( entry != null ) {
4040
OptimisticLockHelper.forceVersionIncrement( object, entry, session.asEventSource() );
4141
}

hibernate-core/src/main/java/org/hibernate/action/internal/EntityVerifyVersionProcess.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import org.hibernate.action.spi.BeforeTransactionCompletionProcess;
88
import org.hibernate.dialect.lock.OptimisticEntityLockException;
99
import org.hibernate.engine.spi.SharedSessionContractImplementor;
10-
import org.hibernate.pretty.MessageHelper;
10+
11+
import static org.hibernate.pretty.MessageHelper.infoString;
1112

1213
/**
1314
* A {@link BeforeTransactionCompletionProcess} impl to verify an entity
@@ -40,7 +41,7 @@ public void doBeforeTransactionCompletion(SharedSessionContractImplementor sessi
4041
"Newer version ["
4142
+ latestVersion
4243
+ "] of entity ["
43-
+ MessageHelper.infoString( entry.getEntityName(), entry.getId() )
44+
+ infoString( entry.getEntityName(), entry.getId() )
4445
+ "] found in database"
4546
);
4647
}

hibernate-core/src/main/java/org/hibernate/cfg/MappingSettings.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,12 @@ public interface MappingSettings {
278278
String PREFER_NATIVE_ENUM_TYPES = "hibernate.type.prefer_native_enum_types";
279279

280280
/**
281-
* Indicates whether {@link Locale#toLanguageTag()} should be preferred over {@link Locale#toString()}
282-
* when converting a value to a {@linkplain String}.
281+
* Indicates whether {@link Locale#toLanguageTag()} should be preferred over
282+
* {@link Locale#toString()} when converting a {@code Locale} to a {@code String}.
283283
* <p/>
284284
* This configuration property is used to specify a global preference,
285285
* but Hibernate ORM can always read both formats, so no data needs to be migrated.
286-
* The setting simply configures how {@link Locale} data is to be stored.
286+
* The setting only affects how {@link Locale} data is stored.
287287
*
288288
* @settingDefault false
289289
*

hibernate-core/src/main/java/org/hibernate/internal/OptimisticLockHelper.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55
package org.hibernate.internal;
66

7-
import org.hibernate.CacheMode;
87
import org.hibernate.action.spi.AfterTransactionCompletionProcess;
98
import org.hibernate.cache.spi.access.EntityDataAccess;
109
import org.hibernate.cache.spi.access.SoftLock;
@@ -13,9 +12,9 @@
1312
import org.hibernate.engine.spi.Status;
1413
import org.hibernate.event.monitor.spi.EventMonitor;
1514
import org.hibernate.persister.entity.EntityPersister;
16-
import org.hibernate.stat.internal.StatsHelper;
1715

1816
import static org.hibernate.cache.spi.entry.CacheEntryHelper.buildStructuredCacheEntry;
17+
import static org.hibernate.stat.internal.StatsHelper.getRootEntityRole;
1918

2019
public final class OptimisticLockHelper {
2120

@@ -53,14 +52,15 @@ public static void forceVersionIncrement(Object object, EntityEntry entry, Share
5352
persister,
5453
session
5554
);
56-
session.getTransactionCompletionCallbacks().registerCallback( new CacheCleanupProcess(
57-
cacheKey,
58-
persister,
59-
previousVersion,
60-
nextVersion,
61-
lock,
62-
cacheEntry
63-
) );
55+
session.getTransactionCompletionCallbacks()
56+
.registerCallback( new CacheCleanupProcess(
57+
cacheKey,
58+
persister,
59+
previousVersion,
60+
nextVersion,
61+
lock,
62+
cacheEntry
63+
) );
6464
}
6565
}
6666

@@ -80,11 +80,10 @@ else if ( session.getCacheMode().isPutEnabled() ) {
8080
final Object cacheEntry =
8181
buildStructuredCacheEntry( entity, nextVersion, entry.getLoadedState(), persister, session );
8282
final boolean put = updateCache( persister, cacheEntry, previousVersion, nextVersion, cacheKey, session );
83-
8483
final var statistics = session.getFactory().getStatistics();
8584
if ( put && statistics.isStatisticsEnabled() ) {
8685
statistics.entityCachePut(
87-
StatsHelper.getRootEntityRole( persister ),
86+
getRootEntityRole( persister ),
8887
persister.getCacheAccessStrategy().getRegion().getName()
8988
);
9089
}
@@ -126,10 +125,9 @@ private static boolean updateCache(
126125
private static boolean isCacheInvalidationRequired(
127126
EntityPersister persister,
128127
SharedSessionContractImplementor session) {
129-
// the cache has to be invalidated when CacheMode is equal to GET or IGNORE
130128
return persister.isCacheInvalidationRequired()
131-
|| session.getCacheMode() == CacheMode.GET
132-
|| session.getCacheMode() == CacheMode.IGNORE;
129+
// the cache has to be invalidated when CacheMode is GET or IGNORE
130+
|| !session.getCacheMode().isPutEnabled();
133131
}
134132

135133
private static class CacheCleanupProcess implements AfterTransactionCompletionProcess {
@@ -193,7 +191,7 @@ protected void cacheAfterUpdate(EntityDataAccess cache, Object cacheKey, SharedS
193191
final var statistics = session.getFactory().getStatistics();
194192
if ( put && statistics.isStatisticsEnabled() ) {
195193
statistics.entityCachePut(
196-
StatsHelper.getRootEntityRole( persister ),
194+
getRootEntityRole( persister ),
197195
cache.getRegion().getName()
198196
);
199197
}

hibernate-core/src/main/java/org/hibernate/internal/util/beans/BeanInfoHelper.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ public interface ReturningBeanInfoDelegate<T> {
2222
T processBeanInfo(BeanInfo beanInfo) throws Exception;
2323
}
2424

25-
private final Class beanClass;
26-
private final Class stopClass;
25+
private final Class<?> beanClass;
26+
private final Class<?> stopClass;
2727

28-
public BeanInfoHelper(Class beanClass) {
28+
public BeanInfoHelper(Class<?> beanClass) {
2929
this( beanClass, Object.class );
3030
}
3131

32-
public BeanInfoHelper(Class beanClass, Class stopClass) {
32+
public BeanInfoHelper(Class<?> beanClass, Class<?> stopClass) {
3333
this.beanClass = beanClass;
3434
this.stopClass = stopClass;
3535
}
@@ -46,7 +46,7 @@ public static void visitBeanInfo(Class<?> beanClass, BeanInfoDelegate delegate)
4646
visitBeanInfo( beanClass, Object.class, delegate );
4747
}
4848

49-
public static void visitBeanInfo(Class beanClass, Class stopClass, BeanInfoDelegate delegate) {
49+
public static void visitBeanInfo(Class<?> beanClass, Class<?> stopClass, BeanInfoDelegate delegate) {
5050
try {
5151
BeanInfo info = Introspector.getBeanInfo( beanClass, stopClass );
5252
try {
@@ -70,11 +70,11 @@ public static void visitBeanInfo(Class beanClass, Class stopClass, BeanInfoDeleg
7070
}
7171
}
7272

73-
public static <T> T visitBeanInfo(Class beanClass, ReturningBeanInfoDelegate<T> delegate) {
73+
public static <T> T visitBeanInfo(Class<?> beanClass, ReturningBeanInfoDelegate<T> delegate) {
7474
return visitBeanInfo( beanClass, null, delegate );
7575
}
7676

77-
public static <T> T visitBeanInfo(Class beanClass, Class stopClass, ReturningBeanInfoDelegate<T> delegate) {
77+
public static <T> T visitBeanInfo(Class<?> beanClass, Class<?> stopClass, ReturningBeanInfoDelegate<T> delegate) {
7878
try {
7979
BeanInfo info = Introspector.getBeanInfo( beanClass, stopClass );
8080
try {

hibernate-core/src/main/java/org/hibernate/internal/util/compare/ComparableComparator.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,17 @@
1313
* @author Gavin King
1414
* @author Steve Ebersole
1515
*/
16-
@SuppressWarnings("rawtypes")
17-
public class ComparableComparator<T extends Comparable> implements Comparator<T>, Serializable {
16+
public class ComparableComparator<T extends Comparable<T>> implements Comparator<T>, Serializable {
1817

18+
@SuppressWarnings("rawtypes")
1919
public static final Comparator INSTANCE = new ComparableComparator();
2020

2121
@SuppressWarnings("unchecked")
22-
public static <T extends Comparable> Comparator<T> instance() {
22+
public static <T extends Comparable<T>> Comparator<T> instance() {
2323
return INSTANCE;
2424
}
2525

26-
@SuppressWarnings("unchecked")
27-
public int compare(Comparable one, Comparable another) {
26+
public int compare(T one, T another) {
2827
return one.compareTo( another );
2928
}
3029
}

hibernate-core/src/main/java/org/hibernate/query/internal/ParameterMetadataImpl.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,7 @@ public Set<String> getNamedParameterNames() {
249249

250250
@Override
251251
public QueryParameterImplementor<?> findQueryParameter(String name) {
252-
if ( queryParametersByName == null ) {
253-
return null;
254-
}
255-
return queryParametersByName.get( name );
252+
return queryParametersByName == null ? null : queryParametersByName.get( name );
256253
}
257254

258255
@Override

hibernate-core/src/main/java/org/hibernate/type/descriptor/java/AbstractClassJavaType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ protected AbstractClassJavaType(Class<T> type) {
4444
* @param type The Java type.
4545
* @param mutabilityPlan The plan for handling mutability aspects of the java type.
4646
*/
47+
@SuppressWarnings("unchecked")
4748
protected AbstractClassJavaType(Class<T> type, MutabilityPlan<T> mutabilityPlan) {
4849
this(
4950
type,

hibernate-core/src/main/java/org/hibernate/type/descriptor/java/AbstractJavaType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected AbstractJavaType(Type type, MutabilityPlan<T> mutabilityPlan) {
5050
this.mutabilityPlan = mutabilityPlan;
5151
this.comparator =
5252
type != null && Comparable.class.isAssignableFrom( getJavaTypeClass() )
53-
? (Comparator<T>) ComparableComparator.INSTANCE
53+
? ComparableComparator.INSTANCE
5454
: null;
5555
}
5656

0 commit comments

Comments
 (0)