Skip to content

Commit 7b2b52e

Browse files
committed
get rid of useless "throws HibernateException" in SessionImpl
1 parent f1a5b5b commit 7b2b52e

File tree

2 files changed

+49
-54
lines changed

2 files changed

+49
-54
lines changed

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

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ private ClearEvent createClearEvent() {
396396
}
397397

398398
@Override
399-
public void close() throws HibernateException {
399+
public void close() {
400400
if ( isClosed() ) {
401401
if ( getFactory().getSessionFactoryOptions().getJpaCompliance().isJpaClosedComplianceEnabled() ) {
402402
throw new IllegalStateException( "EntityManager was already closed" );
@@ -408,7 +408,7 @@ public void close() throws HibernateException {
408408
}
409409
}
410410

411-
public void closeWithoutOpenChecks() throws HibernateException {
411+
public void closeWithoutOpenChecks() {
412412
if ( log.isTraceEnabled() ) {
413413
log.tracef( "Closing session [%s]", getSessionIdentifier() );
414414
}
@@ -560,7 +560,7 @@ protected void cleanupOnClose() {
560560
}
561561

562562
@Override
563-
public LockMode getCurrentLockMode(Object object) throws HibernateException {
563+
public LockMode getCurrentLockMode(Object object) {
564564
checkOpen();
565565
checkTransactionSynchStatus();
566566
if ( object == null ) {
@@ -589,7 +589,7 @@ public LockMode getCurrentLockMode(Object object) throws HibernateException {
589589
}
590590

591591
@Override
592-
public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException {
592+
public Object getEntityUsingInterceptor(EntityKey key) {
593593
checkOpenOrWaitingForAutoClose();
594594
// todo : should this get moved to PersistentContext?
595595
// logically, is PersistentContext the "thing" to which an interceptor gets attached?
@@ -649,7 +649,7 @@ public void lock(String entityName, Object object, LockOptions lockOptions) {
649649
}
650650

651651
@Override
652-
public void lock(Object object, LockMode lockMode) throws HibernateException {
652+
public void lock(Object object, LockMode lockMode) {
653653
final LockOptions lockOptions = copySessionLockOptions();
654654
lockOptions.setLockMode( lockMode );
655655
fireLock( new LockEvent( object, lockOptions, this ) );
@@ -690,19 +690,19 @@ else if ( exception instanceof MappingException ) {
690690
// persist() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
691691

692692
@Override
693-
public void persist(String entityName, Object object) throws HibernateException {
693+
public void persist(String entityName, Object object) {
694694
checkOpen();
695695
firePersist( new PersistEvent( entityName, object, this ) );
696696
}
697697

698698
@Override
699-
public void persist(Object object) throws HibernateException {
699+
public void persist(Object object) {
700700
checkOpen();
701701
firePersist( new PersistEvent( null, object, this ) );
702702
}
703703

704704
@Override
705-
public void persist(String entityName, Object object, PersistContext copiedAlready) throws HibernateException {
705+
public void persist(String entityName, Object object, PersistContext copiedAlready) {
706706
checkOpenOrWaitingForAutoClose();
707707
firePersist( copiedAlready, new PersistEvent( entityName, object, this ) );
708708
}
@@ -784,19 +784,19 @@ public void persistOnFlush(String entityName, Object object, PersistContext copi
784784
// merge() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
785785

786786
@Override @SuppressWarnings("unchecked")
787-
public <T> T merge(String entityName, T object) throws HibernateException {
787+
public <T> T merge(String entityName, T object) {
788788
checkOpen();
789789
return (T) fireMerge( new MergeEvent( entityName, object, this ) );
790790
}
791791

792792
@Override @SuppressWarnings("unchecked")
793-
public <T> T merge(T object) throws HibernateException {
793+
public <T> T merge(T object) {
794794
checkOpen();
795795
return (T) fireMerge( new MergeEvent( null, object, this ));
796796
}
797797

798798
@Override
799-
public void merge(String entityName, Object object, MergeContext copiedAlready) throws HibernateException {
799+
public void merge(String entityName, Object object, MergeContext copiedAlready) {
800800
checkOpenOrWaitingForAutoClose();
801801
fireMerge( copiedAlready, new MergeEvent( entityName, object, this ) );
802802
}
@@ -848,8 +848,7 @@ private void fireMerge(final MergeContext mergeContext, final MergeEvent event)
848848
// delete() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
849849

850850
@Override
851-
public void delete(String entityName, Object object, boolean isCascadeDeleteEnabled, DeleteContext transientEntities)
852-
throws HibernateException {
851+
public void delete(String entityName, Object object, boolean isCascadeDeleteEnabled, DeleteContext transientEntities) {
853852
checkOpenOrWaitingForAutoClose();
854853
final boolean removingOrphanBeforeUpdates = persistenceContext.isRemovingOrphanBeforeUpates();
855854
final boolean traceEnabled = log.isTraceEnabled();
@@ -945,7 +944,7 @@ private void fireDelete(final DeleteEvent event, final DeleteContext transientEn
945944
// load()/get() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
946945

947946
@Override
948-
public void load(Object object, Object id) throws HibernateException {
947+
public void load(Object object, Object id) {
949948
fireLoad( new LoadEvent( id, object, this, getReadOnlyFromLoadQueryInfluencers() ), LoadEventListener.RELOAD );
950949
}
951950

@@ -1003,12 +1002,12 @@ public <E> List<E> findMultiple(Class<E> entityType, List<Object> ids, FindOptio
10031002
}
10041003

10051004
@Override
1006-
public <T> T get(Class<T> entityClass, Object id) throws HibernateException {
1005+
public <T> T get(Class<T> entityClass, Object id) {
10071006
return byId( entityClass ).load( id );
10081007
}
10091008

10101009
@Override
1011-
public Object get(String entityName, Object id) throws HibernateException {
1010+
public Object get(String entityName, Object id) {
10121011
return byId( entityName ).load( id );
10131012
}
10141013

@@ -1018,7 +1017,7 @@ public Object get(String entityName, Object id) throws HibernateException {
10181017
* Do NOT return a proxy.
10191018
*/
10201019
@Override
1021-
public Object immediateLoad(String entityName, Object id) throws HibernateException {
1020+
public Object immediateLoad(String entityName, Object id) {
10221021
if ( log.isDebugEnabled() ) {
10231022
final EntityPersister persister = requireEntityPersister( entityName );
10241023
log.debugf( "Initializing proxy: %s", infoString( persister, id, getFactory() ) );
@@ -1170,22 +1169,22 @@ private void releaseLoadEvent(LoadEvent event) {
11701169
}
11711170

11721171
@Override
1173-
public <T> T get(Class<T> entityClass, Object id, LockMode lockMode) throws HibernateException {
1172+
public <T> T get(Class<T> entityClass, Object id, LockMode lockMode) {
11741173
return this.byId( entityClass ).with( new LockOptions( lockMode ) ).load( id );
11751174
}
11761175

11771176
@Override
1178-
public <T> T get(Class<T> entityClass, Object id, LockOptions lockOptions) throws HibernateException {
1177+
public <T> T get(Class<T> entityClass, Object id, LockOptions lockOptions) {
11791178
return this.byId( entityClass ).with( lockOptions ).load( id );
11801179
}
11811180

11821181
@Override
1183-
public Object get(String entityName, Object id, LockMode lockMode) throws HibernateException {
1182+
public Object get(String entityName, Object id, LockMode lockMode) {
11841183
return this.byId( entityName ).with( new LockOptions( lockMode ) ).load( id );
11851184
}
11861185

11871186
@Override
1188-
public Object get(String entityName, Object id, LockOptions lockOptions) throws HibernateException {
1187+
public Object get(String entityName, Object id, LockOptions lockOptions) {
11891188
return this.byId( entityName ).with( lockOptions ).load( id );
11901189
}
11911190

@@ -1299,24 +1298,24 @@ private void fireResolveNaturalId(final ResolveNaturalIdEvent event) {
12991298
// refresh() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13001299

13011300
@Override
1302-
public void refresh(Object object) throws HibernateException {
1301+
public void refresh(Object object) {
13031302
fireRefresh( new RefreshEvent( object, this ) );
13041303
}
13051304

13061305
@Override
1307-
public void refresh(Object object, LockMode lockMode) throws HibernateException {
1306+
public void refresh(Object object, LockMode lockMode) {
13081307
final LockOptions lockOptions = copySessionLockOptions();
13091308
lockOptions.setLockMode( lockMode );
13101309
fireRefresh( new RefreshEvent( object, lockOptions, this ) );
13111310
}
13121311

13131312
@Override
1314-
public void refresh(Object object, LockOptions lockOptions) throws HibernateException {
1313+
public void refresh(Object object, LockOptions lockOptions) {
13151314
fireRefresh( new RefreshEvent( object, lockOptions, this ) );
13161315
}
13171316

13181317
@Override
1319-
public void refresh(String entityName, Object object, RefreshContext refreshedAlready) throws HibernateException {
1318+
public void refresh(String entityName, Object object, RefreshContext refreshedAlready) {
13201319
fireRefresh( refreshedAlready, new RefreshEvent( entityName, object, this ) );
13211320
}
13221321

@@ -1374,13 +1373,12 @@ private boolean managed(String entityName, Object entity) {
13741373
// replicate() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13751374

13761375
@Override
1377-
public void replicate(Object obj, ReplicationMode replicationMode) throws HibernateException {
1376+
public void replicate(Object obj, ReplicationMode replicationMode) {
13781377
fireReplicate( new ReplicateEvent( obj, replicationMode, this ) );
13791378
}
13801379

13811380
@Override
1382-
public void replicate(String entityName, Object obj, ReplicationMode replicationMode)
1383-
throws HibernateException {
1381+
public void replicate(String entityName, Object obj, ReplicationMode replicationMode) {
13841382
fireReplicate( new ReplicateEvent( entityName, obj, replicationMode, this ) );
13851383
}
13861384

@@ -1400,7 +1398,7 @@ private void fireReplicate(final ReplicateEvent event) {
14001398
* (references held by application or other persistent instances are okay)
14011399
*/
14021400
@Override
1403-
public void evict(Object object) throws HibernateException {
1401+
public void evict(Object object) {
14041402
checkOpen();
14051403
pulseTransactionCoordinator();
14061404
final EvictEvent event = new EvictEvent( object, this );
@@ -1410,13 +1408,12 @@ public void evict(Object object) throws HibernateException {
14101408
}
14111409

14121410
@Override
1413-
public boolean autoFlushIfRequired(Set<String> querySpaces) throws HibernateException {
1411+
public boolean autoFlushIfRequired(Set<String> querySpaces) {
14141412
return autoFlushIfRequired( querySpaces, false );
14151413
}
14161414

14171415
@Override
1418-
public boolean autoFlushIfRequired(Set<String> querySpaces, boolean skipPreFlush)
1419-
throws HibernateException {
1416+
public boolean autoFlushIfRequired(Set<String> querySpaces, boolean skipPreFlush) {
14201417
checkOpen();
14211418
if ( !isTransactionInProgress() ) {
14221419
// do not auto-flush while outside a transaction
@@ -1440,7 +1437,7 @@ public void autoPreFlush(){
14401437
}
14411438

14421439
@Override
1443-
public boolean isDirty() throws HibernateException {
1440+
public boolean isDirty() {
14441441
checkOpen();
14451442
if ( actionQueue.areInsertionsOrDeletionsQueued() ) {
14461443
return true;
@@ -1454,7 +1451,7 @@ public boolean isDirty() throws HibernateException {
14541451
}
14551452

14561453
@Override
1457-
public void flush() throws HibernateException {
1454+
public void flush() {
14581455
checkOpen();
14591456
doFlush();
14601457
}
@@ -1482,12 +1479,12 @@ public void setFlushMode(FlushModeType flushModeType) {
14821479
}
14831480

14841481
@Override
1485-
public void forceFlush(EntityEntry entityEntry) throws HibernateException {
1482+
public void forceFlush(EntityEntry entityEntry) {
14861483
forceFlush( entityEntry.getEntityKey() );
14871484
}
14881485

14891486
@Override
1490-
public void forceFlush(EntityKey key) throws HibernateException {
1487+
public void forceFlush(EntityKey key) {
14911488
if ( log.isDebugEnabled() ) {
14921489
log.debugf("Flushing to force deletion of re-saved object: "
14931490
+ infoString( key.getPersister(), key.getIdentifier(), getFactory() ) );
@@ -1505,15 +1502,15 @@ public void forceFlush(EntityKey key) throws HibernateException {
15051502
}
15061503

15071504
@Override
1508-
public Object instantiate(String entityName, Object id) throws HibernateException {
1505+
public Object instantiate(String entityName, Object id) {
15091506
return instantiate( requireEntityPersister( entityName ), id );
15101507
}
15111508

15121509
/**
15131510
* give the interceptor an opportunity to override the default instantiation
15141511
*/
15151512
@Override
1516-
public Object instantiate(EntityPersister persister, Object id) throws HibernateException {
1513+
public Object instantiate(EntityPersister persister, Object id) {
15171514
checkOpenOrWaitingForAutoClose();
15181515
pulseTransactionCoordinator();
15191516
Object result = getInterceptor()
@@ -1554,7 +1551,7 @@ public EntityPersister getEntityPersister(final String entityName, final Object
15541551

15551552
// not for internal use:
15561553
@Override
1557-
public Object getIdentifier(Object object) throws HibernateException {
1554+
public Object getIdentifier(Object object) {
15581555
checkOpen();
15591556
checkTransactionSynchStatus();
15601557
final LazyInitializer lazyInitializer = extractLazyInitializer( object );
@@ -1845,13 +1842,13 @@ public <T> T getReference(T object) {
18451842
}
18461843

18471844
@Override
1848-
public String guessEntityName(Object object) throws HibernateException {
1845+
public String guessEntityName(Object object) {
18491846
checkOpenOrWaitingForAutoClose();
18501847
return getEntityNameResolver().resolveEntityName( object );
18511848
}
18521849

18531850
@Override
1854-
public void cancelQuery() throws HibernateException {
1851+
public void cancelQuery() {
18551852
checkOpen();
18561853
getJdbcCoordinator().cancelLastQuery();
18571854
}

0 commit comments

Comments
 (0)