Hi all. I have an application that collects a collection of objects, and other that inserts elements in this collection. I want to refresh the items of this collection every time I consult these, while this other application inserts other items.
I tryed some stuff like these:
Code:
public static Session getSession() throws Exception {
if(session == null) {
SessionFactory sessionFactory = null;
// Get the session factory we can use for persistence
sessionFactory = getConfiguration().buildSessionFactory();
sessionFactory.evictQueries();
// Ask for a session using the JDBC information we've configured
session = sessionFactory.openSession();
session.setFlushMode(FlushMode.ALWAYS);
}
return session;
}
and this:
Code:
public Query getQuery(MyQueryInstance myQueyInstance) throws Exception {
Session aSession = MyHibernate.getSession();
aSession.clear();
Query aQuery = aSession.createQuery(myQueyInstance.getQueyStatement());
//aQuery.setCacheable(false);
//aQuery.setCacheMode(CacheMode.IGNORE);
Hashtable aTab = myQueyInstance.getParameters();
Enumeration aParListDefinition = aTab.keys();
while(aParListDefinition.hasMoreElements()) {
MYQueryParameter aParDef = (MyQueryParameter)aParListDefinition.nextElement();
String aParName = aParDef.getName();
Object aValue = aTab.get(aParDef);
aQuery.setParameter(aParName , aValue);
}
return aQuery;
}
I donĀ“t want to use cache, how to disable this? Or there is other better alternative?