Hi. I'm new to NHibernate. I have an old database that I have to do some 
mappings on it. 
 The below database is an example of my problem (not the same).

Database:
<https://lh6.googleusercontent.com/-AU2DXFuCgEI/UFWm1R5DXlI/AAAAAAAAAAM/k69VRGQbj60/s1600/data+model.png>

Class Diagram:
<https://lh5.googleusercontent.com/-Bf6dSgQxSVk/UFWnAusZUHI/AAAAAAAAAAU/6v8CPDFFhwk/s1600/ClassDiagram1.png>


I want to fill MaleActors with Actors that their Sex field equals to 'Male' 
and FemaleActors with Actors that their Sex field equals to 'Female'
I tried where attribute on my many-to-many relation but it doesn't work. 

Here are my Mapping files:

*Movie.hbm.xml*
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="MovieEg" namespace="MovieEg">
    <class name="Movie" table="Movies">
      <id name="Id">
        <generator class="identity"/>  
      </id>
      <property name="Name"/>
      <bag name="FActors" table="ActorRoles" >
        <key column="MovieId"/>
        <many-to-many class="Role" column="Id" where="Actors.Sex='Male'" /> 
 
      </bag>
    </class>
</hibernate-mapping>

*Actor.hbm.xml*
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="MovieEg" namespace="MovieEg">
    <class name="Actor" table="Actors">
      <id name="Id">
        <generator class="identity"/>
      </id>
      <property name="Name"/>
      <property name="Sex"/>
    </class>
</hibernate-mapping>
 
*ActorRole.hbm.xml*
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MovieEg" 
namespace="MovieEg">
<class name="Role" table="ActorRoles">
<id name="Id">
<generator class="identity"/>
</id>
<property name="RoleNameInMovie" column="Role"/>
  <many-to-one name="Actor" class="Actor" column="ActorId" />
</class>
</hibernate-mapping>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/OsggXk6Yg5cJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to