@JoinFetch doesn't work with mappings on Embeddables [message #1017753] |
Tue, 12 March 2013 09:34  |
Eclipse User |
|
|
|
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 10:00  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.03674 seconds