Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » @JoinFetch doesn't work with mappings on Embeddables
@JoinFetch doesn't work with mappings on Embeddables [message #1017753] Tue, 12 March 2013 13:34 Go to next message
J LM is currently offline J LMFriend
Messages: 11
Registered: December 2012
Junior Member
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
Bug submitted : https://bugs.eclipse.org/bugs/show_bug.cgi?id=402866

Any idea of where to search/patch in eclipselink code ?

Re: @JoinFetch doesn't work with mappings on Embeddables [message #1021086 is a reply to message #1017753] Tue, 19 March 2013 14:00 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Only the local relationships are checked for @JoinFetch (@BatchFetch), nested relationships are not checked (issues of cycles, etc).

Checking embeddables would make sense though, this should be possible.
(the start of the fix would be in ObjectBuilder.initializeJoinedAttributes(), then JoinAttributeManager.processJoinedMappings())

You can use the "eclipselink.join-fetch" query hint to join through an embeddable on a specific query.


James : Wiki : Book : Blog : Twitter
Previous Topic:Cached Map Update NPE on element remove
Next Topic:EclipseLink adding extra parens which postgreSQL doesn't like
Goto Forum:
  


Current Time: Tue Apr 23 15:22:34 GMT 2024

Powered by FUDForum. Page generated in 0.03600 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top