There's something odd here with BoneCP's thread affinity.

Could you enable OpenJPA trace (eg <property name="openjpa.Log"
value="JDBC=TRACE,SQL=TRACE"/> ). That should show all of our interactions
with the connection.

Which database are you using?

-mike

On Tue, Feb 8, 2011 at 6:44 AM, Joel Halbert <[email protected]> wrote:

> OK, so I was using BoneCP as the connection pool manager.
> When I reverted to DHCP the problem vanished.
>
> Any ideas as to why this should be the case?
>
>
>
> On Tue, 2011-02-08 at 12:23 +0000, Joel Halbert wrote:
> > Hi,
> >
> > I have performed a test to confirm that I don't seem to be able to
> > disable caching (2.0.1).
> >
> > I've set the following properties:
> >
> >
> > <property name="openjpa.DataCache" value="false"/>
> > <property name="openjpa.QueryCache" value="false"/>
> > <property name="openjpa.jdbc.QuerySQLCache" value="false"/>
> >
> >
> >
> > And I can see the correct values of these properties are logged out when
> > I start my app.
> >
> >
> > When I create the entity Test.java  (below), and run it's main method
> > (with the TEST table empty to start with) and then subsequently manually
> > insert into the test table:
> >
> > insert into TEST values (1,'a');
> >
> > it never picks up on the inserted values, even though I am creating a
> > new EntityManager for each iteration where I perform the query on Test.
> >
> > What could I be doing wrong!?
> >
> > Thanks
> > Joel
> >
> > --------------------------------------------------
> >
> >
> >
> >
> > package com.su3analytics.sitedelta.model;
> >
> >
> >
> > import java.util.List;
> >
> > import javax.persistence.Access;
> > import javax.persistence.AccessType;
> > import javax.persistence.Column;
> > import javax.persistence.Entity;
> > import javax.persistence.EntityManager;
> > import javax.persistence.EntityManagerFactory;
> > import javax.persistence.GeneratedValue;
> > import javax.persistence.GenerationType;
> > import javax.persistence.Id;
> > import javax.persistence.Persistence;
> > import javax.persistence.Table;
> > import javax.persistence.TypedQuery;
> >
> > @Entity
> > @Access(AccessType.PROPERTY)
> > @Table(name="TEST")
> > public class Test {
> >
> >       private int id;
> >       private String name;
> >
> >       @Id
> >       @GeneratedValue(strategy = GenerationType.IDENTITY)
> >       @Column(name="ID")
> >       public int getId() {
> >               return id;
> >       }
> >       public void setId(int id) {
> >               this.id = id;
> >       }
> >
> >       @Column(name="NAME")
> >       public String getName() {
> >               return name;
> >       }
> >       public void setName(String name) {
> >               this.name = name;
> >       }
> >
> >       // SIMPLE TEST CASE
> >       public static void main(String[] args) throws Exception {
> >               EntityManagerFactory factory =
> Persistence.createEntityManagerFactory("su3", null);
> >               while(true) {
> >                       EntityManager em = factory.createEntityManager();
> >                       TypedQuery<Test> q = em.createQuery("select t from
> Test t", Test.class);
> >                       List<Test> res = q.getResultList();
> >                       for (Test t :res) {
> >                               System.out.println(t.getId()+", " +
> t.getName());
> >                       }
> >                       Thread.sleep(1000);
> >                       em.close();
> >               }
> >       }
> > }
> >
>
>
>

Reply via email to