users@glassfish.java.net

Re: JPA

From: Markus Fuchs <Markus.Fuchs_at_Sun.COM>
Date: Tue, 05 Jun 2007 12:53:06 -0700

Hi Daniel,

External changes should be visible in transactions starting after the
external change committed. The cache can be disabled for queries by a
query hint:

    // named query is SELECT p FROM Person p
    final Query q = this.entityManager.createNamedQuery("findEverybody");
    assert q != null;
    q.setHint("toplink.cache-usage", 0); // JDK 1.5; this works
    final List list = q.getResultList(); // List of Person entities

Please also check the EntityManager's refresh API for usage on persistent instances.

Regards,

-- markus.



Daniel Cavalcanti wrote:
> Very basic question:
> I have an app that I use JPA to access a MySQL database.
> When I add rows into a table using MySQL utilities, I don't see them
> im my application when I use the entity manager. I know TopLink uses
> cache, so how do I make it refresh so that I can get the added rows...
>
> thanks,
> Daniel.