Hi Folks.
I have a problem with an application that uses the Hibernate and I need some help.
I have a HQL that I execute to list a complex object (with Sets) and displays it in a grid.
When I update one of the objects that are returned by this HQL, and execute thes query again,
the hibernate got lost and it lists the old object (the new value is correct in the database) and sometimes
shows the updated value, and other times shows the old value again.
PS: I'm using the architecture proposal for the Hibernate Synchonizer.
If somebody have some idea about this problem I´ll really appreciate the help.
It follows code of the HQL:
Query query;
Session session;
StringBuffer stbQuery = new StringBuffer();
//TODO: This will be much better with the "select new" operator in Hibernate3
stbQuery.append("from Template as t ");
/*Active*/
stbQuery.append("where t.Active='").append(localizedTemplate.getTemplateID().getActive()).append("' ");
/*Description*/
if (!Utils.nullOrBlank(localizedTemplate.getDescription())) {
stbQuery.append("and t.TemplateID in (select distinct lt.TemplateID from LocalizedTemplate lt where lt.Description like '%");
stbQuery.append(localizedTemplate.getDescription()+"%') ");
}
/*Language*/
if (localizedTemplate.getLanguageID() != null) {
stbQuery.append("and t.TemplateID in (select distinct lt.TemplateID from LocalizedTemplate lt where lt.LanguageID.LanguageID = ");
stbQuery.append(localizedTemplate.getLanguageID().getLanguageID().toString()+") ");
}
/*Name*/
if (!Utils.nullOrBlank(localizedTemplate.getTemplateID().getName())) {
stbQuery.append("and t.Name like '%"+localizedTemplate.getTemplateID().getName()+"%' ");
}
/*Order HQL clause*/
stbQuery.append("order by t.Name asc");
try {
session = this.getSession();
query = session.createQuery(stbQuery.toString());
return new ArrayList(query.list());
}
|