I believe you are correct that in the app I would not likely end up with a 
disassociated entity to delete. 
I have changed my test class to share the same session across the various 
tests. This allows me to delete without a problem although left with a 
different error upon reinserting which I posted about separately. 
Once again thank you for your assistance. 
-----Original Message-----
From: Diego Mijelshon <[email protected]>
Date: Thu, 28 Jan 2010 15:11:31 
To: nhusers<[email protected]>
Subject: Re: [nhusers] Delete fails references not-null transient object

While it might work on a limited number of cases, it's not a good idea to
call Delete on entities that are not associated with the session, SPECIALLY
if you have cascades.
The question is, how would you end with such an object in your app?
In the test, it's clearly because you are creating it on that
"CreateInitialData" method.

   Diego


On Thu, Jan 28, 2010 at 12:00, Yonah Wahrhaftig <[email protected]>wrote:

> Diego thank you for the quick response. Could you elaborate a little on
> what you mean. Both sessions are coming from the same session factory which
> seems to have worked for me in the past.
> Do I have to first associate the given PurchaseOrder with the session? How
> would I do that?
>
> I see that I can make it work if I have all my tests, setup and cleanup
> share the same session. Is that the recommended way to work? I am surprised
> that my tests for my other classes didn't share the same problem since it
> does very similar work and even joins with the same User class.
>
> Thank you very much for your assistance,
> Yonah
> ------------------------------
> *From: * Diego Mijelshon <[email protected]>
> *Date: *Thu, 28 Jan 2010 11:45:25 -0300
> *To: *nhusers<[email protected]>
> *Subject: *Re: [nhusers] Delete fails references not-null transient object
>
> The PurchaseOrder is not associated with that session.
>
>    Diego
>
>
> On Thu, Jan 28, 2010 at 11:21, Yonah Wahrhaftig <[email protected]>wrote:
>
>>  Thank you for your response
>>
>>
>>
>> I am not assigning the user during the same transaction.
>>
>>
>>
>> Although I can see by debugging that it has loaded the user from the
>> database when retrieving the Item prior to deleting.
>>
>>
>>
>> I have posted the relevant code to PasteBin.
>>
>>
>>
>> http://pastebin.com/m385a6457
>>
>>
>>
>>
>>
>> *From:* [email protected] [mailto:[email protected]] *On
>> Behalf Of *Diego Mijelshon
>> *Sent:* Thursday, January 28, 2010 7:11 AM
>> *To:* nhusers
>> *Subject:* Re: [nhusers] Delete fails references not-null transient
>> object
>>
>>
>>
>> It's kinda hard to help without the code...
>>
>> Are you assigning the user during this transaction?
>>
>>    Diego
>>
>>  On Wed, Jan 27, 2010 at 19:38, Yonah Wahrhaftig <[email protected]>
>> wrote:
>>
>> I have a many-to-one relationship between item and user. User is set to
>> mutable = false.  When I try to delete an item I get an error about there
>> being the User being null or transient.
>> Why does NH care about the user if it isn't mutable. Is there a cascade by
>> default which I have to set as none? Is this likely an issue with my
>> mappings?
>> I don't have the code in front of me at the moment to show my mappings and
>> calling code but I believe that my understanding of NH is what is really
>> lacking here.
>> If there are too many possibilities to glean anything without the mappings
>> please mention this and I will respond when I return to my desk.
>> Thank you,
>> Yonah
>>
>> --
>> 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]<nhusers%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/nhusers?hl=en.
>>
>>
>>
>> --
>> 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]<nhusers%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/nhusers?hl=en.
>>
>>   --
>> 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]<nhusers%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/nhusers?hl=en.
>>
>
>  --
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
> --
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>

-- 
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.


-- 
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