[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Refreshing lists
|
You'll want to turn off shared caching:
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Caching
That should solve your issues with the cached list.
The reason you see the same statement over and over again is that you
a relationship without a @JoinFetch annotation, if you add a
@JoinFetch with an outer join type eclipselink will generate a left
join for you, eliminating the extra fetching.
./tch
On Mon, May 24, 2010 at 4:56 PM, Christopher Piggott <cpiggott@xxxxxxxxx> wrote:
> Hi,
>
> I am working on a small project that involves jersey (jax-rs), JPA
> (provided by eclipselink), and guice. My jersey resources are created
> by guice, which also injects an EntityManager into them. There is
> just one EntityManagerFactory instance, and it is owned by the
> injector.
>
> The resource then, for every request, creates an EntityManager, gets a
> List<Item>, and sends the result back as the response.
>
> The resource looks like this:
>
>
> @Path("/list")
> public class MyResource {
> @Inject @Named("MyTestEntity")
> private EntityManager em;
>
> @GET
> @Produces("text/plain")
> public String getIt() {
> log.debug("returning something");
>
> if(em == null) {
> return "no database";
> } else {
> Query q = em.createNamedQuery("Item.findAll");
> List<Item> items = q.getResultList();
> StringBuilder sb = new StringBuilder();
> for(Item p : items)
> {
> sb.append(p.getPlatformId() + "\n");
> }
>
> em.close();
> return sb.toString();
> }
> }
>
>
> Here's the thing I'm not getting. When I do the first query it takes
> a fairly long time as it gathers up all the data. When I do the
> second and subsequent queries it takes no time at all. It doesn't
> consult the database at all; it just looks in the cache.
>
> I can see how to do en.refresh(anItem) but what I want to do is cause
> it to refresh the ENTIRE LIST. The problem is, this web service isn't
> the only thing accessing this data - external applications are
> constantly adding and updating records.
>
> I can set a queryHint that causes a refresh, but it seems that's not
> really the right thing to do. For one, that would be
> eclipse-specific, and the whole point of me using JPA is to avoid
> implementation-specific APIs (even thought I can't really see myself
> using anything other than eclipselink in the near future).
>
>
> I have looked all over but have yet to find a clear example of how
> this is supposed to work in, say, a grizzly or tomcat environment. I
> want to maximize performance, meaning pooling connections etc.
>
>
> The other problem I have is that, according to logs, it seems to
> prepare the same statements over and over and over ... unless for some
> reason p.put("eclipselink.logging.level.sql", "FINE") is lying
> to me. It doesn't seem to be... it really does seem to generate a LOT
> of traffic to retrieve relatively simple things. It's a fully linked
> database with many relationships; still...
>
>
> --Chris
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>