Can you check if an issue exists in Jira, and, if not, create one with unit 
tests?
Thanks!

RP

On Wednesday, August 5, 2015 at 3:04:26 PM UTC+1, Jan Schubert wrote:
>
> I posted the same question to the nhibernate-development group. Now, I 
> think this group is more <http://www.dict.cc/englisch-deutsch/more.html> 
> suitable <http://www.dict.cc/englisch-deutsch/suitable.html>.
>  
> ISession.Lock does not determine proxies when proxies are used in a many 
> to many relation using cascading.
>
> Given is the following mapping:
>
> <class name="Person" table="Persons" >
>   <id name="Id">
>     <generator class="hilo">
>       <param name="table">AppDBHiLo</param>
>       <param name="column">NextHiValue</param>
>       <param name="max_lo">10</param>
>     </generator>
>   </id>
>
>   <list name="Contacts" lazy="true" cascade="all-delete-orphan" 
> table="Persons_Contacts">
>     <key column="PersonId"/>
>     <index column="Position"></index>
>     <many-to-many class="Contact" column="ContactId"/>
>   </list>
> </class>
>
> <class name="Contact" table="Contacts" >
>   <id name="Id">
>     <generator class="hilo">
>       <param name="table">AppDBHiLo</param>
>       <param name="column">NextHiValue</param>
>       <param name="max_lo">10</param>
>     </generator>
>   </id>
>
>   <list name="Entries" lazy="true" cascade="all-delete-orphan" 
> table="Contacts_ContactEntries">
>     <key column="ContactId"/>
>     <index column="Position"></index>
>     <many-to-many class="ContactEntry" column="ContactEntryId"/>
>   </list> 
> </class>
>
> <class name="ContactEntry" table="ContactEntries" >
>   <id name="Id">
>     <generator class="hilo">
>       <param name="table">AppDBHiLo</param>
>       <param name="column">NextHiValue</param>
>       <param name="max_lo">10</param>
>     </generator>
>   </id>
>   <discriminator column="EntryType" insert="false" type="int"/> 
>   <property name="EntryType" not-null="false" />
>
>   <joined-subclass name=" ContactEntryPostalAddress" 
> table="ContactEntryPostalAddresses">
>     <key column="ContactEntryId"/>
>     <property name="Street" not-null="false" />
>     <property name="PostalCode" not-null="false" />
>     <property name="City" not-null="false" />
>     <property name="Country" not-null="false" /> 
>   </joined-subclass>
>     
>   <joined-subclass name="ContactEntryValue" table="ContactEntryValues">
>     <key column="ContactEntryId"/>
>     <property name="Value" not-null="false" /> 
>   </joined-subclass>
> </class>
>
> EntryType is an enum with values: PostalAddress = 0, Value = 1. Proxies 
> are always generated for all entities using an interceptor.
>
>    1. A person is loaded in a thread with its own session. The session is 
>    disposed as soon as loading has finished.
>    2. The person is locked to the session available inside the GUI-thread 
>    using ISession.Lock(person, LockMode.None).
>    3. A Contact is removed from the person’s contacts list and the 
>    session is flushed.
>    4. Cascading with “all-delete-orphan” deletes the unreferenced contact 
>    and its associated contact entries.
>    
> This leads to a foreign key constraint violation because contact entries 
> in the removed contact are only deleted in the base class table.
> Tracking this down reveals that ISession.Lock does not evaluate proxies 
> and therefor does not find the concrete subclass represented by that 
> object. This happens in 
> NHibernate.Persister.Entity.AbstractEntityPersister# 
> GetSubclassEntityPersister(object instance, ISessionFactoryImplementor 
> factory, EntityMode entityMode) (
> https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs#L4049).
>  
> This is commented in the source code:
> // TODO : really need a way to do something like :
> //     
>  getTuplizer(entityMode).determineConcreteSubclassEntityName(instance)
>
> The corresponding code in Hibernate has changed (
> https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java#L4381
> ).
>
> Is there an issue for that problem and can I expect a fix next time?
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to