Hi,
I'm using entity inheritance with the interface trick to avoid ClassCastException. I have the following classes:
Code:
public interface AbstractNode {...}
public interface Advice extends AbstractNode {...}
@Entity
@Table(name = "node")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "type")
@org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
public abstract class AbstractNodeImpl implements AbstractNode, Serializable {...}
@Entity
@org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
public class AdviceImpl extends AbstractNodeImpl implements Advice, Serializable {...}
I execute this query:
Code:
AbstractNode result = (AbstractNode) sessionFactory.getCurrentSession().createQuery("from Advice n where n.name = :name")
.setParameter("name", name)
.setCacheable(true)
.uniqueResult();
First time, the result is put in cache. The problem is that if I update the name of the Advice entity, the query cache is not invalidated and I still get the old result!
I guess this has something to do with the inheritance and/or the use of interfaces but I can't find a solution.
I'm using Hibernate 3.3.2.GA, Hibernate annotations 3.4.0.GA and EHCache 1.6.2.
Any idea?
Thanks.