Ok I get why you need to constrain:

>From here again: http://www.hibernate.org/162.html#A5

But now imagine your B object may or may not have associated C
(constrained="false"). What should getCee() return when specific B
does not have C? Null. But remember, Hibernate must set correct value
of "cee" at the moment it set B (because it does no know when someone
will call getCee()). Proxy does not help here because proxy itself in
already non-null object.



Cheers, Sorry for the 100 page thread too :P...

On Thu, Nov 13, 2008 at 9:35 PM, Johannes <[EMAIL PROTECTED]> wrote:
>
> This is how I did it mapping 2 entities to 1 table:
>
> <?xml version="1.0" encoding="utf-8" ?>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
> lazy="true" assembly="InExchange.Domain"
> namespace="InExchange.Domain">
>  <class name="Invoice" table="ib_Invoice">
>    <id name="InvoiceId">
>      <generator class="native"></generator>
>    </id>
>
>    <!-- lazy load does not work with one-to-one relations -->
>    <many-to-one name="Data" column="InvoiceId" unique="true"
> insert="false" update="false" cascade="save-update"></many-to-one>
>  </class>
> </hibernate-mapping>
>
> <?xml version="1.0" encoding="utf-8" ?>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
> lazy="true" assembly="InExchange.Domain"
> namespace="InExchange.Domain">
>  <class name="InvoiceData" table="ib_Invoice">
>    <id name="InvoiceId">
>      <generator class="native"></generator>
>    </id>
>
>    <property name="BlobData"></property>
>
>  </class>
>
> </hibernate-mapping>
>
> Notice the insert="false" update="false" in the relation. I had to set
> them to avoid multiple inserts and other strange behaviour. Also, on
> insert, you must set the Data property to null before Save(), then
> issue a Refresh() to let NH create a proxy object. Then you can access
> InvoiceData.BlobField and then call Flush().
>
> Maybe there is a better way though...
>
> Regards,
> Johannes
>
>
> On 13 Nov, 13:34, "Stefan Sedich" <[EMAIL PROTECTED]> wrote:
>> Final try:
>>
>> <one-to-one name="DocumentFile" cascade="all-delete-orphan"
>> lazy="proxy" constrained="true" />
>>
>> WORKS!!! Why is this the case can anyone shed some light why
>> constrained="true" on the Document worked?
>>
>>
>>
>> On Thu, Nov 13, 2008 at 9:28 PM, Stefan Sedich <[EMAIL PROTECTED]> wrote:
>> > Arggggggggggg I was wrong this does not work. Seriously if I could
>> > throw NH out the window right now I would hehe. :\
>>
>> > On Thu, Nov 13, 2008 at 9:25 PM, Fabio Maulo <[EMAIL PROTECTED]> wrote:
>> >> property lazynees is not supported in NH basically because we need
>> >> FieldInterceptors (AFIK not experimented in .NET)
>>
>> >> 2008/11/13 codemonkey <[EMAIL PROTECTED]>
>>
>> >>> Is this possible in NH? I have googled forever and cannot find any
>> >>> info at all? My only option it seems is to use a seperate table to my
>> >>> image and map using a one-to-one with lazy set tot true.
>>
>> >>> Any advice would be good..
>>
>> >>> Cheers
>> >>> Stefan
>>
>> >> --
>> >> Fabio Maulo
>>
>> > --
>> > Stefan Sedich
>> > Software Developer
>> >http://weblogs.asp.net/stefansedich
>>
>> --
>> Stefan Sedich
>> Software Developerhttp://weblogs.asp.net/stefansedich
>
> >
>



-- 
Stefan Sedich
Software Developer
http://weblogs.asp.net/stefansedich

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