You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Joel Halbert <jo...@su3analytics.com> on 2011/02/08 13:23:38 UTC

How to disable caching?

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();
		}
	}
}


Re: How to disable caching?

Posted by MiƂosz <mt...@o2.pl>.
Hi Joel,

Another speculative idea is that there is a glitch with auto-commit setting. The connection might be in non-auto-commit mode but is not
getting committed on em.close() for some reason and you are getting the same connection every time. Hence, because of transaction isolation, you don't see the values
you insert manually. MySQL is treated by OpenJPA in a special way in that matter: because supportsMultipleNontransactionalResultSets is set to false
in MySQL dictionary, OpenJPA switches auto-commit off on the connection. This can be seen in your log:

DEBUG - DataSource connection setAutoCommit to "false"


What happens if you first fill the table and then run your program? Does it show the correct values?

What happens if you encompass the query in a transaction?

What happens if you set DBDicitonary property supportsMultipleNontransactionalResultSets to true?

As for DHCP possible advantages of usage, there are one or two rare cases when it is used to unwrap the pooled connection and get the
original one. One is using LOB streaming on PostgreSQL. You can browse the source of the dictionaries you are going to use to see
if DHCP-specific handling is used. Even if it is, you should be able to override a method and adjust it to your pooling
implementation. And if you are on a real JDBC 4 driver and pool, that should be handled nicely in a pool-agnostic manner.

Greetings,
Milosz




> > > What about the inverse question:  Is there a reason you don't want to use
> > > DBCP?
> 
> Good question!
> 
> It's related to a recurring issue I was having, see this thread:
> 
> http://openjpa.208410.n2.nabble.com/Issues-with-dhcp-connection-pooling-td5998390.html
> 
> So I started experimenting with C3P0 to see if the problem went away.
> Early days yet, but so far so good.
> 
> (I also seem to remember many many moons (pre JPA) ago having issues
> with dhcp that went away when I migrated to c3p0)
> 
> J


Re: How to disable caching?

Posted by Joel Halbert <jo...@su3analytics.com>.
> > What about the inverse question:  Is there a reason you don't want to use
> > DBCP?

Good question!

It's related to a recurring issue I was having, see this thread:

http://openjpa.208410.n2.nabble.com/Issues-with-dhcp-connection-pooling-td5998390.html

So I started experimenting with C3P0 to see if the problem went away.
Early days yet, but so far so good.

(I also seem to remember many many moons (pre JPA) ago having issues
with dhcp that went away when I migrated to c3p0)

J

On Tue, 2011-02-08 at 10:04 -0600, Michael Dick wrote:
> On Tue, Feb 8, 2011 at 9:49 AM, Joel Halbert <jo...@su3analytics.com> wrote:
> 
> > Hi Mike,
> >
> > I'm using the defaults, and setting 'partitionCount=3'
> >
> 
> Shouldn't matter, but it might help us to reproduce the problem.
> 
> 
> > Is it possible that the connection is doing any caching of it's own?
> > There's no mention of this and it would seem to be beyond the remit of
> > it's function.
> >
> 
> My guess is that the connection is never closed and has some internal cache
> for this row. That combined with BoneCP keeping the same connection 'alive'
> is causing the problem. Highly speculative at this point though.
> 
> 
> > I've decided to use C3P0 for pooling now. Is there any reason to prefer
> > DHCP given that it is the out of the box default with OpenJPA?
> >
> 
> I have very limited experience with C3P0. It should work, but I don't know
> any benefits/cons.
> 
> What about the inverse question:  Is there a reason you don't want to use
> DBCP?
> 
> -mike
> 
> 
> > Joel
> >
> > On Tue, 2011-02-08 at 09:42 -0600, Michael Dick wrote:
> > > Hi Joel,
> > >
> > > Looks like we're doing the right thing. I see this pattern several times
> > in
> > > the trace :
> > >
> > > DEBUG - Found datasource1: datasource -672870675 from configuration.
> > > StoreContext: org.apache.openjpa.kernel.FinalizingBrokerImpl@c38157
> > > DEBUG - Executing query: select t from Test t
> > > DEBUG - <t 14892568, conn 16886931> executing prepstmnt 13312389 SELECT
> > > t0.ID, t0.NAME FROM TEST t0
> > > DEBUG - <t 14892568, conn 16886931> [1 ms] spent
> > > DEBUG - <t 14892568, conn 16886931> [0 ms] close
> > > DEBUG - Found datasource1: datasource -672870675 from configuration.
> > > StoreContext: org.apache.openjpa.kernel.FinalizingBrokerImpl@127ff0d
> > > DEBUG - Executing query: select t from Test t
> > > DEBUG - <t 14892568, conn 21860890> executing prepstmnt 29290924 SELECT
> > > t0.ID, t0.NAME FROM TEST t0
> > > DEBUG - <t 14892568, conn 21860890> [1 ms] spent
> > > DEBUG - <t 14892568, conn 21860890> [0 ms] close
> > >
> > > The connection is being closed between each SELECT statement. The only
> > thing
> > > we're reusing is the datasource which should be fine.
> > >
> > > Have you set any BoneCP properties, or are you using the defaults?
> > >
> > >
> > > -mike
> > >
> > > On Tue, Feb 8, 2011 at 9:07 AM, Joel Halbert <jo...@su3analytics.com>
> > wrote:
> > >
> > > > Hi Mike,
> > > >
> > > > I've attached the log file generated with those log level settings.
> > > >
> > > > The test iterates a couple of times before I insert a row into the
> > > > database. This time the new record was picked up, but then I inserted
> > > > several new rows and they were not picked up on any of the subsequent
> > > > iterations.
> > > >
> > > > I was using the following config:
> > > >
> > > >
> > > > <properties>
> > > >        <property name="openjpa.jdbc.SynchronizeMappings"
> > > > value="buildSchema"/>
> > > >        <property name="openjpa.ConnectionDriverName"
> > > >  value="com.jolbox.bonecp.BoneCPDataSource" />
> > > >        <property name="openjpa.ConnectionProperties"
> > > >
> > value="DriverClassName=com.mysql.jdbc.Driver,jdbcUrl=jdbc:mysql://localhost:3306/sitedelta,Username=sitedelta,Password=sitedelta,partitionCount=3"/>
> > > >
> > > >        <property name="openjpa.DataCache" value="false"/>
> > > >        <property name="openjpa.QueryCache" value="false"/>
> > > >
> > > >         <property name="openjpa.Log"
> > > > value="JDBC=TRACE,SQL=TRACE,RUNTIME=TRACE"/>
> > > > </properties>
> > > >
> > > >
> > > > On Tue, 2011-02-08 at 08:55 -0600, Michael Dick wrote:
> > > > > 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 <jo...@su3analytics.com>
> > > > 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();
> > > > > > >               }
> > > > > > >       }
> > > > > > > }
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > >
> > > >
> >
> >
> >



Re: How to disable caching?

Posted by Michael Dick <mi...@gmail.com>.
On Tue, Feb 8, 2011 at 10:04 AM, Michael Dick <mi...@gmail.com>wrote:

> On Tue, Feb 8, 2011 at 9:49 AM, Joel Halbert <jo...@su3analytics.com>wrote:
>
>> Hi Mike,
>>
>> I'm using the defaults, and setting 'partitionCount=3'
>>
>
> Shouldn't matter, but it might help us to reproduce the problem.
>
>
>> Is it possible that the connection is doing any caching of it's own?
>> There's no mention of this and it would seem to be beyond the remit of
>> it's function.
>>
>
> My guess is that the connection is never closed and has some internal cache
> for this row. That combined with BoneCP keeping the same connection 'alive'
> is causing the problem. Highly speculative at this point though.
>
>
>> I've decided to use C3P0 for pooling now. Is there any reason to prefer
>> DHCP given that it is the out of the box default with OpenJPA?
>>
>
> I have very limited experience with C3P0. It should work, but I don't know
> any benefits/cons.
>
> What about the inverse question:  Is there a reason you don't want to use
> DBCP?
>

Just noticed your email to the list from yesterday. Haven't had a chance to
look in depth though. Here's the link for other readers :
http://openjpa.208410.n2.nabble.com/Issues-with-dhcp-connection-pooling-td5998390.html

<snip>

Re: How to disable caching?

Posted by Michael Dick <mi...@gmail.com>.
On Tue, Feb 8, 2011 at 9:49 AM, Joel Halbert <jo...@su3analytics.com> wrote:

> Hi Mike,
>
> I'm using the defaults, and setting 'partitionCount=3'
>

Shouldn't matter, but it might help us to reproduce the problem.


> Is it possible that the connection is doing any caching of it's own?
> There's no mention of this and it would seem to be beyond the remit of
> it's function.
>

My guess is that the connection is never closed and has some internal cache
for this row. That combined with BoneCP keeping the same connection 'alive'
is causing the problem. Highly speculative at this point though.


> I've decided to use C3P0 for pooling now. Is there any reason to prefer
> DHCP given that it is the out of the box default with OpenJPA?
>

I have very limited experience with C3P0. It should work, but I don't know
any benefits/cons.

What about the inverse question:  Is there a reason you don't want to use
DBCP?

-mike


> Joel
>
> On Tue, 2011-02-08 at 09:42 -0600, Michael Dick wrote:
> > Hi Joel,
> >
> > Looks like we're doing the right thing. I see this pattern several times
> in
> > the trace :
> >
> > DEBUG - Found datasource1: datasource -672870675 from configuration.
> > StoreContext: org.apache.openjpa.kernel.FinalizingBrokerImpl@c38157
> > DEBUG - Executing query: select t from Test t
> > DEBUG - <t 14892568, conn 16886931> executing prepstmnt 13312389 SELECT
> > t0.ID, t0.NAME FROM TEST t0
> > DEBUG - <t 14892568, conn 16886931> [1 ms] spent
> > DEBUG - <t 14892568, conn 16886931> [0 ms] close
> > DEBUG - Found datasource1: datasource -672870675 from configuration.
> > StoreContext: org.apache.openjpa.kernel.FinalizingBrokerImpl@127ff0d
> > DEBUG - Executing query: select t from Test t
> > DEBUG - <t 14892568, conn 21860890> executing prepstmnt 29290924 SELECT
> > t0.ID, t0.NAME FROM TEST t0
> > DEBUG - <t 14892568, conn 21860890> [1 ms] spent
> > DEBUG - <t 14892568, conn 21860890> [0 ms] close
> >
> > The connection is being closed between each SELECT statement. The only
> thing
> > we're reusing is the datasource which should be fine.
> >
> > Have you set any BoneCP properties, or are you using the defaults?
> >
> >
> > -mike
> >
> > On Tue, Feb 8, 2011 at 9:07 AM, Joel Halbert <jo...@su3analytics.com>
> wrote:
> >
> > > Hi Mike,
> > >
> > > I've attached the log file generated with those log level settings.
> > >
> > > The test iterates a couple of times before I insert a row into the
> > > database. This time the new record was picked up, but then I inserted
> > > several new rows and they were not picked up on any of the subsequent
> > > iterations.
> > >
> > > I was using the following config:
> > >
> > >
> > > <properties>
> > >        <property name="openjpa.jdbc.SynchronizeMappings"
> > > value="buildSchema"/>
> > >        <property name="openjpa.ConnectionDriverName"
> > >  value="com.jolbox.bonecp.BoneCPDataSource" />
> > >        <property name="openjpa.ConnectionProperties"
> > >
> value="DriverClassName=com.mysql.jdbc.Driver,jdbcUrl=jdbc:mysql://localhost:3306/sitedelta,Username=sitedelta,Password=sitedelta,partitionCount=3"/>
> > >
> > >        <property name="openjpa.DataCache" value="false"/>
> > >        <property name="openjpa.QueryCache" value="false"/>
> > >
> > >         <property name="openjpa.Log"
> > > value="JDBC=TRACE,SQL=TRACE,RUNTIME=TRACE"/>
> > > </properties>
> > >
> > >
> > > On Tue, 2011-02-08 at 08:55 -0600, Michael Dick wrote:
> > > > 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 <jo...@su3analytics.com>
> > > 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();
> > > > > >               }
> > > > > >       }
> > > > > > }
> > > > > >
> > > > >
> > > > >
> > > > >
> > >
> > >
>
>
>

Re: How to disable caching?

Posted by Joel Halbert <jo...@su3analytics.com>.
Hi Mike,

I'm using the defaults, and setting 'partitionCount=3'

Is it possible that the connection is doing any caching of it's own?
There's no mention of this and it would seem to be beyond the remit of
it's function. 

I've decided to use C3P0 for pooling now. Is there any reason to prefer
DHCP given that it is the out of the box default with OpenJPA?

Joel

On Tue, 2011-02-08 at 09:42 -0600, Michael Dick wrote:
> Hi Joel,
> 
> Looks like we're doing the right thing. I see this pattern several times in
> the trace :
> 
> DEBUG - Found datasource1: datasource -672870675 from configuration.
> StoreContext: org.apache.openjpa.kernel.FinalizingBrokerImpl@c38157
> DEBUG - Executing query: select t from Test t
> DEBUG - <t 14892568, conn 16886931> executing prepstmnt 13312389 SELECT
> t0.ID, t0.NAME FROM TEST t0
> DEBUG - <t 14892568, conn 16886931> [1 ms] spent
> DEBUG - <t 14892568, conn 16886931> [0 ms] close
> DEBUG - Found datasource1: datasource -672870675 from configuration.
> StoreContext: org.apache.openjpa.kernel.FinalizingBrokerImpl@127ff0d
> DEBUG - Executing query: select t from Test t
> DEBUG - <t 14892568, conn 21860890> executing prepstmnt 29290924 SELECT
> t0.ID, t0.NAME FROM TEST t0
> DEBUG - <t 14892568, conn 21860890> [1 ms] spent
> DEBUG - <t 14892568, conn 21860890> [0 ms] close
> 
> The connection is being closed between each SELECT statement. The only thing
> we're reusing is the datasource which should be fine.
> 
> Have you set any BoneCP properties, or are you using the defaults?
> 
> 
> -mike
> 
> On Tue, Feb 8, 2011 at 9:07 AM, Joel Halbert <jo...@su3analytics.com> wrote:
> 
> > Hi Mike,
> >
> > I've attached the log file generated with those log level settings.
> >
> > The test iterates a couple of times before I insert a row into the
> > database. This time the new record was picked up, but then I inserted
> > several new rows and they were not picked up on any of the subsequent
> > iterations.
> >
> > I was using the following config:
> >
> >
> > <properties>
> >        <property name="openjpa.jdbc.SynchronizeMappings"
> > value="buildSchema"/>
> >        <property name="openjpa.ConnectionDriverName"
> >  value="com.jolbox.bonecp.BoneCPDataSource" />
> >        <property name="openjpa.ConnectionProperties"
> > value="DriverClassName=com.mysql.jdbc.Driver,jdbcUrl=jdbc:mysql://localhost:3306/sitedelta,Username=sitedelta,Password=sitedelta,partitionCount=3"/>
> >
> >        <property name="openjpa.DataCache" value="false"/>
> >        <property name="openjpa.QueryCache" value="false"/>
> >
> >         <property name="openjpa.Log"
> > value="JDBC=TRACE,SQL=TRACE,RUNTIME=TRACE"/>
> > </properties>
> >
> >
> > On Tue, 2011-02-08 at 08:55 -0600, Michael Dick wrote:
> > > 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 <jo...@su3analytics.com>
> > 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();
> > > > >               }
> > > > >       }
> > > > > }
> > > > >
> > > >
> > > >
> > > >
> >
> >



Re: How to disable caching?

Posted by Michael Dick <mi...@gmail.com>.
Hi Joel,

Looks like we're doing the right thing. I see this pattern several times in
the trace :

DEBUG - Found datasource1: datasource -672870675 from configuration.
StoreContext: org.apache.openjpa.kernel.FinalizingBrokerImpl@c38157
DEBUG - Executing query: select t from Test t
DEBUG - <t 14892568, conn 16886931> executing prepstmnt 13312389 SELECT
t0.ID, t0.NAME FROM TEST t0
DEBUG - <t 14892568, conn 16886931> [1 ms] spent
DEBUG - <t 14892568, conn 16886931> [0 ms] close
DEBUG - Found datasource1: datasource -672870675 from configuration.
StoreContext: org.apache.openjpa.kernel.FinalizingBrokerImpl@127ff0d
DEBUG - Executing query: select t from Test t
DEBUG - <t 14892568, conn 21860890> executing prepstmnt 29290924 SELECT
t0.ID, t0.NAME FROM TEST t0
DEBUG - <t 14892568, conn 21860890> [1 ms] spent
DEBUG - <t 14892568, conn 21860890> [0 ms] close

The connection is being closed between each SELECT statement. The only thing
we're reusing is the datasource which should be fine.

Have you set any BoneCP properties, or are you using the defaults?


-mike

On Tue, Feb 8, 2011 at 9:07 AM, Joel Halbert <jo...@su3analytics.com> wrote:

> Hi Mike,
>
> I've attached the log file generated with those log level settings.
>
> The test iterates a couple of times before I insert a row into the
> database. This time the new record was picked up, but then I inserted
> several new rows and they were not picked up on any of the subsequent
> iterations.
>
> I was using the following config:
>
>
> <properties>
>        <property name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema"/>
>        <property name="openjpa.ConnectionDriverName"
>  value="com.jolbox.bonecp.BoneCPDataSource" />
>        <property name="openjpa.ConnectionProperties"
> value="DriverClassName=com.mysql.jdbc.Driver,jdbcUrl=jdbc:mysql://localhost:3306/sitedelta,Username=sitedelta,Password=sitedelta,partitionCount=3"/>
>
>        <property name="openjpa.DataCache" value="false"/>
>        <property name="openjpa.QueryCache" value="false"/>
>
>         <property name="openjpa.Log"
> value="JDBC=TRACE,SQL=TRACE,RUNTIME=TRACE"/>
> </properties>
>
>
> On Tue, 2011-02-08 at 08:55 -0600, Michael Dick wrote:
> > 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 <jo...@su3analytics.com>
> 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();
> > > >               }
> > > >       }
> > > > }
> > > >
> > >
> > >
> > >
>
>

Re: How to disable caching?

Posted by Joel Halbert <jo...@su3analytics.com>.
Hi Mike,

I've attached the log file generated with those log level settings.

The test iterates a couple of times before I insert a row into the
database. This time the new record was picked up, but then I inserted
several new rows and they were not picked up on any of the subsequent
iterations.

I was using the following config:


<properties>
        <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
	<property name="openjpa.ConnectionDriverName"  value="com.jolbox.bonecp.BoneCPDataSource" />
	<property name="openjpa.ConnectionProperties" value="DriverClassName=com.mysql.jdbc.Driver,jdbcUrl=jdbc:mysql://localhost:3306/sitedelta,Username=sitedelta,Password=sitedelta,partitionCount=3"/>
	
	<property name="openjpa.DataCache" value="false"/>
	<property name="openjpa.QueryCache" value="false"/> 
			
	<property name="openjpa.Log" value="JDBC=TRACE,SQL=TRACE,RUNTIME=TRACE"/>		
</properties>


On Tue, 2011-02-08 at 08:55 -0600, Michael Dick wrote:
> 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 <jo...@su3analytics.com> 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();
> > >               }
> > >       }
> > > }
> > >
> >
> >
> >


Re: How to disable caching?

Posted by Michael Dick <mi...@gmail.com>.
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 <jo...@su3analytics.com> 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();
> >               }
> >       }
> > }
> >
>
>
>

Re: How to disable caching?

Posted by Joel Halbert <jo...@su3analytics.com>.
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();
> 		}
> 	}
> }
>