| Summary: | Use TYPE expression to limit joins/calls with joined inheritance on a root entity | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Chris Delahunt <christopher.delahunt> |
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> |
| Status: | NEW --- | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | kokwai.looi |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Chris Delahunt
Hi Chris, I am referring to your comments in http://myforums.oracle.com/jive3/thread.jspa?threadID=868053&tstart=0. Assume that the class hierarchy is as such: Equipment > CiscoEquipment > CiscoRouter. (> = "parent class of") I know if we have queried for the base Equipment class, EL would automatically add the subclasses CiscoEquipment and CiscoRouter as outer joins, especially when we use range. If the query is for CiscoEquipment however, would there still be any outer join at least to the CiscoRouter subclass? I assume if the query result class is for CiscoRouter then there is no more join generated because only that subclass is requested. What happens if we set "ClassDescriptor.getDescriptorInheritancePolicy().setShouldReadSubclasses(false)". When we execute explicit query for Equipment, CiscoEquipment, or CiscoRouter classes, is it true that since this descriptor property is set to false there should be no outer join generated but we have to also expect that some rows would be missing from the results because of the joins being removed. Thanks. The EclipseLink user mailing list (eclipselink-users@eclipse.org) or the forums might be a better place to to questions. JPA requires selecting all subclasses when you query on a parent class type, so queries on CiscoEquipment will require bringing back CiscoRouter entities as well. EclipseLink will use outerjoining if counts/pagination is involved. I've not tried using setShouldReadSubclasses(false) but it looks like it will prevent this behavior. This setting will force queries on Equipment to return only Equipment instances - and exclude data that might be in CiscoEquipment and CiscoRouter. You would then need to query on each subclass explicitly to get those results if required. The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |