openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alejandro Abdelnur <>
Subject getting ID only of OneToOne and ManyToOne relationships
Date Thu, 25 Feb 2016 04:49:42 GMT

I've spent quite a bit of time searching around without any luck.

With OpenJPA 2.x, is it possible to get the foreign key of a OneToOne
relationship in the source without loading the target entity?

For example:

public class A {
  private String id;
  private String name;
 @OneToOne(fetch = FetchType.LAZY)
  private B b;

public class B {
  private String id;
  private String name;

Even if 'A a = em.find(A.class, "1")' loads the columns 'ID, NAME, B_ID'
from A if I do 'a.getB().getId()' this triggers a new query on B to get ID.

The closest related thing I found is
, but this does not seem to apply to OpenJpa.

Similarly for ManyToOne relationships?

Thanks in advance.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message