-->
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: need a solution based on hibernate criteria
PostPosted: Wed Apr 21, 2010 5:31 pm 
Newbie

Joined: Wed Apr 21, 2010 5:05 pm
Posts: 1
I have two classes Customer and Merchant with many-to-many relationship as shown below.

Code:
public class Customer implements Serializable {
      private Collection<Merchant> preferences;


   @ManyToMany(targetEntity = Merchant.class, cascade = { CascadeType.PERSIST,
         CascadeType.MERGE, CascadeType.ALL }, fetch = FetchType.EAGER)
   @JoinTable(name = "CUSTOMER_MERCHANT", joinColumns = @JoinColumn(name = "CUSTOMER_ID"), inverseJoinColumns = @JoinColumn(name = "MERCHANT_ID"))
   public Collection<Merchant> getPreferences() {
      return preferences;
   }

   public void setPreferences(Collection<Merchant> preferences) {
      this.preferences = preferences;
   }
}



Code:
public class Merchant implements Serializable {
private Collection<Customer> cutomers;

@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE,
         CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "preferences", targetEntity = Customer.class)
   public Collection<Customer> getCutomers() {
      return cutomers;
   }

   public void setCutomers(Collection<Customer> cutomers) {
      this.cutomers = cutomers;
   }
}


I need to get the merchants according to the customer's preferences using hibernate template. since my DAO class extends HibernateDaoSupport, i need a solution based on it. Please help me.........


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.