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 to fetch collection in Embedded object with Join?
PostPosted: Tue Apr 06, 2010 9:10 am 
Newbie

Joined: Wed Dec 27, 2006 3:27 am
Posts: 2
Hello!!!

I have working application and want to optimize it. The code is:
Code:
@Entity
public class ComplaintModel {
//code
    @Embedded
    private ComplaintOrder complaintOrder;
}

@Embeddable
public class ComplaintOrder {
   @OneToMany(cascade = CascadeType.ALL, mappedBy = "complaint")
   @JoinColumn(name = "COMPLAINT_ID", referencedColumnName = "COMPLAINT_ID")
   @Cascade( { org.hibernate.annotations.CascadeType.MERGE,
         org.hibernate.annotations.CascadeType.SAVE_UPDATE,
         org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
   private Set<CompliantLot> compliantLots = new HashSet<CompliantLot>();
}

@Entity
public class CompliantLot extends BaseEntity {

    @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
    @JoinColumn(name = "COMPLAINT_ID", referencedColumnName = "COMPLAINT_ID", nullable = false)
    private ComplaintModel complaint;
}


So, as you see Ebmeddable object ComplaintOrder contains a collection of entities CompliantLot. For now, when I try to get ComplaintModel from database I'm getting additional SQL query for noted collection. I tried difefrent fetch modes, added fetch as annotations and in criterions (even tried Aliases) - no luck. Hibernate fetches it only by additional queries.

Maybe mapping is wrong? Or I do smth. completelly wrong?


Top
 Profile  
 
 Post subject: Re: How to fetch collection in Embedded object with Join?
PostPosted: Thu Apr 08, 2010 3:57 am 
Newbie

Joined: Wed Dec 27, 2006 3:27 am
Posts: 2
Hi, does anybody know the answer?


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.