-->
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.  [ 1 post ] 
Author Message
 Post subject: @Where annotated list not refreshed after merge
PostPosted: Mon May 19, 2014 8:21 am 
Newbie

Joined: Mon May 19, 2014 8:03 am
Posts: 1
Hello guys,

I have an Entity CustomerProgram that has a List<CustomerProgramEntries> property, like this:

Code:
   @OneToMany(mappedBy = "customerProgram", orphanRemoval = true, fetch = FetchType.LAZY, cascade = javax.persistence.CascadeType.ALL)
   @Where(clause = "status='ACTIVE' or status='PENDING' or status='TERMINATED'")
   @OrderBy(clause = "uid asc")
   public List<CustomerProgramEntry> getCustomerProgramEntries() {
      
      /*check if composition is valid*/
      validateCustomerProgramEntries();
      
      return this.customerProgramEntries;
   }


The @Where annotation works perfectly well when selecting, but when updating an item in this list to a different status (which does not meet the @Where clause, e.g. 'INACTIVE'), and subsequently merging the CustomerProgram, the updated CustomerPogramEntry remains in the list whereas (I assumed) it should not since it has gotten a different status than specified in the @Where annotation.

The workaround is calling em.flush afther merging (em.merge) and then calling em.refresh on the customerProgram entity to force a reload of the list. As you guys can read I'm using EntityManager rather than Hibernate Session.

For me, this doesnt feel quite right. I had expected the merge operation to cascade on the list<CustomerProgramEntry> property and return the correct db state to me meaning the item should not be in the list anymore.

Can anyone please confirm if this specified behaviour is correct and that my workaround is the only possible solution?

Many thanks,

Kim

PS. Im using JPA 2.1 icw Hibernate 4.3.5-Final


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

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.