| 
					
						 Hibernate 3.0.5
 
 
 Hi,
       I have a uni-directional many-many relatonship using join-table defined in the following way.
 
 Client and Module have many-to-many relation via client_modules table.
 
 <class name="Client"..
 ...
 <set name="assignedModules" lazy="true" table="client_modules">
   <key column="client_id" not-null="true"/>
   <composite-element class="ClientModule">
        <many-to-one name="module" class="Module" column="client_module_id" not-null="true"/>
    <property name="allBranches" type="java.lang.Boolean"  column="allbranches" not-null="true"/>
    </composite-element>
 </set>
 ..
 </Class>
 
 In my criteria query, i need to add restriction looking for a particular module id. I tried to create alias using createAlias and use it like 
 
 criteria.createAlias("client.assignedModules", "myClientModule")
 ...
 criteria.add(Expression.eq("myClientModule.module.id", new Integer(2)))
 ..
 
 I am  getting 
 org.hibernate.MappingException: collection was not an association: Client.assignedModules
 
 I partially understand why i am getting this error. But, couldn't figure out how to overcome this.
 
 So, how do i add search criteria for elements in a collection of components? 
 
 Thanks for reading the post. Any ideas for a newbie, please?
 
 Ravi 
					
  
						
					 |