Hi!

I've got following entities:

    public class UserEntity : PersistentObject
    {
        public virtual string UserName { get; set; }
        public virtual string Email { get; set; }
        public virtual string Password { get; set; }
        public virtual bool IsActive { get; set; }
        public virtual bool IsActivated { get; set; }
        public virtual DateTime RegistrationDate { get; set; }
    }

    public class UserWithRoleEntity : UserEntity
    {
        public virtual IList<RoleEntity> Roles { get; set; }
    }

There are two NH hbm mappings to those entities. I added single row to
database table
When I run this code:

   var query = session.QueryOver<UserEntity>().Where(u => u.UserName
== userName).List();

I've got two entities of UserEntity type and UserWithRoleEntity type.
Is it possible to call QueryOver<> and ignore inheritance of entities?
Here are my mappings:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
auto-import="true" assembly="OnAgile.DAL"
namespace="OnAgile.DAL.DataEntities">
  <class name="UserEntity" table="users" lazy="false">
    <id name="ID" column="id">
      <generator class="native" />
    </id>
    <property name="UserName" column="user_name" not-null="true"/>
    <property name="Password" column="password" not-null="true"/>
    <property name="Email" column="email" not-null="true"/>
    <property name="IsActive" column="is_active" type="boolean"
not-null="true"/>
    <property name="IsActivated" column="is_activated" type="boolean"
not-null="true"/>
    <property name="RegistrationDate" column="registration_date"
not-null="true"/>
  </class>
</hibernate-mapping>


<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
auto-import="true" assembly="OnAgile.DAL"
namespace="OnAgile.DAL.DataEntities">
  <class name="UserWithRoleEntity" table="users" lazy="false">
    <id name="ID" column="id">
      <generator class="native" />
    </id>
    <property name="UserName" column="user_name" not-null="true"/>
    <property name="Password" column="password" not-null="true"/>
    <property name="Email" column="email" not-null="true"/>
    <property name="IsActive" column="is_active" type="boolean"
not-null="true"/>
    <property name="IsActivated" column="is_activated" type="boolean"
not-null="true"/>
    <property name="RegistrationDate" column="registration_date"
not-null="true"/>

    <bag name="Roles" table="users_roles" lazy="true" cascade="all">
      <key column="user_id"/>
      <many-to-many column="role_id"
         class="OnAgile.DAL.DataEntities.RoleEntity, NHibernateManyToMany"/>
    </bag>
  </class>
</hibernate-mapping>

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
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