Skip to content

Commit

Permalink
clean up some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking authored and sebersole committed Dec 27, 2021
1 parent 9d0ee36 commit a25aa20
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
25 changes: 11 additions & 14 deletions hibernate-core/src/main/java/org/hibernate/SessionFactory.java
Expand Up @@ -172,16 +172,21 @@ default <R> R fromSession(Function<Session,R> action) {
default <R> R fromTransaction(Function<Session,R> action) {
return fromSession(
session -> {
R result = null;

final Transaction txn = session.beginTransaction();

try {
result = action.apply( session );
R result = action.apply( session );

if ( !txn.isActive() ) {
throw new TransactionManagementException( "Execution of action caused managed transaction to be completed" );
}

// action completed with no errors - attempt to commit the transaction allowing
// any RollbackException to propagate. Note that when we get here we know the
// txn is active

txn.commit();

return result;
}
catch (RuntimeException e) {
// an error happened in the action
Expand All @@ -195,14 +200,6 @@ default <R> R fromTransaction(Function<Session,R> action) {

throw e;
}

// action completed with no errors - attempt to commit the transaction allowing
// any RollbackException to propagate. Note that when we get here we know the
// txn is active

txn.commit();

return result;
}
);
}
Expand Down Expand Up @@ -248,7 +245,7 @@ default <R> R fromTransaction(Function<Session,R> action) {
*
* @return The set of filter names.
*/
Set getDefinedFilterNames();
Set<String> getDefinedFilterNames();

/**
* Obtain the definition of a filter by name.
Expand Down Expand Up @@ -285,7 +282,7 @@ default <R> R fromTransaction(Function<Session,R> action) {
* @deprecated Use the descriptors from {@link #getMetamodel()} instead
*/
@Deprecated
ClassMetadata getClassMetadata(Class entityClass);
ClassMetadata getClassMetadata(@SuppressWarnings("rawtypes") Class entityClass);

/**
* Retrieve the {@link ClassMetadata} associated with the given entity class.
Expand Down
Expand Up @@ -188,7 +188,7 @@ public <T> void addNamedEntityGraph(String graphName, EntityGraph<T> entityGraph
}

@Override
public Set getDefinedFilterNames() {
public Set<String> getDefinedFilterNames() {
return delegate.getDefinedFilterNames();
}

Expand Down
Expand Up @@ -1010,7 +1010,7 @@ public boolean containsFetchProfileDefinition(String name) {
return fetchProfiles.containsKey( name );
}

public Set getDefinedFilterNames() {
public Set<String> getDefinedFilterNames() {
return filters.keySet();
}

Expand Down
Expand Up @@ -27,11 +27,11 @@ public interface SessionStatistics {
* Get the set of all {@code EntityKey}s
* @see org.hibernate.engine.spi.EntityKey
*/
Set getEntityKeys();
Set<?> getEntityKeys();
/**
* Get the set of all {@code CollectionKey}s
* @see org.hibernate.engine.spi.CollectionKey
*/
Set getCollectionKeys();
Set<?> getCollectionKeys();

}
Expand Up @@ -31,11 +31,11 @@ public int getCollectionCount() {
return session.getPersistenceContextInternal().getCollectionEntriesSize();
}

public Set getEntityKeys() {
public Set<?> getEntityKeys() {
return Collections.unmodifiableSet( session.getPersistenceContextInternal().getEntitiesByKey().keySet() );
}

public Set getCollectionKeys() {
public Set<?> getCollectionKeys() {
return Collections.unmodifiableSet( session.getPersistenceContextInternal().getCollectionsByKey().keySet() );
}

Expand Down

0 comments on commit a25aa20

Please sign in to comment.