I found that em.getReference acts the same way as em.find, I mean it does fetch
entity from database. That causes great performance issues, because everywhere I
need only a reference, TopLink is fetching entire entity which I do not really
That issue was discussed on "users" mailing list:
Following Tom Ware's suggestion, I am entering this issue as ENHANCEMENT, but
for me, it should be a DEFECT. Yes, I know "JPA spec." says:
"Get an instance, whose state may be lazily fetched."
but I believe, the JPA intention was that it may be lazily fetched only because
that entity could have been in cache already, so there would be no reason not to
provide initialized entity.
As Sahoo from SUN said /in the thread mentioned above/
"[...] I agree with you that implementing getReference() this way defeats the
purpose of having that API. I don't know the rational behind the current