Bug 402866 - @JoinFetch doesn't work with mappings on Embeddables
Summary: @JoinFetch doesn't work with mappings on Embeddables
Status: REOPENED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 critical with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard: submitted_patch
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2013-03-11 03:48 EDT by J LM CLA
Modified: 2022-06-09 10:35 EDT (History)
2 users (show)

See Also:


Attachments
Patch on ObjectBuilder methods : getMappingForAttributeName and initializeJoinedAttributes (3.78 KB, patch)
2013-03-25 05:50 EDT, J LM CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description J LM CLA 2013-03-11 03:48:19 EDT
Hi,
Simple use case :
TcRoot (Entity) -> TcEmbeddable (Embeddable) -> TcSubEntity (Entity)

@Entity
@Table(name = "TCEMB_ROOT")
@SequenceGenerator(name = "SEQ_TCEMB_ROOT")
public class TcRoot implements Serializable {
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE,
			generator = "SEQ_TCEMB_ROOT")
	@Column(name = "TCEMB_ROOT_ID")
	private int id;

	@Embedded
	TcEmbeddable emb;
}


@Embeddable
public class TcEmbeddable implements Serializable {
	@OneToOne
	@JoinColumn(name = "SUBE_ID", referencedColumnName = "TCEMB_SUBE_ID")
	@JoinFetch(JoinFetchType.INNER)
	TcSubEntity tcSE;
}

@Entity
@Table(name = "TCEMB_SUBE")
@SequenceGenerator(name = "SEQ_TCEMB_SUBE", sequenceName = "SEQ_TCEMB_SUBE")
public class TcSubEntity implements Serializable {
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE,
			generator = "SEQ_TCEMB_SUBE")
	@Column(name = "TCEMB_SUBE_ID")
	private int id;
}

A find on TcRoot by Id results in 2 SQL Queries : 
 - 1 retrieving TcRoot and TcEmbeddable attributes (deleted from the sample code for lisibility)
 - 1 retrieving TcSubEntity

It should produce only one query.
(Think this issue is extendable to @BatchFetch)

Issue verified with 2.3.3 and 2.4.0
Comment 1 J LM CLA 2013-03-12 03:56:05 EDT
Any idea of where to search in eclipselink code ?
Comment 2 J LM CLA 2013-03-25 05:50:30 EDT
Created attachment 228984 [details]
Patch on ObjectBuilder methods : getMappingForAttributeName and initializeJoinedAttributes
Comment 3 J LM CLA 2013-03-25 05:53:19 EDT
The attached Patch resolves the issue.
Comment 4 Tom Ware CLA 2013-03-25 07:57:56 EDT
Why are you closing this bug?  Is the patch somehow checked into the code stream?
Comment 5 Tom Ware CLA 2013-03-25 07:58:03 EDT
Why are you closing this bug?  Is the patch somehow checked into the code stream?
Comment 6 J LM CLA 2013-06-26 01:30:11 EDT
Patch is not fully functional.
Comment 7 Eclipse Webmaster CLA 2022-06-09 10:35:46 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink