Hello all,
I am facing a wierd problem with Hibernate.
I am developing a Swing application that access MySQL by Hibernate. My developent envioroment is MyEclipse. Everything works fine in MyEclipse.
After that use InstallShield to generate a setup.exe for my application.
In order to generate the setup.exe, I do the following steps:
1. generate a fatjar file, bill.jar, for instance
2. convert bill.jar to bill.exe by Jsmooth
3. put bill.exe and other file into setup.exe by InstallShield
I run setup.exe to install the application, then run the application.
The wierd part is all the query dosn't return any result for the first time I run the application. But everything works fine after I stop it and re-run.
I check my log file, and see that Hibernate is configured , and no exception during the application is run. the HQL str is somethning like :
from Bill where calldate >= '2009-02-06 00:00:00' and calldate <= '2009-03-06 23:59:59'
the query code is the following:
public List queryList(String hql)
{
Session session = HibernateSessionFactory.getSession();
Query query = session.createQuery(hql);
List list = query.list();
return list;
}
There are many records in MySQL database, but the queryList(String hql) method return a list of size 0. The same situation with all other HQL.
I just can't explain why hibernate dosn't work for the first time the app is run, but works fine since the second time. Does anybody can explain? and tell me how to solve this problem?
Thanks in advance.
Yhqian99
|