Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Relationship Mappings/Common Relationship Configurations/JoinFetch"
< EclipseLink | UserGuide | JPA | Basic JPA Development | Mapping | Relationship Mappings | Common Relationship Configurations
m |
m |
||
Line 8: | Line 8: | ||
|apis= | |apis= | ||
* [http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/annotations/JoinFetch.html @JoinFetch] | * [http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/annotations/JoinFetch.html @JoinFetch] | ||
− | + | ||
}} | }} | ||
− | = | + | =@JoinFetch= |
− | + | ||
− | + | Use the <tt>@JoinFetch</tt> annotation to enable the joining and reading of the related objects in the same query as the source object. | |
− | + | {{EclipseLink_Note | |
− | = | + | |note=We recommend setting join fetching at the query level, as not all queries require joining. |
+ | }} | ||
You can specify the <tt>@JoinFetch</tt> annotation for the following mappings: | You can specify the <tt>@JoinFetch</tt> annotation for the following mappings: | ||
Line 26: | Line 26: | ||
* <tt>[[#How to Use the @BasicMap Annotation|@BasicMap]]</tt> | * <tt>[[#How to Use the @BasicMap Annotation|@BasicMap]]</tt> | ||
− | |||
− | |||
− | |||
− | |||
Alternatively, you can use batch reading, especially for collection relationships.]]. | Alternatively, you can use batch reading, especially for collection relationships.]]. |
Revision as of 15:47, 16 May 2011
EclipseLink JPA
EclipseLink | |
Website | |
Download | |
Community | |
Mailing List • Forums • IRC • mattermost | |
Issues | |
Open • Help Wanted • Bug Day | |
Contribute | |
Browse Source |
Key API
@JoinFetch
Use the @JoinFetch annotation to enable the joining and reading of the related objects in the same query as the source object.
Note: We recommend setting join fetching at the query level, as not all queries require joining.
You can specify the @JoinFetch annotation for the following mappings:
- @OneToOne
- @OneToMany
- @ManyToOne
- @ManyToMany
- @BasicCollection
- @BasicMap
Alternatively, you can use batch reading, especially for collection relationships.]].
Attribute | Description | Default | Required? |
---|---|---|---|
value | Set this attribute to the org.eclipse.persistence.annotations.JoinFetchType enumerated type of the fetch that you will be using.
The following are the valid values for the JoinFetchType:
|
JoinFetchType.INNER | No |
The following example shows how to use the @JoinFetch annotation to specify Employee field managedEmployees.
Example: @JoinFetch Annotation
@Entity public class Employee implements Serializable { ... @OneToMany(cascade=ALL, mappedBy="owner") @JoinFetch(value=OUTER) public Collection<Employee> getManagedEmployees() { return managedEmployees; } ... }