Bug 402866

Summary: @JoinFetch doesn't work with mappings on Embeddables
Product: z_Archived Reporter: J LM <jlamande>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: REOPENED --- QA Contact:
Severity: critical    
Priority: P3 CC: martin.grebac, tom.ware
Version: unspecifiedKeywords: contributed
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: submitted_patch
Attachments:
Description Flags
Patch on ObjectBuilder methods : getMappingForAttributeName and initializeJoinedAttributes none

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