openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <kwsut...@gmail.com>
Subject Re: openJPA generates select per row - impossible to use for simple select statements
Date Thu, 16 Jul 2009 13:19:43 GMT
Hi Mikhail,
Your log file is showing at least one difference from my environment.  It
looks like you are (accidentally) using the subclassing support for
enhancement per this log statement:

[7/16/09 12:53:52:964 MSD] 0000001d SystemErr     R 31  MainPersistence
INFO   [WebContainer : 0] openjpa.Enhance - Creating subclass for "[class
com.ubs.n3.persistence.ReportBond, class com.ubs.n3.persistence.Account,
class com.ubs.n3.persistence.N3Property]". This means that your application
will be less efficient and will consume more memory than it would if you ran
the OpenJPA enhancer. Additionally, lazy loading will not be available for
one-to-one and many-to-one persistent attributes in types using field
access; they will be loaded eagerly instead.

I thought I had asked about what type of enhancement processing you were
using, but maybe that was a different forum posting...  You can find out
more about OpenJPA's enhancement processing here [1].  In a nutshell, the
subclassing support is not meant for production use.  It's meant for some
simple, out of the box examples just to get people started.  Real usage of
OpenJPA would use one of the enhancement processes.

What's interesting is that you mention that you are using OpenJPA within
WebSphere.  The WebSphere packaged version of OpenJPA turns off this
subclassing support.  If your applicaiton's processing should take you into
the subclassing support, an error message should be logged to let you know
of this condition.  But, maybe you are just using OpenJPA as a shared
library or an applicaiton library.  In that case, the default, last-ditch
attempt at enhancement is the subclassing support.

I'm also not prepared to say that this is definitely your problem.  I'm
waiting for my development environment to boot up, so I will try it out
shortly.  But, anytime that I see subclassing with an error condition, it's
been a common culprit.  I just wanted to get this bit of information out to
you so that maybe we can try out variations at the same time.

Good luck,
Kevin



[1]
http://webspherepersistence.blogspot.com/2009/02/openjpa-enhancement.html

On Thu, Jul 16, 2009 at 4:41 AM, om <mikhail.ostryanin@ubs.com> wrote:

>
> http://n2.nabble.com/file/n3267829/dump.rar dump.rar
>
> Hi All,
>
> Thank you very much for paying attention to my problem. In spite of it
> works
> with Hibernate, I don't like the idea to use another JPA and have pretty
> many additional libs on board. I would like to fix the issue with OpenJPA
> and use it since it's embedded in WebSphere server, at least.
>
> The code is extremely simple and clear. Stateless bean just returns
> query.getResultList() to struts2 action , which puts it in request object
> for displaytag grid. The whole time spends in query.getResultList() method.
>
> I’ve tried once more to remove IFilterTO and Map from Account object, but
> with no result.
>
> I put asterisks before and after  query.getResultList(), switched on
> runtime
> trace, and attached result log. It’s pretty detailed, with many openjpa
> runtime parameters and actions, may be somebody will be able to determine
> what is happening…
>
> Database is ORACLE10, detailed version is present in attached log file –
> openJPA determined it correctly. Tables are created automatically by
> OpenJPA
> using the following property in persistence.xml :
>
>      <properties>
>
>         <property name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema"/>
>
>      </properties>
>
>
>
> IFilterTO interface just has two methods , nothing special :
>
> public interface IFilterTO {
>   void setValue( String key, String value );
>   String getValue( String key );
> }
>
> Thank you all in advance for your help.
>
> Mikhail
>
>
> Craig L Russell wrote:
> >
> > Hi,
> >
> > Could I ask again what the code is doing, following the
> > query.getResultList() ?
> >
> > Where is the list of results being used? Are the results being
> > serialized or detached?
> >
> > Thanks,
> >
> > Craig
> >
> > On Jul 15, 2009, at 12:19 AM, om wrote:
> >
> >>
> >> Hi All!
> >>
> >> I’m new in openJPA, and didn’t manage to get over the problem with
> >> simple
> >> select statement for one object after a few days of investigation.
> >> Please
> >> help!
> >>
> >> For simple select from one object, OpenJPA ( same strategy for 1.0,
> >> 1.2.1,
> >> 2.0 ) fist generates right query to retrieve all rows and fields,
> >> and then
> >> start generating query per object by primary key.
> >>
> >> Code :
> >>      StringBuffer queryBuf = new StringBuffer("SELECT a FROM Account
> >> AS a
> >> WHERE a.date = :date ");
> >>      PersistenceProviderImpl impl = new PersistenceProviderImpl();
> >>      OpenJPAEntityManagerFactory fac =
> >> impl.createEntityManagerFactory("MainPersistence",
> >> System.getProperties());
> >>      OpenJPAEntityManager man = fac.createEntityManager();
> >>
> >>      Query query = man.createQuery(queryBuf.toString());
> >>      query.setParameter("date", reportDate);
> >>      List res = query.getResultList();
> >>
> >>
> >> LOG TRACE
> >>
> >> [7/14/09 16:57:50:475 MSD]  R 266  MainPersistence  TRACE
> >> openjpa.Runtime -
> >> Query "SELECT a FROM Account AS a WHERE a.date = :date " is cached
> >> as target
> >> query "null"
> >> [7/14/09 16:57:50:475 MSD] R 266  MainPersistence  TRACE
> >> openjpa.Query -
> >> Executing query: [SELECT a FROM Account AS a WHERE a.date = :date]
> >> with
> >> parameters: {date=java.util.GregorianCalendar[]}
> >> [7/14/09 16:57:50:475 MSD] R 266  MainPersistence  TRACE
> >> openjpa.jdbc.SQL
> >> - <t 1495423266, conn 1329090360> executing prepstmnt 1388597956
> >> SELECT
> >> t0.id, t0.version, t0.cur_code, t0.acc_date, t0.mask, t0.acc_name,
> >> t0.acc_seq, t0.value FROM ACCOUNT t0 WHERE (t0.acc_date = ?)
> >> [params=(Timestamp) 2009-07-03 00:00:00.0]
> >> [7/14/09 16:57:50:553 MSD] R 344  MainPersistence  TRACE
> >> openjpa.jdbc.SQL -
> >> <t 1495423266, conn 1329090360> [78 ms] spent
> >>
> >> [7/14/09 16:57:50:553 MSD] R 344  MainPersistence  TRACE
> >> openjpa.jdbc.SQL -
> >> <t 1495423266, conn 1329090360> executing prepstmnt 139855958 SELECT
> >> t0.mask, t0.acc_name, t0.acc_seq, t0.value FROM ACCOUNT t0 WHERE
> >> t0.id = ?
> >> [params=(long) 328]
> >> [7/14/09 16:57:50:631 MSD] R 422  MainPersistence  TRACE
> >> [WebContainer : 2]
> >> openjpa.jdbc.SQL - <t 1495423266, conn 1329090360> [78 ms] spent
> >> [7/14/09 16:57:50:631 MSD] R 422  MainPersistence  TRACE
> >> [WebContainer : 2]
> >> openjpa.jdbc.SQL - <t 1495423266, conn 1329090360> executing prepstmnt
> >> 646850190 SELECT t0.mask, t0.acc_name, t0.acc_seq, t0.value FROM
> >> ACCOUNT t0
> >> WHERE t0.id = ? [params=(long) 329]
> >> [7/14/09 16:57:50:709 MSD] R 500  MainPersistence  TRACE
> >> [WebContainer : 2]
> >> openjpa.jdbc.SQL - <t 1495423266, conn 1329090360> [78 ms] spent
> >> [7/14/09 16:57:50:709 MSD] R 500  MainPersistence  TRACE
> >> [WebContainer : 2]
> >> openjpa.jdbc.SQL - <t 1495423266, conn 1329090360> executing prepstmnt
> >> 2146074602 SELECT t0.mask, t0.acc_name, t0.acc_seq, t0.value FROM
> >> ACCOUNT t0
> >> WHERE t0.id = ? [params=(long) 330]
> >> [7/14/09 16:57:50:787 MSD] R 578  MainPersistence  TRACE
> >> [WebContainer : 2]
> >> openjpa.jdbc.SQL - <t 1495423266, conn 1329090360> [78 ms] spent
> >> ………………………………..
> >>
> >>
> >> I need just list of detached objects to show it in grid. As it’s
> >> seen from
> >> log trace above, first query is enough to return all necessary
> >> objects and
> >> fields.
> >> Why OpenJPA makes select per object after that? In this case simple
> >> code
> >> above works 37 seconds for retrieving 440 rows, since same jdbc
> >> select and
> >> wrap works 1.5 sec. I’ve tried different query hints and a few openjpa
> >> versions, but with no result.
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://n2.nabble.com/openJPA-generates-select-per-row---impossible-to-use-for-simple-select-statements-tp3261512p3261512.html
> >> Sent from the OpenJPA Users mailing list archive at Nabble.com.
> >
> > Craig L Russell
> > Architect, Sun Java Enterprise System http://db.apache.org/jdo
> > 408 276-5638 mailto:Craig.Russell@sun.com
> > P.S. A good JDO? O, Gasp!
> >
> >
> >
> >
>
> --
> View this message in context:
> http://n2.nabble.com/openJPA-generates-select-per-row---impossible-to-use-for-simple-select-statements-tp3261512p3267829.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message