Skip to content

Commit 5b3c6c4

Browse files
committed
continued work on replacing LoadPlan with SQL AST approach - cleanup;
change expected type of entity identifier values from Serializable to Object
1 parent e522cbe commit 5b3c6c4

File tree

221 files changed

+1300
-1456
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+1300
-1456
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77
package org.hibernate;
88

9-
import java.io.Serializable;
109
import java.util.Optional;
1110

1211
import org.hibernate.graph.GraphSemantic;
@@ -55,7 +54,7 @@ default IdentifierLoadAccess<T> with(RootGraph<T> graph) {
5554
*
5655
* @return the persistent instance or proxy
5756
*/
58-
T getReference(Serializable id);
57+
T getReference(Object id);
5958

6059
/**
6160
* Return the persistent instance with the given identifier, or null if there is no such persistent instance.
@@ -66,7 +65,7 @@ default IdentifierLoadAccess<T> with(RootGraph<T> graph) {
6665
*
6766
* @return The persistent instance or {@code null}
6867
*/
69-
T load(Serializable id);
68+
T load(Object id);
7069

7170
/**
7271
* Same semantic as {@link #load} except that here {@link Optional} is returned to
@@ -76,5 +75,5 @@ default IdentifierLoadAccess<T> with(RootGraph<T> graph) {
7675
*
7776
* @return The persistent instance, if one, wrapped in Optional
7877
*/
79-
Optional<T> loadOptional(Serializable id);
78+
Optional<T> loadOptional(Object id);
8079
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77
package org.hibernate;
88

9-
import java.io.Serializable;
109
import java.util.List;
1110

1211
import org.hibernate.graph.GraphSemantic;
@@ -107,12 +106,12 @@ default MultiIdentifierLoadAccess<T> with(RootGraph<T> graph) {
107106
* and {@link #enableReturnOfDeletedEntities} for options which effect
108107
* the size and "shape" of the return list.
109108
*
110-
* @param ids The ids to load
111109
* @param <K> The identifier type
112110
*
111+
* @param ids The ids to load
113112
* @return The persistent entities.
114113
*/
115-
<K extends Serializable> List<T> multiLoad(K... ids);
114+
<K> List<T> multiLoad(K... ids);
116115

117116
/**
118117
* Perform a load of multiple entities by identifiers. See {@link #enableOrderedReturn}
@@ -124,5 +123,5 @@ default MultiIdentifierLoadAccess<T> with(RootGraph<T> graph) {
124123
*
125124
* @return The persistent entities.
126125
*/
127-
<K extends Serializable> List<T> multiLoad(List<K> ids);
126+
<K> List<T> multiLoad(List<K> ids);
128127
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77
package org.hibernate;
88

9-
import java.io.Serializable;
109
import java.util.Optional;
1110

1211
/**

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,27 @@
1818
* @author Gavin King
1919
*/
2020
public class NonUniqueObjectException extends HibernateException {
21-
private final Serializable identifier;
21+
private final Object identifier;
2222
private final String entityName;
2323

2424
/**
2525
* Constructs a NonUniqueObjectException using the given information.
26-
*
27-
* @param message A message explaining the exception condition
26+
* @param message A message explaining the exception condition
2827
* @param entityId The identifier of the entity
2928
* @param entityName The name of the entity
3029
*/
31-
public NonUniqueObjectException(String message, Serializable entityId, String entityName) {
30+
public NonUniqueObjectException(String message, Object entityId, String entityName) {
3231
super( message );
3332
this.entityName = entityName;
3433
this.identifier = entityId;
3534
}
3635

3736
/**
3837
* Constructs a NonUniqueObjectException using the given information, using a standard message.
39-
*
40-
* @param entityId The identifier of the entity
38+
* @param entityId The identifier of the entity
4139
* @param entityName The name of the entity
4240
*/
43-
public NonUniqueObjectException(Serializable entityId, String entityName) {
41+
public NonUniqueObjectException(Object entityId, String entityName) {
4442
this(
4543
"A different object with the same identifier value was already associated with the session",
4644
entityId,
@@ -52,7 +50,7 @@ public String getEntityName() {
5250
return entityName;
5351
}
5452

55-
public Serializable getIdentifier() {
53+
public Object getIdentifier() {
5654
return identifier;
5755
}
5856

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
*/
77
package org.hibernate;
88

9-
import java.io.Serializable;
10-
119
/**
1210
* Thrown when the user tries to do something illegal with a deleted object.
1311
*
@@ -16,12 +14,11 @@
1614
public class ObjectDeletedException extends UnresolvableObjectException {
1715
/**
1816
* Constructs an ObjectDeletedException using the given information.
19-
*
20-
* @param message A message explaining the exception condition
17+
* @param message A message explaining the exception condition
2118
* @param identifier The identifier of the entity
2219
* @param entityName The name of the entity
2320
*/
24-
public ObjectDeletedException(String message, Serializable identifier, String entityName) {
21+
public ObjectDeletedException(String message, Object identifier, String entityName) {
2522
super( message, identifier, entityName );
2623
}
2724

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
*/
77
package org.hibernate;
88

9-
import java.io.Serializable;
10-
119
/**
1210
* Thrown when <tt>Session.load()</tt> fails to select a row with
1311
* the given primary key (identifier value). This exception might not
@@ -24,11 +22,14 @@
2422
public class ObjectNotFoundException extends UnresolvableObjectException {
2523
/**
2624
* Constructs a ObjectNotFoundException using the given information.
27-
*
28-
* @param identifier The identifier of the entity
25+
* @param identifier The identifier of the entity
2926
* @param entityName The name of the entity
3027
*/
31-
public ObjectNotFoundException(Serializable identifier, String entityName) {
28+
public ObjectNotFoundException(Object identifier, String entityName) {
3229
super( identifier, entityName );
3330
}
31+
32+
public ObjectNotFoundException(String entityName, Object identifier) {
33+
this( identifier, entityName );
34+
}
3435
}

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

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.hibernate.graph.RootGraph;
2121
import org.hibernate.jdbc.ReturningWork;
2222
import org.hibernate.jdbc.Work;
23-
import org.hibernate.jpa.HibernateEntityManager;
2423
import org.hibernate.stat.SessionStatistics;
2524

2625
/**
@@ -235,7 +234,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
235234
*
236235
* To override this session's read-only/modifiable setting for entities
237236
* and proxies loaded by a Query:
238-
* @see Query#setReadOnly(boolean)
237+
* @see org.hibernate.query.Query#setReadOnly(boolean)
239238
*
240239
* @param readOnly true, the default for loaded entities/proxies is read-only;
241240
* false, the default for loaded entities/proxies is modifiable
@@ -252,7 +251,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
252251
* @throws TransientObjectException if the instance is transient or associated with
253252
* a different session
254253
*/
255-
Serializable getIdentifier(Object object);
254+
Object getIdentifier(Object object);
256255

257256
/**
258257
* Check if this entity is associated with this Session. This form caters to
@@ -281,17 +280,17 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
281280
* Return the persistent instance of the given entity class with the given identifier,
282281
* obtaining the specified lock mode, assuming the instance exists.
283282
* <p/>
284-
* Convenient form of {@link #load(Class, Serializable, LockOptions)}
283+
* Convenient form of {@link #load(Class, Object, LockOptions)}
285284
*
286285
* @param theClass a persistent class
287286
* @param id a valid identifier of an existing persistent instance of the class
288287
* @param lockMode the lock level
289288
*
290289
* @return the persistent instance or proxy
291290
*
292-
* @see #load(Class, Serializable, LockOptions)
291+
* @see #load(Class, Object, LockOptions)
293292
*/
294-
<T> T load(Class<T> theClass, Serializable id, LockMode lockMode);
293+
<T> T load(Class<T> theClass, Object id, LockMode lockMode);
295294

296295
/**
297296
* Return the persistent instance of the given entity class with the given identifier,
@@ -302,23 +301,23 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
302301
* @param lockOptions contains the lock level
303302
* @return the persistent instance or proxy
304303
*/
305-
<T> T load(Class<T> theClass, Serializable id, LockOptions lockOptions);
304+
<T> T load(Class<T> theClass, Object id, LockOptions lockOptions);
306305

307306
/**
308307
* Return the persistent instance of the given entity class with the given identifier,
309308
* obtaining the specified lock mode, assuming the instance exists.
310309
* <p/>
311-
* Convenient form of {@link #load(String, Serializable, LockOptions)}
310+
* Convenient form of {@link #load(String, Object, LockOptions)}
312311
*
313312
* @param entityName a persistent class
314313
* @param id a valid identifier of an existing persistent instance of the class
315314
* @param lockMode the lock level
316315
*
317316
* @return the persistent instance or proxy
318317
*
319-
* @see #load(String, Serializable, LockOptions)
318+
* @see #load(String, Object, LockOptions)
320319
*/
321-
Object load(String entityName, Serializable id, LockMode lockMode);
320+
Object load(String entityName, Object id, LockMode lockMode);
322321

323322
/**
324323
* Return the persistent instance of the given entity class with the given identifier,
@@ -330,7 +329,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
330329
*
331330
* @return the persistent instance or proxy
332331
*/
333-
Object load(String entityName, Serializable id, LockOptions lockOptions);
332+
Object load(String entityName, Object id, LockOptions lockOptions);
334333

335334
/**
336335
* Return the persistent instance of the given entity class with the given identifier,
@@ -346,7 +345,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
346345
*
347346
* @return the persistent instance or proxy
348347
*/
349-
<T> T load(Class<T> theClass, Serializable id);
348+
<T> T load(Class<T> theClass, Object id);
350349

351350
/**
352351
* Return the persistent instance of the given entity class with the given identifier,
@@ -362,16 +361,13 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
362361
*
363362
* @return the persistent instance or proxy
364363
*/
365-
Object load(String entityName, Serializable id);
364+
Object load(String entityName, Object id);
366365

367366
/**
368367
* Read the persistent state associated with the given identifier into the given transient
369368
* instance.
370-
*
371-
* @param object an "empty" instance of the persistent class
372-
* @param id a valid identifier of an existing persistent instance of the class
373369
*/
374-
void load(Object object, Serializable id);
370+
void load(Object object, Object id);
375371

376372
/**
377373
* Persist the state of the given detached instance, reusing the current
@@ -404,7 +400,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
404400
*
405401
* @return the generated identifier
406402
*/
407-
Serializable save(Object object);
403+
Object save(Object object);
408404

409405
/**
410406
* Persist the given transient instance, first assigning a generated identifier. (Or
@@ -417,7 +413,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
417413
*
418414
* @return the generated identifier
419415
*/
420-
Serializable save(String entityName, Object object);
416+
Object save(String entityName, Object object);
421417

422418
/**
423419
* Either {@link #save(Object)} or {@link #update(Object)} the given
@@ -693,25 +689,25 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
693689
*
694690
* @return a persistent instance or null
695691
*/
696-
<T> T get(Class<T> entityType, Serializable id);
692+
<T> T get(Class<T> entityType, Object id);
697693

698694
/**
699695
* Return the persistent instance of the given entity class with the given identifier,
700696
* or null if there is no such persistent instance. (If the instance is already associated
701697
* with the session, return that instance. This method never returns an uninitialized instance.)
702698
* Obtain the specified lock mode if the instance exists.
703699
* <p/>
704-
* Convenient form of {@link #get(Class, Serializable, LockOptions)}
700+
* Convenient form of {@link #get(Class, Object, LockOptions)}
705701
*
706702
* @param entityType The entity type
707703
* @param id an identifier
708704
* @param lockMode the lock mode
709705
*
710706
* @return a persistent instance or null
711707
*
712-
* @see #get(Class, Serializable, LockOptions)
708+
* @see #get(Class, Object, LockOptions)
713709
*/
714-
<T> T get(Class<T> entityType, Serializable id, LockMode lockMode);
710+
<T> T get(Class<T> entityType, Object id, LockMode lockMode);
715711

716712
/**
717713
* Return the persistent instance of the given entity class with the given identifier,
@@ -725,7 +721,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
725721
*
726722
* @return a persistent instance or null
727723
*/
728-
<T> T get(Class<T> entityType, Serializable id, LockOptions lockOptions);
724+
<T> T get(Class<T> entityType, Object id, LockOptions lockOptions);
729725

730726
/**
731727
* Return the persistent instance of the given named entity with the given identifier,
@@ -737,23 +733,23 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
737733
*
738734
* @return a persistent instance or null
739735
*/
740-
Object get(String entityName, Serializable id);
736+
Object get(String entityName, Object id);
741737

742738
/**
743739
* Return the persistent instance of the given entity class with the given identifier,
744740
* or null if there is no such persistent instance. (If the instance is already associated
745741
* with the session, return that instance. This method never returns an uninitialized instance.)
746742
* Obtain the specified lock mode if the instance exists.
747743
* <p/>
748-
* Convenient form of {@link #get(String, Serializable, LockOptions)}
744+
* Convenient form of {@link #get(String, Object, LockOptions)}
749745
*
750746
* @param entityName the entity name
751747
* @param id an identifier
752748
* @param lockMode the lock mode
753749
*
754750
* @return a persistent instance or null
755751
*
756-
* @see #get(String, Serializable, LockOptions)
752+
* @see #get(String, Object, LockOptions)
757753
*/
758754
Object get(String entityName, Serializable id, LockMode lockMode);
759755

@@ -769,7 +765,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
769765
*
770766
* @return a persistent instance or null
771767
*/
772-
Object get(String entityName, Serializable id, LockOptions lockOptions);
768+
Object get(String entityName, Object id, LockOptions lockOptions);
773769

774770
/**
775771
* Return the entity name for a persistent entity.
@@ -936,7 +932,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
936932
*
937933
* To override this session's read-only/modifiable setting for entities
938934
* and proxies loaded by a Query:
939-
* @see Query#setReadOnly(boolean)
935+
* @see org.hibernate.query.Query#setReadOnly(boolean)
940936
*
941937
* @param entityOrProxy an entity or HibernateProxy
942938
* @param readOnly {@code true} if the entity or proxy should be made read-only; {@code false} if the entity or

0 commit comments

Comments
 (0)