We were able to work around this issue by ensuring the collection was initialized before adding the item.
On Tue, Feb 24, 2009 at 4:06 PM, Brian <[email protected]> wrote: > > I'm getting an exception when attempting to cascade delete a transient > entity. The error message is this... > > System.NullReferenceException: Object reference not set to an instance > of an object. > at > NHibernate.Event.Default.DefaultDeleteEventListener.DeleteTransientEntity > (IEventSource session, Object entity, Boolean cascadeDeleteEnabled, > IEntityPersister persister, ISet transientEntities) > > Searches for information on this error only show a couple of entries > from the Hibernate forum. The most recent was > http://forum.hibernate.org/viewtopic.php?p=2401548&sid=fab1f581c3b3c3... > > This error occurs only when we use the lazy="true" attribute on the > bag element. Performance will be too poor if we don't use lazy > loading. > > Has anyone seen this type of error before or have any insight or > alternatives? > > TIA > Brian > > I'm including the NHibernate file below for reference. The error > occurs when a new ReviewerComment record is added, then removed, and > then the FieldAnswer is saved. > > <?xml version="1.0" encoding="utf-8" ?> > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default- > lazy="false"> > <class > name="TOPAZ.Domain.Forms.Answers.Sections.Fields.FieldAnswer, > TOPAZ" table="FIELD_ANSWER"> > <cache usage="read-write"/> > <id name="FieldAnswerID" type="Int32" > column="FIELD_ANSWER_ID"> > <generator class="native"> > <param > name="sequence">FIELD_ANSWER_ID_SEQ</param> > </generator> > </id> > > <discriminator column="FIELD_TYPE_ID" type="String"/> > > <property name="Index" type="Int32" column="FIELD_ANSWER_ORDER" > not-null="true"/> > <property name="PreviousReviewSummaryID" type="Int32" > column="PREV_FIELD_ANSWER_REV_SUM_ID" not-null="false"/> > <property name="FieldAnswerDataHash" type="String" > column="ANSWER_DATA_HASH" not-null="false"/> > > <many-to-one name="SectionAnswer" > class="TOPAZ.Domain.Forms.Answers.Sections.SectionAnswerBase, TOPAZ" > column="SECTION_ANSWER_ID" lazy="proxy"/> > <many-to-one name="FieldLink" > class="TOPAZ.Domain.Forms.Structure.Sections.FieldLink, TOPAZ" > column="SECTION_FIELD_ID"/> > > <component name="Timestamp" class="TOPAZ.Domain.Timestamp, TOPAZ"> > <property name="CreatedByStaff" type="String" > column="CREATED_BY_STAFF" not-null="true"/> > <property name="UpdatedByStaff" type="String" > column="UPDATED_BY_STAFF" not-null="false"/> > <property name="CreatedDateTime" type="DateTime" > column="CREATED_DATETIME" not-null="true"/> > <property name="UpdatedDateTime" type="DateTime" > column="UPDATED_DATETIME" not-null="false"/> > </component> > > <bag name="reviewerComments" access="field" generic="true" > inverse="true" cascade="all-delete-orphan" order- > by="REVIEWER_COMMENTS_ID asc" lazy="true"> > <cache usage="read-write"/> > <key column="FIELD_ANSWER_ID" /> > <one-to-many > class="TOPAZ.Domain.Reviews.ReviewerComments.ReviewerComment, TOPAZ"/> > </bag> > > <bag name="commentSummary" access="field" generic="true" > inverse="true" cascade="all-delete-orphan" lazy="true"> > <cache usage="read-write"/> > <key column="FIELD_ANSWER_ID" /> > <one-to-many > > class="TOPAZ.Domain.Forms.Answers.Sections.Fields.FieldAnswerCommentSummary, > TOPAZ"/> > </bag> > > <bag fetch="select" name="fieldAnswerAttachments" access="field" > generic="true" inverse="true" cascade="all-delete-orphan" lazy="true" > > <cache usage="read-write"/> > <key column="FIELD_ANSWER_ID" /> > <one-to-many > class="TOPAZ.Domain.Forms.Answers.Sections.Fields.FieldAnswerAttachment, > TOPAZ"/> > </bag> > > </class> > > </hibernate-mapping> > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
