users@glassfish.java.net

Re: TopLink: em.getReference downloads data from database

From: Tom Ware <tom.ware_at_oracle.com>
Date: Mon, 25 Jun 2007 10:23:29 -0400

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
>
>