Post your mapping for the Favourite class?

It looks like you probably have a NOT NULL constraint on the foreign
key mapping the Favourite to User. Do other collections reference the
Favourite class? Sometimes all-delete-orphan doesn't work if the
entity is not actually an orphan.


 -Will

On Tue, Dec 23, 2008 at 5:23 AM, Craig van Nieuwkerk <[email protected]> wrote:
> Thanks, but I still get the same error.
>
> On Wed, Dec 24, 2008 at 12:04 AM, Stefan Sedich <[email protected]>
> wrote:
>>
>> Try Change cascade on the collection to all-delete-orphan so that the
>> child items are removed on deletion
>>
>> Cheers
>>
>> Stefan Sedich
>>
>>
>> On 23/12/2008, at 9:40 PM, "Craig van Nieuwkerk" <[email protected]>
>> wrote:
>>
>> > I have a Master Detail relationship configured. The hbm file is
>> > below. When I run some code like this
>> >
>> > Favourite favourite = favourites.Find(f => f.Id== id);
>> > user.Favourites.Remove(favourite);
>> > m_UserRepository.Save(ref user);
>> >
>> > I get the error message
>> >
>> > NHibernate.Exceptions.GenericADOException: could not delete
>> > collection rows: [Model.Entities.User.Favourites#249][SQL: SQL not
>> > available] ---> System.Data.SqlClient.SqlException: Cannot insert
>> > the value NULL into column 'UserId', table 'BE.Favourite'; column
>> > does not allow nulls. UPDATE fails.
>> >
>> > Any suggestions on what this means please help.
>> >
>> > Craig.
>> >
>> > <?xml version="1.0" encoding="utf-8" ?>
>> > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
>> > namespace="Model.Entities" schema="BE" assembly="Model" default-
>> > lazy="false">
>> >   <class name="Model.Entities.User, Model" table="Users" >
>> >     <id name="UserId" column="UserId" type="int" unsaved-value="0">
>> >       <generator class="native" />
>> >     </id>
>> >     <property name="UserName" column="UserName" type="string" />
>> >
>> >     <bag name="Favourites" cascade="all" lazy="true">
>> >       <key column="UserId"/>
>> >       <one-to-many class="Model.Entities.Favourite, Model"/>
>> >     </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
-~----------~----~----~----~------~----~------~--~---

Reply via email to