-->
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 Help With Many to Many Mappinng querying. PLease :-(
PostPosted: Thu Apr 29, 2010 8:58 am 
Newbie

Joined: Thu Apr 29, 2010 8:38 am
Posts: 1
Somebody please help me to solve this issue. I am new to hibernate. Let me mention my issue.

I have the following pojo classes called UserMasterPojo.java


private String strUserName = "";
private String strLoginName = "";
private Set<UserOptionsPojo> userPrivilages = new HashSet<UserOptionsPojo>();

public String getStrUserName() {
return strUserName;
}

public void setStrUserName(String strUserName) {
this.strUserName = strUserName;
}

public String getStrLoginName() {
return strLoginName;
}

public void setStrLoginName(String strLoginName) {
this.strLoginName = strLoginName;
}

public Set<UserOptionsPojo> getUserPrivilages() {
return userPrivilages;
}
}

Mapping xml for UserMasterPojo.java is as follows

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.trinity.pojos">
<class name="UserMasterPojo" table="usermaster">
<id name="lngUserId" column="umid">
<generator class="increment" />
</id>
<property name="strUserName" column="umname"></property>
<property name="strLoginName" column="umloginname"></property>

<set name="userPrivilages" table="useroptionslink" >
<key column="umid" />
<many-to-many column="uoid" class="UserOptionsPojo" />
</set>
</class>
</hibernate-mapping>

The second pojo class is as follows

public class UserOptionsPojo {

private Long lnguserOptionID = 0L;
private String strMainOptions = "";
private String strSubOptions = "";
private String strFuncOptions = "";


public Long getLnguserOptionID() {
return lnguserOptionID;
}

public void setLnguserOptionID(Long lnguserOptionID) {
this.lnguserOptionID = lnguserOptionID;
}

public String getStrMainOptions() {
return strMainOptions;
}

public void setStrMainOptions(String strMainOptions) {
this.strMainOptions = strMainOptions;
}

public String getStrSubOptions() {
return strSubOptions;
}

public void setStrSubOptions(String strSubOptions) {
this.strSubOptions = strSubOptions;
}

public String getStrFuncOptions() {
return strFuncOptions;
}

public void setStrFuncOptions(String strFuncOptions) {
this.strFuncOptions = strFuncOptions;
}
}
and xml mapping file for above pojo is as follows


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.trinity.pojos">
<class name="UserOptionsPojo" table="useroptions">
<id name="lnguserOptionID" column="uoid">
<generator class="increment" />
</id>
<property name="strMainOptions" column="uomainoptions"></property>
<property name="strSubOptions" column="uosuboptions"></property>
<property name="strFuncOptions" column="uofuncoptions"></property>
</class>
</hibernate-mapping>

i need to write a select query using criteria . The query need to check the use name (which in UserMasterpojo.java) and strMainOption (which is in UserOptionsPojo.java but has a many to many mapping with UserMasterPojo. See that UserMasterPojo has a set of userOptionsPojo)
. PLease help me. Thanks


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.