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

Jpa joins #1085

Merged
merged 6 commits into from Jun 26, 2018

Conversation

@Traivor
Copy link
Contributor

Traivor commented Jun 25, 2018

This makes several improvements to how joins are handled in the JPA connector.

Traivor added 6 commits Jun 8, 2018
Implicit joins are those where the synthesized foreign key is selected
from a table. At the JPA level this requires navigating the relationship
to the related entity and getting its id. Existing behavior does an
inner join which means any case where the relation is null would simply
exclude that row from results. This is incorrect behavior. It should
instead allow the null value to be returned. Hence left outer join.

Inner join behavior can be had by explicitly specifiying the join in the
SQL.
…/right.

The names customer/address were messing with my head when trying to
reason about this code. My guess is the customer/address names leaked from
the test case ddl.
It's not clear to me what this is trying to accomplish. The *ToOne
side of a relationship is handled by addSingularAttributes. The
ManyToMany case would surely need a join table created, which this
method does not do. The OneToMany which this method tries to do
something with is unnecessary as far as I can reason, and it results in
an explosion of row results because of joining the relationship in even
the simplist of query (select * from entity).
Old behavior uses a relation's PK as the name of the FK column in the
parent. If the entities happen to use the same name for their IDs you
get a collision and only one column ends up exposed. I for one always
name my entity ids 'id'.

This change instead names the FK column(s)
$parentAttribute_$childIdProperty.
…ties.

These properties are added to FK columns so downstream processing knows
the parent attribute and the child id property associated with the
column. This is necessary for disambiguating joins.
Old behavior matches up joins based table names or table metadata
matching. This does not work when the same entity is joined multiple
times. Eg, two properties have the same entity type or a parent->child
relationship is joined.

Instead, the RELATION_* properties are used to match joins up by parent
attribute names and  child id.
@Traivor

This comment has been minimized.

Copy link
Contributor Author

Traivor commented Jun 25, 2018

@rareddy rareddy merged commit f7e9f5e into teiid:master Jun 26, 2018
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@rareddy

This comment has been minimized.

Copy link
Member

rareddy commented Jun 26, 2018

Thank you for the contribution

@Traivor Traivor deleted the Traivor:jpa_joins branch Jun 26, 2018
@Traivor Traivor restored the Traivor:jpa_joins branch Jun 26, 2018
shawkins added a commit that referenced this pull request Jun 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.