KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm getting this exception (Full exception at the bottom): NHibernate.PropertyValueException was unhandled by user code Message="not-null property references a null or transient valueClearwave.Models.Encounters.Insurance.Patient" Source="NHibernate" EntityName="Clearwave.Models.Encounters.Insurance" PropertyName="Patient" I've done a lot of Googling and it seems the most common cause for that error is when an association is bi-directional but only one half has been set. As in: Insurance.Patient = Patient is called but Patient.Insurances.Add(Insurance) is not. I do, in fact, have a scenario like that but I've checked the object just before calling Save with it and both Insurance.Patient and Patient.Insurances[0] are the right objects. The other possibility that this exception seems to reference is a transient value. In my case every object is transient so I'm suspecting the root of my problem is here. However, everything needs to be transient right now because nothing has been saved yet. I would expect NHibernate to persist things rather than complain that they are not persisted. Here are some snippets from my mappings (fluent): public PatientMap() { WithTable("tPatient"); Id(x => x.Id, "uid_Patient").GeneratedBy.GuidComb ().Access.AsReadOnlyPropertyThroughCamelCaseField(); HasMany(x => x.Insurances).WithKeyColumn("uid_Patient") .Cascade.All() .Inverse(); ... } public InsuranceMap() { WithTable("tPatientInsuranceInfo"); Id(x => x.Id, "uid_PatientInsuranceInfo").GeneratedBy.GuidComb ().Access.AsReadOnlyPropertyThroughCamelCaseField(); References(x => x.Patient, "uid_Patient").Not.Nullable ().Cascade.All(); ... } So, what could be the issue? NHibernate.PropertyValueException
Tags (comma-separated)
Save Edits
Cancel