-->
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: How can seconde level cache know data is updated?
PostPosted: Mon Feb 21, 2011 9:51 am 
Newbie

Joined: Mon Feb 21, 2011 9:33 am
Posts: 3
We have RuleGroup object, onToMany to Rule(each RuleGroup having several rules), when query RuleGroup we only want rule having "where rule.end_date is null", so using following config, can work fine, but, when we:
1.execute ruleGroupDao.find()
2.update some rule.end_date from null to some date;
3.re execute ruleGroupDao.find(), we expect getting out ruleGroup without that updated rule(end_date is not null), but actually we get the updated rule, although end_date is not null, seems the data was query out from cache, but how can we get result as our expected?


@Entity
@Table(name = "IPCAT_RULE_GROUPS")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@SequenceGenerator(name = "SEQ_GENERATOR", sequenceName = "IPCAT_RULE_GROUPS_SEQ")
public class RuleGroup implements Serializable {

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "rule_group_id")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Where(clause = "end_date is null")
@Fetch(FetchMode.SUBSELECT)
private List<Rule> rules = new ArrayList<Rule>();
......

}

@Entity
@Table(name = "IPCAT_RULES")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@SequenceGenerator(name = "SEQ_GENERATOR", sequenceName = "IPCAT_RULES_SEQ")
public class Rule implements Serializable {
@Temporal(TemporalType.DATE)
@Column(name = "end_date")
private Date endDate;

......
}

RuleGroup RuleGroupDao.find()
{
List<RuleGroup> list = getHibernateTemplate().find(
"select distinct rg from RuleGroup as rg " +
"left join rg.rules as rule with (rule.endDate is null) " +
"left join rule.ruleExpressions as exp with (exp.endDate is null) , " +
"RuleGroupGL rgg, RuleGroupStrategy rgs, " +
"Strategy st " +
" where rg.id = rgg.key.ruleGroupId and rg.id = rgs.key.ruleGroupId and st.id = rgs.key.strategyId " +
" and st.owner = ? and st.name = ? and rg.legalEntityId = ? and rgg.key.gl = ? " +
"and rg.scenario = ? ", paramaters);

return list;
}


Top
 Profile  
 
 Post subject: Re: How can seconde level cache know data is updated?
PostPosted: Mon Feb 21, 2011 9:35 pm 
Newbie

Joined: Mon Feb 21, 2011 9:33 am
Posts: 3
seems need to evict the object from second-level cache?


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.