Thanks for the quick reply!
I can provide the entity and the mapping file, but this is all I have of the stack trace (hence the difficult investigation!).
To be honest, even some ideas for common causes would help!
Thanks again.
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using OurClient.core.services;
using OurClient.core.dataaccess;
using System.Security.Principal;
namespace OurClient.core.domain
{
public class SiteUser : User
{
#region members
private bool _activated;
private IList<Address> _addresses;
private IList<OptIn> _optIns;
private Branch _branch;
private Scrapbook _scrapBook;
private string _title;
private bool? _gender; //Male is true; Female is false;
private DateTime? _dateOfBirth;
private string _location;
private string _avatarUrl;
private IList<Comment> _comments;
private IList<RecipeComment> _recipeComments;
private IList<BlogComment> _blogComments;
private IList<ProductComment> _productComments;
private IList<Comment> _allPublicComments;
private IDictionary<Guid, RecipeNote> _recipeNotes;
private IList<CompetitionResponse> _competitionResponses;
private int _failedLogins;
private ExtendedUserData _extendedUserData;
private bool _termsAndConditionsAccepted;
#endregion
#region public properties
public virtual bool Activated
{
get { return _activated; }
set { _activated = value; }
}
public virtual IList<Address> Addresses
{
get { return _addresses; }
set { _addresses = value; }
}
public virtual IList<OptIn> OptIns
{
get { return _optIns; }
set { _optIns = value; }
}
public virtual OptIn GetOptIn(string name)
{
if(OptIns != null)
foreach (OptIn optIn in OptIns)
{
if (optIn.Name == name)
return optIn;
}
return null;
}
public virtual Branch Branch
{
get { return _branch; }
set { _branch = value; }
}
public virtual Scrapbook ScrapBook
{
get
{
return _scrapBook;
}
set { _scrapBook = value; }
}
public virtual string Title
{
get { return _title; }
set
{
if (value != null)
if (value.Length > 10)
throw new ArgumentOutOfRangeException("Invalid value for Title", value, value.ToString());
_isChanged |= (_title != value); _title = value;
}
}
//Male is true; Female is false;
public virtual bool? Gender
{
get { return _gender; }
set { _isChanged |= (_gender != value); _gender = value; }
}
public virtual DateTime? DateOfBirth
{
get { return _dateOfBirth; }
set { _isChanged |= (_dateOfBirth != value); _dateOfBirth = value; }
}
public virtual string Location
{
get { return _location; }
set
{
if (value != null)
if (value.Length > 30)
throw new ArgumentOutOfRangeException("Invalid value for Location", value, value.ToString());
_isChanged |= (_location != value); _location = value;
}
}
public virtual string AvatarUrl
{
get { return _avatarUrl; }
set
{
if (value != null)
if (value.Length > 100)
throw new ArgumentOutOfRangeException("Invalid value for AvatarUrl", value, value.ToString());
_isChanged |= (_avatarUrl != value); _avatarUrl = value;
}
}
public virtual IList<Comment> Comments
{
get { return _comments; }
set { _comments = value; }
}
public virtual IList<RecipeComment> RecipeComments
{
get { return _recipeComments; }
set { _recipeComments = value; }
}
public virtual IList<BlogComment> BlogComments
{
get { return _blogComments; }
set { _blogComments = value; }
}
public virtual IList<ProductComment> ProductComments
{
get { return _productComments; }
set { _productComments = value; }
}
public virtual IList<Comment> AllPublicComments
{
get { return _allPublicComments; }
set { _allPublicComments = value; }
}
public virtual IList<CompetitionResponse> CompetitionResponses
{
get { return _competitionResponses; }
set { _competitionResponses = value; }
}
public virtual int PercentComplete
{
get
{
int percentComplete = 0;
if (!String.IsNullOrEmpty(_title))
percentComplete += 6;
if (!String.IsNullOrEmpty(FirstName))
percentComplete += 6;
if (!String.IsNullOrEmpty(Surname))
percentComplete += 6;
if (_gender != null)
percentComplete += 7;
if (_dateOfBirth != null)
percentComplete += 7;
if (_addresses.Count > 0)
{
if (!String.IsNullOrEmpty(_addresses[0].Address1))
percentComplete += 6;
if (!String.IsNullOrEmpty(_addresses[0].Address2))
percentComplete += 6;
if (!String.IsNullOrEmpty(_addresses[0].City))
percentComplete += 6;
if (!String.IsNullOrEmpty(_addresses[0].Postcode))
percentComplete += 6;
}
if (!String.IsNullOrEmpty(Location))
percentComplete += 8;
if (!String.IsNullOrEmpty(Mobile))
percentComplete += 8;
if (!String.IsNullOrEmpty(UserName))
percentComplete += 6;
if (!String.IsNullOrEmpty(Email))
percentComplete += 6;
if (!String.IsNullOrEmpty(Password))
percentComplete += 6;
if (!String.IsNullOrEmpty(AvatarUrl))
percentComplete += 10;
return percentComplete;
}
}
public virtual IDictionary<Guid, RecipeNote> RecipeNotes
{
get { return _recipeNotes; }
set { _recipeNotes = value; }
}
public virtual int FailedLogins
{
get { return _failedLogins; }
set { _failedLogins = value; }
}
public virtual ExtendedUserData ExtendedUserData
{
get { return _extendedUserData; }
set { _extendedUserData = value; }
}
public virtual bool TermsAndConditionsAccepted
{
get { return _termsAndConditionsAccepted; }
set { _termsAndConditionsAccepted = value; }
}
#endregion
#region constructors
public SiteUser() : base()
{
_addresses = new List<Address>();
_optIns = new List<OptIn>();
//_branch = new Branch();
_dateOfBirth = null;
_title = null;
_gender = null;
_avatarUrl = null;
_extendedUserData = null;
_comments = new List<Comment>();
_allPublicComments = new List<Comment>();
_productComments = new List<ProductComment>();
_recipeComments = new List<RecipeComment>();
_blogComments = new List<BlogComment>();
_recipeNotes = new Dictionary<Guid, RecipeNote>();
_competitionResponses = new List<CompetitionResponse>();
}
#endregion
}
}
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="OurClient.core.domain.User,OurClient.core" table="Users" discriminator-value="0">
<cache usage="read-write"/>
<id name="Uid" column="Uid" type="System.Guid" unsaved-value="00000000-0000-0000-0000-000000000000">
<generator class="guid"/>
</id>
<discriminator column="UserType" type="Int32"/>
<timestamp name="UpdateTimestamp" column="updatetimestamp" />
<property column="Version" type="Int32" name="Version" not-null="true" />
<property column="FirstName" type="String" name="FirstName" not-null="true" length="100" />
<property column="Surname" type="String" name="Surname" not-null="false" length="100" />
<property column="Email" type="String" name="Email" not-null="true" length="100" />
<property column="UserName" type="String" name="UserName" not-null="false" length="100" />
<property column="Password" type="String" name="Password" length="100" />
<property column="EncryptedPassword" name="_encryptedPassword" type="String" not-null="true" access="field"/>
<property column="Mobile" type="String" name="Mobile" length="200" />
<property column="Landline" type="String" name="Landline" length="200" />
<property column="inserttimestamp" type="DateTime" name="InsertTimestamp"/>
<property column="LastUseTimeStamp" type="DateTime" name="LastUseTimeStamp" not-null="false"/>
<property column="updatetimestamp" type="DateTime" name="UpdateTimestamp" update="false" insert="false" />
<subclass name="OurClient.core.domain.AdminUser, OurClient.core" discriminator-value="1" lazy="true">
<bag name="Roles" table="UserRoles" inverse="false" lazy="true" generic="true" cascade="save-update">
<key column="UserUid"/>
<many-to-many class="OurClient.core.domain.Role, OurClient.core" column="RoleId"/>
</bag>
<bag name="WfiRegions" table="WFIRegionUsers" inverse="false" lazy="true" cascade="save-update" >
<cache usage="read-write"/>
<key column="UserUID"/>
<many-to-many class="OurClient.core.domain.WfiRegion, OurClient.core" column="RegionUID" not-found="ignore"/>
</bag>
<bag name="Products" inverse="true" lazy="true" table="ProductBuyers" cascade="save-update">
<key column="BuyerUid"/>
<many-to-many class="OurClient.core.domain.Product, OurClient.core" column="ProductUid"/>
</bag>
</subclass>
<subclass name="OurClient.core.domain.SiteUser, OurClient.core" discriminator-value="2" lazy="true">
<bag name="Addresses" inverse="false" lazy="true" generic="true" cascade="all">
<key column="UserUid"/>
<one-to-many class="OurClient.core.domain.Address,OurClient.core"/>
</bag>
<bag name="OptIns" table="OptInsLink" inverse="false" lazy="true" cascade="save-update" >
<cache usage="read-write"/>
<key column="UserId"/>
<many-to-many class="OurClient.core.domain.OptIn, OurClient.core" column="OptInId" not-found="ignore"/>
</bag>
<many-to-one name="Branch" column="BranchId" class="OurClient.core.domain.Branch,OurClient.core" />
<many-to-one name="ScrapBook" column="ScrapbookUid" class="OurClient.core.domain.Scrapbook,OurClient.core" cascade="all" not-found="ignore" insert="true" update="true"/>
<property column="Activated" type="Boolean" name="Activated" not-null="true" />
<property column="Title" type="String" name="Title" not-null="false" length="10" />
<property column="Gender" type="Boolean" name="Gender" not-null="false" />
<property column="DateOfBirth" type="DateTime" name="DateOfBirth" not-null="false" />
<property column="Location" type="String" name="Location" not-null="false" length="10" />
<property column="AvatarUrl" type="String" name="AvatarUrl" not-null="false" length="100" />
<property column="FailedLogins" type="Int32" name="FailedLogins" not-null="false" />
<bag name="Comments" inverse="false" generic="true" lazy="true" cascade="all" order-by="inserttimestamp DESC" where="Deleted=0">
<cache usage="read-write"/>
<key column="UserUid"/>
<one-to-many class="OurClient.core.domain.Comment,OurClient.core"/>
</bag>
<bag name="RecipeComments" inverse="false" generic="true" lazy="true" cascade="all" where="Deleted=0 AND CommentType=1" order-by="inserttimestamp DESC">
<cache usage="read-write"/>
<key column="UserUid"/>
<one-to-many class="OurClient.core.domain.RecipeComment,OurClient.core"/>
</bag>
<bag name="BlogComments" inverse="false" generic="true" lazy="true" cascade="all" where="Deleted=0 AND CommentType=2" order-by="inserttimestamp DESC">
<cache usage="read-write"/>
<key column="UserUid"/>
<one-to-many class="OurClient.core.domain.BlogComment,OurClient.core"/>
</bag>
<bag name="ProductComments" inverse="false" generic="true" lazy="true" cascade="all" where="Deleted=0 AND CommentType=3" order-by="inserttimestamp DESC">
<cache usage="read-write"/>
<key column="UserUid"/>
<one-to-many class="OurClient.core.domain.ProductComment,OurClient.core"/>
</bag>
<bag name="AllPublicComments" inverse="false" generic="true" lazy="true" cascade="all" order-by="inserttimestamp DESC" where="Approved=1 AND Deleted=0">
<cache usage="read-write"/>
<key column="UserUid"/>
<one-to-many class="OurClient.core.domain.Comment,OurClient.core"/>
</bag>
<map name="RecipeNotes" inverse="true" generic="true" lazy="true" cascade="all-delete-orphan">
<key column="UserUid"/>
<index column="RecipeUid" type="System.Guid"/>
<one-to-many class="OurClient.core.domain.RecipeNote,OurClient.core"/>
</map>
<bag name="CompetitionResponses" inverse="false" generic="true" lazy="true" cascade="all">
<cache usage="read-write"/>
<key column="SiteUserUid"/>
<one-to-many class="OurClient.core.domain.CompetitionResponse,OurClient.core"/>
</bag>
<one-to-one name="ExtendedUserData" class="OurClient.core.domain.ExtendedUserData,OurClient.core" property-ref="User" cascade="all-delete-orphan" />
<property column="TermsAndConditionsAccepted" type="Boolean" name="TermsAndConditionsAccepted" not-null="true" />
</subclass>
<subclass name="OurClient.core.domain.SiteModerator, OurClient.core" discriminator-value="3" lazy="true">
<property column="FailedLogins" type="Int32" name="FailedLogins" not-null="false" />
<bag name="Roles" table="UserRoles" inverse="false" lazy="true" generic="true" cascade="save-update">
<key column="UserUid"/>
<many-to-many class="OurClient.core.domain.Role, OurClient.core" column="RoleId"/>
</bag>
</subclass>
</class>
<sql-query name="GetScreenNameSuggestions">
<return-scalar column="Screenname" type="String" />
exec GetScreenNameSuggestions :firstname, :surname
</sql-query>
</hibernate-mapping>