-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: HQL problem (maybe related to hibernate cache)
PostPosted: Sat Jan 15, 2005 5:27 pm 
Newbie

Joined: Sat Jan 15, 2005 5:22 pm
Posts: 1
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());

}


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 15, 2005 6:17 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Are you doing proper transaction management? e.g. use the Transaction API?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.