Skip to content

Commit ab8d655

Browse files
committed
add clarifications as recommended by @sebersole
1 parent b0b73db commit ab8d655

File tree

6 files changed

+29
-21
lines changed

6 files changed

+29
-21
lines changed

hibernate-core/src/main/java/org/hibernate/LockMode.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,33 @@
3535
* and does not force a version increment.
3636
* <p>
3737
* When an entity is read from the database, its lock mode
38-
* determines whether lost updates and non-repeatable reads
39-
* are possible.
38+
* determines whether lost updates and non-repeatable reads are
39+
* possible. Assuming the underlying transaction isolation
40+
* {@linkplain java.sql.Connection#getTransactionIsolation level}
41+
* of the current JDBC database connection is at least
42+
* {@linkplain java.sql.Connection#TRANSACTION_READ_COMMITTED
43+
* read committed}, then:
4044
* <ul>
4145
* <li>{@link #NONE} and {@link #READ} prevent lost updates
4246
* only for versioned entities, but do not prevent
4347
* non-repeatable reads, and do not prevent lost updates
44-
* for entities with no version attribute.
48+
* for entities with no version attribute;
4549
* <li>{@link #OPTIMISTIC} and {@link #OPTIMISTIC_FORCE_INCREMENT}
4650
* prevent lost updates and non-repeatable reads only for
47-
* versioned entities.
51+
* versioned entities;
4852
* <li>{@link #PESSIMISTIC_READ}, {@link #PESSIMISTIC_WRITE},
4953
* and {@link #PESSIMISTIC_FORCE_INCREMENT} prevent lost
5054
* updates and non-repeatable reads for all entities,
5155
* including entities with no version attribute.
5256
* </ul>
5357
* <p>
58+
* Regardless of the lock mode of a given entity, a non-repeatable
59+
* read is always possible when {@link Session#refresh(Object)}
60+
* is called for that entity, except when the underlying transaction
61+
* isolation level of the current JDBC database connection is at
62+
* least {@linkplain java.sql.Connection#TRANSACTION_REPEATABLE_READ
63+
* repeatable read}.
64+
* <p>
5465
* This enumeration of lock modes competes with the JPA-defined
5566
* {@link LockModeType}, but offers additional options, including
5667
* {@link #UPGRADE_NOWAIT} and {@link #UPGRADE_SKIPLOCKED}.

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)