0

We have entities (top-entity) with sub-entities and can't use Open Session In View Filter because we modify entities in our service layer but we don't wan't those changes to be persistent. We persist only what we want by calling dao.update!

On the other hand if we don't use open session in view filter our sub-entities are not correct ones.

Is there some workaround to force GWT not to call findEntity() on sub-entities if we instant those sub-entities in top entity!

Example:

    public class User {
    private Long id;
    private Long version;
    private String name;
    Address address;
    /* Getters and Setters */
    public static User findUser(Long id){
        //load from db User with Address    
    }
}
public class Address {
    private Long id;
    private Long version;
    private String name;
    /* Getters and Setters */
    public static Address findAddress(Long id){
        // GWT calls this method although i have allready populated address 
    }
}
  • Even if you use OSIV, you'll persist _"only what [you] want by calling dao.update"_ so I don't understand why you can't use OSIV. – Thomas Broyer Jan 10 '13 at 16:06
  • Thomas tnx for the answer. We use spring with hibernate and if objects are loaded in hibernate session and changed those changes will be persisted without calling dao.update! For example if i load User – user1967002 Jan 10 '13 at 20:59
  • For example if i load user and change his name that would be persisted without the need to call update on that entity and that is Inappropriate behavior to us. – user1967002 Jan 10 '13 at 21:12
  • Indeed it is, but then it's a Spring/Hibernate issue. We must not have the same definition of OSIV or what a session is (though I'm pretty sure Hibernate is fine on its own, so I'd rather blame Spring) – Thomas Broyer Jan 11 '13 at 08:19
  • Why is this working with gwt 2.4 without OSIV? – user1967002 Jan 11 '13 at 16:06
  • See https://code.google.com/p/google-web-toolkit/issues/detail?id=7827 – Thomas Broyer Jan 12 '13 at 12:29
  • Thomas thank you very much. i will have to figure out something else because i am not very confortable with using OSIV. My only problem is that hibernate returns two Address object insted of one and the wrong one gets updated by Request Factory. – user1967002 Jan 12 '13 at 14:24
  • And AFAUI that's what OSIV is about: sharing a single entity-cache spanning an entire request; and then you use several transactions on the same session, one for each service method being called. And of course, in your case, do not use auto-commit. – Thomas Broyer Jan 12 '13 at 15:32

0 Answers0