hi there..
i'm writing an desktop application and i'm using hibernate for persistence, and i'm using free form project and ant files.
i want update hibernate at latest version,
actually, i'm using 4.1 version.
in ant file i has :
Code:
hibernate.ver = 4.1
hibernate-tools.ver = 4.1
hibernate-annotations.ver = 4.1
// this is swing ant file
<path id="hibernate.classpath">
<fileset refid="hibernate.jars" />
<fileset refid="hibernate-annotations.jars" />
</path>
// this is my framework-hibernate-template-build.xml
Code:
<echo message="Versione di Hibernate: ${hibernate.ver}" />
<fileset id="hibernate.jars" dir="${lib.dir}/hibernate-${hibernate.ver}">
<include name="antlr-*.jar" />
<include name="commons-collections-*.jar" />
<include name="dom4j-*.jar" />
<include name="hibernate*.jar" />
<include name="hibernate-jpa*.jar" />
<include name="javassist*.jar" />
<include name="jboss-*.jar" />
<!-- <include name="c3p0-*.jar" />
<include name="mchange-*.jar" /> -->
</fileset>
<echo message="Versione di Hibernate-annotations: ${hibernate-annotations.ver}" />
<fileset id="hibernate-annotations.jars" dir="${lib.dir}/hibernate-annotations-${hibernate-annotations.ver}">
<include name="hibernate-commons-annotations*.jar" />
</fileset>
<echo message="Versione di Hibernate-tools: ${hibernate-tools.ver}" />
<fileset id="hibernate-tools.jars" dir="${lib.dir}/hibernate-tools-${hibernate-tools.ver}">
<include name="hibernate-tools*.jar" />
<include name="freemarker.jar" />
<include name="commons-logging-*.jar" />
</fileset>
my problem is that if I download the new hibernate version I can not find the same folders and the jars files, can you tell me where to find them?
I want to upgrade to the latest version because I get this error
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
another post I read that it is advisable to first update.
Code:
SessionFactory sf = DAOUtilHibernate.getSessionFactory();
IDAOSala dao = new DAOSala();
try {
sf.getCurrentSession().beginTransaction();
Session session = (Session) sf.getCurrentSession();
listaSale = dao.findAll();
sf.getCurrentSession().getTransaction().commit();
this.controllo.getModello().setListaSale(listaSale);
return true;
} catch (DAOException ex) {
JOptionPane.showMessageDialog(this.controllo.getVista(), "Errore nel caricamento delle sale", "Inane error", JOptionPane.ERROR_MESSAGE);
if (sf.getCurrentSession().getTransaction().isActive()) {
logger.error("Trying to rollback database transaction after exception");
sf.getCurrentSession().getTransaction().rollback();
}
logger.error("errore nel caricamento sala e tavoli " + ex);
return false;
}
}
"Sale" --> is room
sale has a list of table.
Hibernate use lazy loading.
when my view call the table list, hibernate session is closed.
if i comment sf.getCurrentSession().getTransaction().commit();
the app works, but i don't know if is it correct or not
( one user, one session ? open with app and close when i close app?? it is a solution ? what does commit() method? )
thank you very much for your help!