Lazy initialization on collection

Hi VP,

Just a question, is it possible to Add an object to a persistent collection (like hashedset) without lazily initializing it?

I mean:

NET C#:
Class1.MyCollection.Add(myNewObject)

This causes the “MyCollection” to be initialized… just for adding only a new item. If collection is huge… then the process takes “ages”.

Is it possible to avoid this initialization, or at least limit the result set to, say 10 or few records?

BTW for your info, when dealing with this problem I also found that when you manually set the cascade behavior of both roles of an association to “none”, when adding an element and later on do a DAO.Save(object), a persistent exception is thrown with the message: “Failed to lazily initialize a collection - no session” :evil: . But… a session was “alive”.

I did not “catch” the origin of that problem yet, I will let you know if I can reproduce in a simple model.

Many thanks for your info
(I’m using DBVA latest build by now: 20071116h)

Hello distansia,

Let me ask our developers first. Will let you know the answer shortly. :slight_smile:

Best regards,
Jick

Hi distansia,

is it possible to Add an object to a persistent collection (like hashedset) without lazily initializing it?

It seems that it is not possible, because it is the NHibernate’s lazy collection implementation.

Concerning the problem “Failed to lazily initialize a collection - no session”, we are unable to reproduce it. Could ou send me your project and test case? This is my Email address:
jick@visual-paradigm.com

Please also answer the questions below in order for us to reproduce the problem:
=> What session type are you using? It is THREAD_BASE by default. But you may customize it in the generated persistent manager.
=> Where was the session came from? getting from the persistent manager? or get from httpSession (web application)?
=> You said that the session was “alive”, is this session the one connected by the collection? (I mean the session for loading the collection owner object)

We look forward to hearing from you.

Best regards,
Jick

[quote=Jick]Concerning the problem “Failed to lazily initialize a collection - no session”, we are unable to reproduce it. Could ou send me your project and test case? This is my Email address:
jick@visual-paradigm.com
[/quote]

Hi Jick,

The evaluation period at my company ended few days ago, but I will continue helping you with this problem from home. Please be patient because now I will have less time available for this software, but sure I will.

My final verdict about your software is 4/5 **** on features needed by us, and 5/5 ***** (if not 6/5) on support :smiley:

I will contact you as soon as I can about this problem. But I think it was caused mainly by bad code I should made at the beginning of the evaluation.

Many thanks for all your effort!!

Hi distansia,

Oh, I didn’t really remember you are an evaluation user. You really did a lot to help us improve. We can’t thank you enough! :smiley: :smiley: :smiley:

Many thanks for all your effort as well !!!

Bet regards,
Jick

[quote=Jick]Please also answer the questions below in order for us to reproduce the problem:
=> What session type are you using? It is THREAD_BASE by default. But you may customize it in the generated persistent manager.
=> Where was the session came from? getting from the persistent manager? or get from httpSession (web application)?
=> You said that the session was “alive”, is this session the one connected by the collection? (I mean the session for loading the collection owner object)
[/quote]

Hi Jick,

Sorry for being too late. Now I have no much free time to test things, but I will try.

Concerning the error message, I have not found it… yet. But, I can answer some of your questions:

-Session Type: THREAD_BASE (you were right)
-The session went from the PersistentManager (the test application is a Windows Forms one)

BTW, I am using “DAO Factory (with Interface)” when generating ORM Code, if it helps.

Anyway, I will mail you when I see that error message again.

Thanks!! :stuck_out_tongue: You did a lot too to improve things quickly! your support impressed us a lot