Add evict method

This commit is contained in:
Terry Brady
2016-08-18 17:10:43 -07:00
parent 4334ffdd99
commit d64722a628
3 changed files with 13 additions and 0 deletions

View File

@@ -714,6 +714,12 @@ public class Context
return (E) dbConnection.reloadEntity(entity);
}
@SuppressWarnings("unchecked")
public <E extends ReloadableEntity> void uncacheEntity(E entity) throws SQLException {
dbConnection.uncacheEntity(entity);
}
/**
* Reload all entities related to this context.
* @throws SQLException When reloading one of the entities fails.

View File

@@ -53,4 +53,6 @@ public interface DBConnection<T> {
* @param entity The DSpace object to reload
*/
public <E extends ReloadableEntity> E reloadEntity(E entity) throws SQLException;
public <E extends ReloadableEntity> void uncacheEntity(E entity) throws SQLException ;
}

View File

@@ -157,4 +157,9 @@ public class HibernateDBConnection implements DBConnection<Session> {
getSession().setFlushMode(FlushMode.AUTO);
}
}
@Override
public <E extends ReloadableEntity> void uncacheEntity(E entity) throws SQLException {
getSession().evict(entity);
}
}