users@glassfish.java.net

Re: TopLink: em.getReference downloads data from database

From: Witold Szczerba <pljosh.mail_at_gmail.com>
Date: Tue, 26 Jun 2007 02:14:48 +0200

Following Tom's suggestion, I have filled an issue:
https://glassfish.dev.java.net/issues/show_bug.cgi?id=3251

I really hope, it will be resolved soon, as without getReference, all
the foreign keys are really causing performance disaster

Witold Szczerba.


2007/6/25, Tom Ware <tom.ware_at_oracle.com>:
> The understanding we got through interation with the spec comittee as
> the spec was being written is that the phrasing was written the way it
> was for the reason Sahoo mentions below (i.e. to allow the provider to
> decide whether or not to fetch the state from the database). In our
> initial implementation we chose not to optimize getReference() in the
> way detailed below.
>
> I beleive optimizing getReference() is a good idea and I suggest you
> enter an Enhancement request to complete this work.
>
> -Tom
>
> Witold Szczerba wrote:
>
> > I think the pharse: "whose state may be lazily fetched" is there only
> > because the entity might be already in cache, but downloading it from
> > database seems to be what you said, it defeats purpose of that API
> > and.. this is what makes my application slow.
> >
> > 2007/6/25, Sahoo <Sahoo_at_sun.com>:
> >
> >> Hi,
> >>
> >> The spec [1] allows a provider to fetch the state from a database (see
> >> the use of *may* in the javadocs). But, 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 implementation. Let's
> >> hope someone clarifies the same.
> >>
> >> Thanks,
> >> Sahoo
> >>
> >> [1]
> >> http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.html#getReference(java.lang.Class,%20java.lang.Object)
> >>
> >>
> >> Witold Szczerba wrote:
> >> > Hi there,
> >> > I have problem with TopLink, because em.getReference is fetching data
> >> > from database the same way as em.find does. But sometimes, there is no
> >> > need to fetch entity, only reference is important, for example, to use
> >> > it as a foreign key in some query.
> >> > Is it a bug? Why em.getReference acts the same way as em.find?
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> >> > For additional commands, e-mail: users-help_at_glassfish.dev.java.net
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> >> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> > For additional commands, e-mail: users-help_at_glassfish.dev.java.net
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>