Hi Markus,

We implemented it OneToOne:

public class Texture{
  [OneToOne(Constrained = true,Fetch=FetchEnum.Select)]
  public TextureImage TextureImage{get; set;}//the class with blobs
}

public class TextureImage{
  [OneToOne]
  public Texture Texture { get; set; }
}

However it still loads both, and then makes the killer updates:

SELECT texture0_.Id as Id21_0_, ...
FROM Textures texture0_
WHERE [EMAIL 
PROTECTED]',N'@p0uniqueidentifier',@p0='E68A1E62-E640-458E-92CE-9B5B00C6714A'

SELECT textureima0_.Id as Id17_1_, textureima0_.ImageBinaryMin as
ImageBin2_17_1_... texture1_.Id as Id21_0_,
FROM TextureImages textureima0_
left outer join Textures texture1_ on textureima0_.Id=texture1_.Id
WHERE [EMAIL 
PROTECTED]',N'@p0uniqueidentifier',@p0='E68A1E62-E640-458E-92CE-9B5B00C6714A'

If we don't add the Fetch, it will just do one SELECT which will load all,
including the blobs, and there's not way to set Lazy=true.

Thanks,

Dan


On Wed, Nov 19, 2008 at 3:12 PM, Markus Zywitza <[EMAIL PROTECTED]>wrote:

> You attach the object to a different session. Dirty checking uses
> first-level-cache which is tied to the session. NH must therefore perform an
> update to assure that there has not been any changes to the object before it
> was attached to the session.
>
> The "AND Version = @p3' AND Path = @p1" part is NH's optimistic locking. If
> the data has changed, 0 rows are affected and NH detects an concurrent
> change to data.
>
> To save you SQLServer from being killed you have to use a lazy loaded
> 1-on-1-relation between object and BLOBs. See the NH FAQ blog for a tutorial
> on this.
>
> -Markus
>
>
> 2008/11/19 Dan Bunea <[EMAIL PROTECTED]>
>
>> Hi,
>>
>> In our application, there was a reauirement to have Guids as Ids. However
>> we have an odd behaviour: havina a class Texture, with and Id:Guid and a
>> property Path:string if I do something like:
>>
>> Texture t=null;
>> using(SessionScope s1 = new SessionScope())
>> {
>> t = Texture.Find(someTexture.Id);// we added it before
>> }
>> using(SessionScope s1 = new SessionScope())
>> {
>> t.Save();
>> }
>>
>> on t.Save() it will do an update such as:
>>
>> UPDATE Textures SET Version = @p0, Path = @p1, WHERE Id = @p2 AND Version
>> = @p3' AND Path = @p1,
>>
>> Problems:
>>
>> 1. Since NH has dirty checking why does it even perform the update since
>> nothing is changed.
>> 2. Even if something has changed why isn't the update only using the Id
>> like
>>
>> UPDATE Textures SET Version = @p0, Path = @p1, WHERE Id = @p2
>>
>> and not all the properties??
>>
>> Thanks,
>>
>> Because of problem 1 we have a multitude of UPDATES being performed some
>> with BLOBS and it is killing the sql server.
>>
>> --
>> Dan Bunea
>> http://www.danbunea.ro
>>
>>  >>
>>


-- 
Dan Bunea
http://www.danbunea.ro

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to