Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor sequential select #1979

Merged
merged 6 commits into from
Jan 31, 2019

Conversation

maca88
Copy link
Contributor

@maca88 maca88 commented Jan 15, 2019

This PR moves the generated sequential statements form the root entity to its subclasses which then simplifies the ILoadable.Hydrate method as the root persister parameter is not needed anymore.

@hazzik hazzik force-pushed the RefactorSequentialSelect branch from ba0f915 to 4f8c972 Compare January 16, 2019 09:24
@hazzik
Copy link
Member

hazzik commented Jan 16, 2019

This sequential select feature such a mess.....

@maca88
Copy link
Contributor Author

maca88 commented Jan 16, 2019

This sequential select feature such a mess.....

And also a quite old one that hasn't changed since 2007 even in Hibernate.

I've restored the HasSequentialSelect behavior in order to avoid a breaking change and deprecate it in favor of GetSequentialSelect.

@fredericDelaporte
Copy link
Member

This sequential select feature such a mess.....

What that feature is about? Eager fetch mode select on associations?

@hazzik
Copy link
Member

hazzik commented Jan 17, 2019

What that feature is about?

It's about eager joins (<join fetch="select" ... >) inside of an entity. See here: https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate.Test/Join/JoinTest.cs#L47. It is a kind of an in-between of table-per-hierarchy and joined-subclass features.

About mapping like this:

<class name="Person" table="person" lazy="true" discriminator-value="null">
<id name="Id" column="person_id" unsaved-value="0">
<generator class="native"/>
</id>
<!-- force is unnecessary, in case we had other unknown discriminator values -->
<discriminator column="person_type" type="string" length="1" not-null="false" force="true"/>
<property name="Name" not-null="true" length="80"/>
<property name="Sex" not-null="true" update="false"/>
<join table="address">
<key column="address_id"/>
<property name="Address"/>
<property name="Zip"/>
<property name="Country"/>
</join>
<join table="phone" optional="true">
<key column="phone_id"/>
<property name="HomePhone"/>
<property name="BusinessPhone"/>
<set name="OthersPhones" cascade="all" access="property">
<key column="phone_id"/>
<element column="phone" type="string" length="20"/>
</set>
</join>
<join table="inversed_stuff" inverse="true">
<key column="stuff_id"/>
<property name="StuffName"/>
</join>
<subclass name="Employee" lazy="true" discriminator-value="E">
<join table="employee" fetch="select">
<key column="person_id"/>
<property name="Title" not-null="true" length="20"/>
<property name="Salary"/>
<many-to-one name="Manager"/>
<bag name="Meetings" cascade="all" inverse="true" access="property">
<key column="person_id"/>
<one-to-many class="Meeting"/>
</bag>
</join>
</subclass>
<subclass name="Customer" lazy="true" discriminator-value="C">
<join table="customer" fetch="select">
<key column="person_id"/>
<property name="Comments"/>
<many-to-one name="Salesperson"/>
</join>
</subclass>
<subclass name="User" lazy="true" discriminator-value="U">
<join table="t_user" fetch="select" optional="true">
<key column="person_id"/>
<property name="Login" column="u_login"/>
</join>
<join table="t_silly" fetch="select" optional="true">
<key column="person_id"/>
<property name="_Silly" column="`_Silly`" access="field"/>
</join>
</subclass>
</class>

@fredericDelaporte fredericDelaporte added this to the 5.3 milestone Jan 24, 2019
@fredericDelaporte
Copy link
Member

There are some conflicts to resolve with #1922 merge into master. For AbstractEntityPersister, they do not look trivial.

@maca88
Copy link
Contributor Author

maca88 commented Jan 30, 2019

Conflicts are resolved.

@fredericDelaporte fredericDelaporte merged commit 7ccb678 into nhibernate:master Jan 31, 2019
@maca88 maca88 deleted the RefactorSequentialSelect branch September 27, 2019 20:32
Comment on lines +448 to +449
propertyTableNumbersByNameAndSubclass[prop.PersistentClass.EntityName + '.' + prop.Name] =
persistentClass.GetJoinNumber(prop);
Copy link
Member

@bahusoid bahusoid Jul 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is wrongly placed here. This calculation makes sense only for SingleTableEntityPersister. It's wrong for all others persisters (fills dictionary with 0 for all properties).

Ok. It makes sense for sequenitial select. But it contains info only about join elements inside subclasses and 0 for all other places. So GetSubclassPropertyTableNumber(string propertyName, string entityName) behaves quite differently to GetSubclassPropertyTableNumber(string propertyPath). Which is confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants