I cannot disable caching in OpenJPA 2.0.1.
I set the following properties in my persistence.xml:
<property name="openjpa.DataCache" value="false"/>
<property name="openjpa.QueryCache" value="false"/>
<property name="openjpa.jdbc.QuerySQLCache" value="false"/>
And I see that the correct values for these properties exit the system when my application starts.
I created a base object to verify this using the main method, which simply queries the table every second. I create a new EntityManager at each iteration. When I run it against an empty TEST table, and then manually insert the data into the test:
insert into TEST values (1,'a');
it never picks up new data (although if I re-run the program, it does).
import java.util.List;
import javax.persistence.*;
@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;
}
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();
}
}
}
what am I doing wrong?
EDIT1. EntityManagerFactory while, , , , DataCache QueryCache false, , .
EDIT2: BoneCP , DHCP C3P0 . , , ...
EDIT3: , BoneCP:
<property name="openjpa.ConnectionDriverName" value="com.jolbox.bonecp.BoneCPDataSource"/>
<property name="openjpa.ConnectionProperties" value="DriverClassName=com.mysql.jdbc.Driver,jdbcUrl=jdbc:mysql://localhost:3306/mydb,Username=xxxx,Password=yyyy,partitionCount=3"/>