[jboss-user] [JBoss Seam] - Cache level

rapowder do-not-reply at jboss.com
Tue Jul 17 12:29:28 EDT 2007


I'm not sure whether this is the right place to post this question, but I'm not sure either if the problem I have comes from Hibernate or from Seam Conversations. 

I am using seam 1.2.1.GA and hibernate 3.2. In my application, data is updated quite frequently by many concurrent clients. Scenario is very simple. Two pages: one to show items, one to edit an item's properties.

My item entity is defined as such:

  | @Name("item")
  | @Table(name="item")
  | public class MItem implements Serializable {
  |    @ManyToMany
  |    @org.hibernate.annotations.Fetch(FetchMode.SUBSELECT)
  |     @Cascade({
  |         CascadeType.SAVE_UPDATE,
  |         CascadeType.MERGE, 
  |         CascadeType.PERSIST})
  |     @JoinTable(
  |     name = "item_prop",
  |     joinColumns = {@JoinColumn(name = "ip_item")},
  |     inverseJoinColumns = {@JoinColumn(name = "ip_prop")})
  |     private Set<MProperty> properties = new HashSet<MProperty>();
  |     [...]
  | }

and the property class:

  | @Entity
  | @Name("property")
  | @Table(name="property")
  | public class MProperty implements Serializable {
  |     @ManyToMany(mappedBy = "properties")
  |     private Set<MItem>items = new HashSet<MItem>();
  |     @Column(name = "pr_value")
  |     private String value;
  | [...]
  | }

The conversation spans from the item list page to the edit item (join) and is never ended (not even after saving the changes to the item properties).

If from Client A I update one of the properties of an item I can see my changes in the item list (even without ending the conversation upon persisting) but if from Client B I query the DB I can not see changes done to that property until I logout and login again (or simply when the http session is ended).

On the contrary, when I create a new item I can see changes on both clients.

I was not sure weather this was related to the second-level cache of hibernate, which I now disabled but this didn't give any significant results.

The only solution I found so far is to execute an em.refresh(item) on each item of the list before showing it, which works but has a terrible effect on performances! 

Annotating queries with hints does not work either, does somebody have a good solution for this problem?

Thank you!

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4065071#4065071

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4065071

More information about the jboss-user mailing list