ClassCastException in PersistenceManager.newQuery(Extent)
The event described below looks like a Kodo issue:
Let pm be a PersistenceManager,
Extent e = pm.getExtent(<some class>, true);
pm.newQuery(e);
The last statement aborts with a JDOException containing a
ClassCastException mentioning the class
com.solarmetric.kodo.runtime.CacheAwareExtent, which is probably the
runtime type of e. The Query factory implementation seems to assume
that e should be something else.
Maybe newQuery(Extent) is simply not implemented, so newQuery(Object)
is invoked spuriously, and thus the argument is expected to be a
precompiled query?
Abe White wrote:
Maybe newQuery(Extent) is simply not implemented, so newQuery(Object)
is invoked spuriously, and thus the argument is expected to be a
precompiled query?That would certainly be true if you're not using Kodo 2.3; all previous
versions of Kodo implemented the PFD, which didn't have the newQuery(Extent)
method.
If you are using 2.3, could you please post the stack trace from the
cast exception?Sorry, I forgot to add that I used 2.2.6. I will try 2.3 now. Thank you.
Similar Messages
-
ClassCastException with ClassLoader issues
I'm using JBoss 3.2.3, with Kodo 3.1.0
After doing a hot deploy in JBoss, ClassCastExceptions start occuring.
String filter = "reference==param1";
Extent extent = pm.getExtent(Customer.class, false);
KodoQuery query = (KodoQuery) pm.newQuery(extent, filter);
Collection col = null;
try {
query.declareParameters("String param1");
col = (Collection) query.execute("x34c");
if (col.isEmpty())
return null;
Customer cust = (Customer) col.iterator().next();
finally {
if (query != null)
query.close(col);
At the line: Customer cust = (Customer) col.iterator().next();
a ClassCastException is thrown. The class loader for Customer.class point
to the deployed ear file, whilst the loader for
col.iterator().next().getClass() points to null.
Now, what is even more interesting is if I amend the above code slightly:
Extent extent = pm.getExtent(Customer.class, false);
KodoQuery query = (KodoQuery) pm.newQuery(extent);
Collection col = null;
try {
col = (Collection) query.execute();
if (col.isEmpty())
return null;
Customer cust = (Customer) col.iterator().next();
finally {
if (query != null)
query.close(col);
With the above, everything works fine. The only difference is that one
uses a filter to retrieve a particular object from the datastore, and the
other retrieves all objects from the datastore. I don't understand why it
throws a ClassCastException in one instance and not the other. Note that
this only happens after a hot deploy.
This problem only surfaced recently after I added a few more classes to be
persistent capable. After adding a further two classes, the
ClassCastException moved to another class.
Can anyone explain this?
CheersA N-
Did you make absolutely sure that you enhanced all of the new classes
and deployed them to correctly, and that you have clobbered any caches
JBoss may have to any of the old .ear files?
It might be the case that when you obtain the first in the list of all
the Customer instances, it doesn't have a relation to one of the new
classes, or its concrete instance is not one of the new classes, as
opposed to when you execute the filter.
If this doesn't help, can you provide us with some more information? At
a minimum, a complete stack trace is usually a prerequisite for being
able to diagnose problems like this.
In article <[email protected]>, A N wrote:
>
I'm using JBoss 3.2.3, with Kodo 3.1.0
After doing a hot deploy in JBoss, ClassCastExceptions start occuring.
String filter = "reference==param1";
Extent extent = pm.getExtent(Customer.class, false);
KodoQuery query = (KodoQuery) pm.newQuery(extent, filter);
Collection col = null;
try {
query.declareParameters("String param1");
col = (Collection) query.execute("x34c");
if (col.isEmpty())
return null;
Customer cust = (Customer) col.iterator().next();
finally {
if (query != null)
query.close(col);
At the line: Customer cust = (Customer) col.iterator().next();
a ClassCastException is thrown. The class loader for Customer.class point
to the deployed ear file, whilst the loader for
col.iterator().next().getClass() points to null.
Now, what is even more interesting is if I amend the above code slightly:
Extent extent = pm.getExtent(Customer.class, false);
KodoQuery query = (KodoQuery) pm.newQuery(extent);
Collection col = null;
try {
col = (Collection) query.execute();
if (col.isEmpty())
return null;
Customer cust = (Customer) col.iterator().next();
finally {
if (query != null)
query.close(col);
With the above, everything works fine. The only difference is that one
uses a filter to retrieve a particular object from the datastore, and the
other retrieves all objects from the datastore. I don't understand why it
throws a ClassCastException in one instance and not the other. Note that
this only happens after a hot deploy.
This problem only surfaced recently after I added a few more classes to be
persistent capable. After adding a further two classes, the
ClassCastException moved to another class.
Can anyone explain this?
Cheers
Marc Prud'hommeaux [email protected]
SolarMetric Inc. http://www.solarmetric.com -
ClassCastException from Query to JDBCQuery
Section 4.6 of the 3.0b2 documentation states, "You can safely cast any
query instance returned by a Kodo JDO persistence manager to a JDBCQuery."
I get the following stack trace when I attempt to do so:
java.lang.ClassCastException
at kodopt.UserManagerServlet.doGet(UserManagerServlet.java:1060)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at
com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at
com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at
com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246)
at
com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:536)
I set javax.jdo.PersistenceManagerFactoryClass to
kodo.jdbc.runtime.JDBCPersistenceManagerFatory. The object type returned
by PersistenceManager.newQuery() is kodo.datacache.CacheAwareQuery. Is
this a bug, or am I doing something wrong?Abe White wrote:
The object type returned
by PersistenceManager.newQuery() is kodo.datacache.CacheAwareQuery. Is
this a bug, or am I doing something wrong?
Argh; it's a bug. It'll only happen when the data cache is enabled, by
the way. Darn... you'll have to make due with casting to
kodo.query.KodoQuery.
Was there a specific JDBCQuery method you needed to invoke?Yes... setJoinSyntax(). -
MissingResourceException when I iterator a collection after closing the PM
I retrieve a collection, call pm.retrieveAll on it, and then close the PM.
When I try to iterator over the collection, I get a
MissingResourceException. I can't figure out why I'm getting the exception,
if I do a retrieveAll it should retrieve all the fields of all the objects
in the collection. It's as if there is a rule "Thou shall not iterator over
a collection after closing the PM". Is this true?
java.util.MissingResourceException: Can't find resource for bundle
java.util.PropertyResourceBundle, key resultlist-closed
at java.util.ResourceBundle.getObject(ResourceBundle.java:314)
at java.util.ResourceBundle.getString(ResourceBundle.java:274)
at serp.util.Localizer.get(Localizer.java:270)
at serp.util.Localizer.get(Localizer.java:121)
at
com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.checkClosed(LazyResult
List.java:349)
at
com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.listIterator(LazyResul
tList.java:403)
at
com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.iterator(LazyResultLis
t.java:397)
at
com.verideon.siteguard.services.SchedulerService.getMonitorsToRun(SchedulerS
ervice.java:103)
at
com.verideon.siteguard.services.SchedulerService.schedule(SchedulerService.j
ava:59)
at
com.verideon.siteguard.web.util.TimerServlet$scheduleTask.run(TimerServlet.j
ava:84)
at java.util.TimerThread.mainLoop(Timer.java:432)
at java.util.TimerThread.run(Timer.java:382)
Here is my code:
private Collection getMonitorsToRun() {
Collection c = new LinkedList();
PersistenceManager pm = null;
try {
pm = JDOFactory.getPersistenceManager();
Extent extent = pm.getExtent(Monitor.class, true);
String filter = "nextDate <= now";
Query q = pm.newQuery(extent, filter);
q.declareParameters("java.util.Date now");
q.setOrdering("nextDate ascending");
Hashtable p = new Hashtable();
p.put("now", new Date());
c = (Collection) q.executeWithMap(p);
pm.retrieveAll(c);
} catch (JDOException e) {
log.warn("Received JDO Exception while retrieving Monitors " + e);
} finally {
pm.close();
log.debug("Retrieved " + c.size() + " Monitors ready to be ran.");
Iterator i = c.iterator();
while (i.hasNext()) {
Monitor m = (Monitor) i.next();
log.debug("m id = " + m.getId());
return c;It appears to be a query in which case, yes, a Query result Collection cannot be iterated over.
The simple way to bypass this is to transfer the results to a non-closing Collection.
Collection results = (Collection) q.execute ();
results = new LinkedList (results);
pm.retrieveAll (results);
pm.close ();
On Thu, 27 Feb 2003 14:49:17 +0100, Michael Mattox wrote:
I retrieve a collection, call pm.retrieveAll on it, and then close the PM.
When I try to iterator over the collection, I get a
MissingResourceException. I can't figure out why I'm getting the exception,
if I do a retrieveAll it should retrieve all the fields of all the objects
in the collection. It's as if there is a rule "Thou shall not iterator over
a collection after closing the PM". Is this true?
java.util.MissingResourceException: Can't find resource for bundle
java.util.PropertyResourceBundle, key resultlist-closed
at java.util.ResourceBundle.getObject(ResourceBundle.java:314)
at java.util.ResourceBundle.getString(ResourceBundle.java:274)
at serp.util.Localizer.get(Localizer.java:270)
at serp.util.Localizer.get(Localizer.java:121)
at
com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.checkClosed(LazyResult
List.java:349)
at
com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.listIterator(LazyResul
tList.java:403)
at
com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.iterator(LazyResultLis
t.java:397)
at
com.verideon.siteguard.services.SchedulerService.getMonitorsToRun(SchedulerS
ervice.java:103)
at
com.verideon.siteguard.services.SchedulerService.schedule(SchedulerService.j
ava:59)
at
com.verideon.siteguard.web.util.TimerServlet$scheduleTask.run(TimerServlet.j
ava:84)
at java.util.TimerThread.mainLoop(Timer.java:432)
at java.util.TimerThread.run(Timer.java:382)
Here is my code:
private Collection getMonitorsToRun() {
Collection c = new LinkedList();
PersistenceManager pm = null;
try {
pm = JDOFactory.getPersistenceManager();
Extent extent = pm.getExtent(Monitor.class, true);
String filter = "nextDate <= now";
Query q = pm.newQuery(extent, filter);
q.declareParameters("java.util.Date now");
q.setOrdering("nextDate ascending");
Hashtable p = new Hashtable();
p.put("now", new Date());
c = (Collection) q.executeWithMap(p);
pm.retrieveAll(c);
} catch (JDOException e) {
log.warn("Received JDO Exception while retrieving Monitors " + e);
} finally {
pm.close();
log.debug("Retrieved " + c.size() + " Monitors ready to be ran.");
Iterator i = c.iterator();
while (i.hasNext()) {
Monitor m = (Monitor) i.next();
log.debug("m id = " + m.getId());
return c;
Stephen Kim
[email protected]
SolarMetric, Inc.
http://www.solarmetric.com -
I'm now trying to map a class with an existing db table. Firstly, here is
my package.jdo
<?xml version="1.0"?>
<jdo>
<package name="test">
<class name="Testclass">
<extension vendor-name="kodo" key="table" value="test_table"/>
<extension vendor-name="kodo" key="lock-column" value="none"/>
<extension vendor-name="kodo" key="pk-column" value="test_id"/>
<extension vendor-name="kodo" key="class-column" value="none"/>
<field name="testField">
<extension vendor-name="kodo" key="data-column" value="test_field"/>
</field>
</class>
</package>
</jdo>
And this is the error that I get.
javax.jdo.JDOUserException: No database mapping was found for type "class
test.Testclass"; all persistent types must be registered in the database;
this is done automatically through the SchemaTool.
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.getClassMapping(JDBCStoreManager.java:674)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCExpressionFactory.(JDBCExpressionFactory.java:49)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.getExpressionFactory(JDBCQuery.java:178)
Ideas?Hi,
I think we're getting somewhere now:)
It appears to be running the query (unsuccessfully). Here is my data
test_column_a test_column_b test_column_c
1 andrew 12
2 row2 33
This is my query.
public Collection getTests(String sFilter, PersistenceManager aPM) {
Extent anExtent = aPM.getExtent(Test.class, true);
Query aQry = aPM.newQuery(Test.class, anExtent, sFilter);
Collection aTestList = (Collection) aQry.execute();
System.out.print("The number of test items is: ");
System.out.println(aTestList.size());
return aTestList;
I call this via:
Test aTest = new Test();
aTest.getTests("", JDOFactory.getPersistenceManager());
The logging in the getTests() method says the number of items in the
collection returned from the query is 0. (I'm expecting 2).
I've also passed null as the filter when creating the newQuery().
So I'm getting close...
Patrick Linskey wrote:
[email protected] (Andrew) writes:
I'm 99% certain they are iTestColumnA, B and C.
iTestColumnA is the primary key, and my xml file looks exactly like the
first one you've
listed. I initially didn't have the iTestColumnA in my class file (I think
I read in the
documents that it shouldn't be), but I got an error when running the
enhancer so I put
it back in.
Looking at the second xml listing, I've tried the same type of thing
there, and I got an
error with that as well. I will try these things again tomorrow though,
and let you know
the results. Oh, one point I just noticed is that I haven't mentioned an
identity type!
I've looked through the documents and didn't find how this was done, but I
see it now in
your listing, perhaps that will help solve the problems.
All the primary keys are handled by me, so unique generation etc is fine
(we're using
oracle and I dont' know the details, but as long as I know the difference
it will be
handled).
Thanks for your help, I'll let you know how I go tomorrow.
Andrew
BTW, note that my XML for application identity was incorrect. I forgot
to specify an app id oid class. Something like this would probably be
better:
<?xml version="1.0"?>
<jdo>
<package name="test">
<class name="Testclass" identity-type="application"objectid-class="TestKey">
<extension vendor-name="kodo" key="table" value="TEST"/>
<extension vendor-name="kodo" key="lock-column" value="none"/>
Note that we provide a tool to simplify the process of generating
application id keys. Run 'java
com.solarmetric.kodo.tools.appid.ApplicationIDTool' on your .jdo files
to generate template app id classes.
-Patrick>>
Patrick Linskey wrote:
Andrew,
Based on the error that you are seeing and on your class, I bet that the
fields are actually 'iTestA', 'sTestB', and 'iTestC'.
Is 'iTestA' the primary key field? Also, did you specify application
identity or data store identity in your XML metadata?
I'm guessing that your XML should look like one of the two following
examples. The first uses datastore identity; the second application
identity.
In the first case, I have removed the iTestA field. This field
should also be removed from your class file. This is because I'm
guessing that the test_column_a column is the primary key column, and
when using data store identity, you cannot map the pk to a field in your
class.
<?xml version="1.0"?>
<jdo>
<package name="test">
<class name="Testclass" identity-type="datastore">
<extension vendor-name="kodo" key="table" value="TEST"/>
<extension vendor-name="kodo" key="lock-column" value="none"/>
<extension vendor-name="kodo" key="pk-column" value="test_column_a"/>
<extension vendor-name="kodo" key="class-column" value="none"/>
<field name="sTestB">
<extension vendor-name="kodo" key="data-column"
value="test_column_b"/>
</field>
<field name="iTestC">
<extension vendor-name="kodo" key="data-column"value="test_column_c"/>
</field>
</class>
</package>
</jdo>
In the second case, the iTestA field is in both the Java class and the
metadata. It is your responsibility to ensure that this field be given a
unique id, as it is the primary key, and this configuration uses
application-controlled identity.
<?xml version="1.0"?>
<jdo>
<package name="test">
<class name="Testclass" identity-type="application">
<extension vendor-name="kodo" key="table" value="TEST"/>
<extension vendor-name="kodo" key="lock-column" value="none"/>
<extension vendor-name="kodo" key="class-column" value="none"/>
<field name="iTestA" primary-key="true">
<extension vendor-name="kodo" key="data-column"
value="test_column_a"/>
</field>
<field name="sTestB">
<extension vendor-name="kodo" key="data-column"value="test_column_b"/>
</field>
<field name="iTestC">
<extension vendor-name="kodo" key="data-column"value="test_column_c"/>
</field>
</class>
</package>
</jdo>
-Patrick
[email protected] (Andrew) writes:
Hi, Something like this (I'm at home now, but this is pretty close):
public class Test {
public Test() {
super();
// This bit isn't exact, but just imagine it's the tutorial
example,
no
//restrictions.
public Collection getTestList(String sFilter, PersistenceManager
pm) {
// Copied out of the tutorial....
Extent e = pm.getExtent(Test.class, sFilter);
Collection aTestList = aQry.execute();
return aTestList;
private int iTestColumnA = 0;
private String sTestColumnB = null;
private int iTestColumnC = 0;
Patrick Linskey wrote:
[email protected] (Andrew) writes:
I'm just working with a small test table at the moment with 1
primary
key
column and 2 other columns. When the JDO tries to access the
database,
this is an error I get.
javax.jdo.JDODataStoreException: [SQL=SELECT t0.test_column_a,t0.ITESTAX,> > > > > > t0.test_column_c, t0.test_column_b FROM TEST t0 ORA-00904: invalidcolumn
name
Now, I'm not sure where this ITESTAX column is coming from??
Andrew,
What does your test class look like?
-Patrick
Patrick Linskey [email protected]
SolarMetric Inc. http://www.solarmetric.com
Patrick Linskey [email protected]
SolarMetric Inc. http://www.solarmetric.com
Patrick Linskey [email protected]
SolarMetric Inc. http://www.solarmetric.com -
Does Kodo cache projection queries? All my queries are caching properly,
except for ones that use setResult(), and I'd like them to be cached also.
Here's an example:
PersistenceManager pm = getPM();
extent = pm.getExtent(ConstellationRevenueDAO.class, false);
query = (KodoQuery) pm.newQuery(extent);
query.setResult("max(billingDate)");
date = (Date) query.execute();
The corresponding log entries show a cache miss every time. I've noticed
that when the kodo.datacache.QueryKey has a "cacheable:false", it won't be
cached:
2004-12-10 16:04:49,160 DEBUG [kodo.DataCache] Query cache miss while
looking up key "kodo.datacache.QueryKey@dafa335b[filter:[null],access
path:null,subs:false,ordering:null,ignoreCache:false,startIndex:0,endIndex:0,timeout:-1,cacheable:false]".
2004-12-10 16:04:49,160 DEBUG [kodo.Query] executing query: select
max(billingDate) from
com.stercomm.slp.biztier.persistence.stg.ConstellationRevenueDAO exclude
subclasses
2004-12-10 16:04:49,441 DEBUG [kodo.jdbc.SQL] <t 14300405, conn 30092753>
[281 ms] executing prepstmnt 2954511 SELECT MAX(t0.BES1_BILLINGDATE) FROM
DMMK01.CONSTELLATIONREVENUE t0
2004-12-10 16:04:49,441 DEBUG [kodo.jdbc.JDBC] <t 14300405, conn 30092753>
[0 ms] close
2004-12-10 16:04:59,316 DEBUG [kodo.DataCache] Query cache miss while
looking up key "kodo.datacache.QueryKey@dafa335b[filter:[null],access
path:null,subs:false,ordering:null,ignoreCache:false,startIndex:0,endIndex:0,timeout:-1,cacheable:false]".
2004-12-10 16:04:59,316 DEBUG [kodo.Query] executing query: select
max(billingDate) from
com.stercomm.slp.biztier.persistence.stg.ConstellationRevenueDAO exclude
subclasses
2004-12-10 16:04:59,597 DEBUG [kodo.jdbc.SQL] <t 14300405, conn 723185>
[281 ms] executing prepstmnt 7871956 SELECT MAX(t0.BES1_BILLINGDATE) FROM
DMMK01.CONSTELLATIONREVENUE t0
2004-12-10 16:04:59,613 DEBUG [kodo.jdbc.JDBC] <t 14300405, conn 723185>
[0 ms] closeEric-
Unfortunately, queries that use aggregates, projections, or any
custom result class are not cached. The next version of Kodo
will mention this behavior in the documentation.
In article <cpd3dv$m12$[email protected]>, Eric Long wrote:
Does Kodo cache projection queries? All my queries are caching properly,
except for ones that use setResult(), and I'd like them to be cached also.--
Marc Prud'hommeaux
SolarMetric Inc. -
Exception in 2.5.2
Hi,
This is probably a configuration error, But I've just upgraded from 2.4.2 to
2.5.2
And a existing function seems to fail.
public static Collection findAllObjectsOfType(Class objectTypeToFind) {
PersistenceManagerFactory pmfLocal =
PersistenceManagerHelper.getPersistenceManagerFactory();
PersistenceManager pm = pmfLocal.getPersistenceManager();
Extent extent = pm.getExtent(objectTypeToFind, true);
Query query = pm.newQuery(extent);
return (Collection) query.execute();
At line
Query query = pm.newQuery(extent);
I get
java.lang.NoClassDefFoundError
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.newQuery(JDBCStoreMa
nager.java:601)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.newQuery(PersistenceMana
gerImpl.java:2081)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.newQuery(PersistenceMana
gerImpl.java:2073)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.newQuery(PersistenceMana
gerImpl.java:2012)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.newQuery(PersistenceMana
gerImpl.java:2037)Rolled driver back to 2.4.3.
Code works fine again. Will wait on a Solarmetric response to this issue
before attempting to upgrade again.
Graham Cruickshanks
"Graham Cruickshanks" <[email protected]> wrote in message
news:[email protected]...
Tried installing 2.5.1
Same java.lang.NoClassDefFoundError exception, Also
A Query with a filter fails the same way as well.
example: Query query = pm.newQuery(extent, filter);
Regards
Graham Cruickshanks
"Graham Cruickshanks" <[email protected]> wrote in message
news:[email protected]...
But's it's still getting this java.lang.NoClassDefFoundError exception.
"Graham Cruickshanks" <[email protected]> wrote in message
news:[email protected]...
Update:
Double checked the classpath, and versions of libraries. And
everything
seems to be o.k.
"Graham Cruickshanks" <[email protected]> wrote in message
news:[email protected]...
Hi,
This is probably a configuration error, But I've just upgraded from
2.4.2
to
2.5.2
And a existing function seems to fail.
public static Collection findAllObjectsOfType(Class
objectTypeToFind)
PersistenceManagerFactory pmfLocal =
PersistenceManagerHelper.getPersistenceManagerFactory();
PersistenceManager pm =
pmfLocal.getPersistenceManager();
Extent extent = pm.getExtent(objectTypeToFind, true);
Query query = pm.newQuery(extent);
return (Collection) query.execute();
At line
Query query = pm.newQuery(extent);
I get
java.lang.NoClassDefFoundError
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.newQuery(JDBCStoreMa
nager.java:601)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.newQuery(PersistenceMana
gerImpl.java:2081)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.newQuery(PersistenceMana
gerImpl.java:2073)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.newQuery(PersistenceMana
gerImpl.java:2012)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.newQuery(PersistenceMana
gerImpl.java:2037) -
Kodo JDO EE 2.3 RC1 (with InstantDB on JBoss 3.0 on JDK 1.3.1 on Mac
OS X 10.1.5) generates wrong SQL for a JDO query with a parameter.
Essentially (unimportant details omitted) I have the following:
2 associated persistence-capable classes
public class Person
private String name;
public class Issue
private int id;
private Person owner;
both with application-managed identity (Person by name, Issue by id),
both in the same package. I want to search the database for all Issues
owned by a certain Person. My code looks like this:
@pre p is persistent
Collection findByOwner(Person p){
// pm is the PersistenceManager
//TODO pm.newQuery(Issue.class, filter) does not work with Kodo 2.3 RC1
Extent extent = pm.getExtent(Issue.class, true);
Query query = pm.newQuery(extent, "owner==person");
query.setClass(Issue.class);
query.setIgnoreCache(true);
query.declareParameters(Person.class.getName() + " person");
return (Collection)query.execute(p);
and produces the following SQL statement
SELECT t0.IDX, t0.JDOCLASSX, t0.JDOLOCKX, t0.NAME_OWNERX FROM ISSUEX
t0, PERSONX t1 WHERE (t1.NAMEX = NULL AND t0.NAME_OWNERX = t1.NAMEX)
which is wrong because the actual p.name, which is definitely not nil,
got lost, and is even rejected by the database*, probably because
NAMEX is the primary key and cannot be NULL.
I am pretty sure that this used to work correctly with Kodo 2.2.4. Can
anyone tell me what I could be doing wrong? I will provide the full
source code at request.
Thanks,
Jakob
* SQLException:
Don't understand SQL after: "WHERE"
Expected: "{" found: "NULL"This issue has been resolved in internal builds.
Some tangential notes about the code below:
- in our latest version, we no longer require extents when executing
queries (the candidate class is sufficient).
- I'm a little concerned about where the 'pm' variable came from in
Issue.findByOwner(). If that's a member variable, you'd be better off
doing 'JDOHelper.getPersistenceManager (this)' instead of caching it on
your own -- this way, you'll avoid any potential issues with somehow
using the wrong PM or something.
- Given that all the info is stored in the database already, I'd suggest
making the relation a bidirectional one, so that you can just traverse
from Issue to Person without needing to do a query. This will be faster,
as we will be able to leverage our PM and PMF caches rather than needing
to execute a query against the data store.
-Patrick
Jakob Spies <[email protected]> wrote:
Kodo JDO EE 2.3 RC1 (with InstantDB on JBoss 3.0 on JDK 1.3.1 on Mac
OS X 10.1.5) generates wrong SQL for a JDO query with a parameter.
Essentially (unimportant details omitted) I have the following:
2 associated persistence-capable classes
public class Person
private String name;
public class Issue
private int id;
private Person owner;
both with application-managed identity (Person by name, Issue by id),
both in the same package. I want to search the database for all Issues
owned by a certain Person. My code looks like this:
@pre p is persistent
Collection findByOwner(Person p){
// pm is the PersistenceManager
//TODO pm.newQuery(Issue.class, filter) does not work with Kodo 2.3 RC1
Extent extent = pm.getExtent(Issue.class, true);
Query query = pm.newQuery(extent, "owner==person");
query.setClass(Issue.class);
query.setIgnoreCache(true);
query.declareParameters(Person.class.getName() + " person");
return (Collection)query.execute(p);
Patrick Linskey [email protected]
SolarMetric Inc. http://www.solarmetric.com -
Many to Many Relations Problem
I have following two classes with many-to-many case:
public class Protocol {
private long protocolId;
private final Collection keyPersons = new ArrayList();
public void addKeyPerson(Person person) {
person.addKeyProtocol(this);
public void removeKeyPerson(Person person) {
person.removeKeyProtocol(this);
public class Person {
private long personId;
private final Collection keyProtocols = new ArrayList();
public void addKeyProtocol(Protocol protocol) {
protocol.getKeyPersonsCollection().add(this);
keyProtocols.add(protocol);
public void removeKeyProtocol(Protocol protocol) {
protocol.getKeyPersonsCollection().remove(this);
keyProtocols.remove(protocol);
The meta data is:
<?xml version="1.0"?>
<jdo>
<package name="peacetech.nih.nhlbi.iasp.dao">
<class name="Protocol" identity-type="application"
objectid-class="peacetech.nih.nhlbi.iasp.dao.oid.ProtocolOid">
<extension vendor-name="tt" key="table" value="protocol"/>
<extension vendor-name="tt" key="pk-column" value="int_protocol"/>
<extension vendor-name="tt" key="lock-column" value="none"/>
<extension vendor-name="tt" key="class-column" value="none"/>
<field name="protocolId" primary-key="true">
<extension vendor-name="tt" key="data-column" value="int_protocol"/>
</field>
<field name="keyPersons">
<collection element-type="Person"/>
<extension vendor-name="tt" key="inverse" value="keyProtocols"/>
<extension vendor-name="tt" key="table" value="KeyPersonnel"/>
<extension vendor-name="tt" key="personId-data-column" value="PID"/>
<extension vendor-name="tt" key="protocolId-ref-column"
value="int_protocol"/>
</field>
</class>
<class name="Person" identity-type="application"
objectid-class="peacetech.nih.nhlbi.iasp.dao.oid.PersonOid">
<extension vendor-name="tt" key="table" value="Personnel"/>
<extension vendor-name="tt" key="pk-column" value="PID"/>
<extension vendor-name="tt" key="lock-column" value="none"/>
<extension vendor-name="tt" key="class-column" value="none"/>
<field name="personId" primary-key="true">
<extension vendor-name="tt" key="data-column" value="PID"/>
</field>-
<field name="keyProtocols">
<collection element-type="Protocol"/>
<extension vendor-name="tt" key="inverse" value="keyPersons"/>
<extension vendor-name="tt" key="table" value="KeyPersonnel"/>
<extension vendor-name="tt" key="protocolId-data-column"
value="int_protocol"/>
<extension vendor-name="tt" key="personId-ref-column" value="PID"/>
</field>
</class>
The assignment works fine beetwen New Persistent Protocol and Persons, but
when ever I try to add new assignment between existing protocol and person:
void updateProtocol(PersistenceManager pm){
Extent e = pm.getExtent (Person.class, true);
Query query = pm.newQuery (Person.class, e, "fname == \"Alex\"");
Collection collection = (Collection) query.execute();
Iterator i = collection.iterator ();
Person alex = (Person)i.next();
System.out.println("Person to assign" + alex);
e = pm.getExtent (Protocol.class, true);
query = pm.newQuery (Protocol.class, e, "projectTitle == \"This is
JDO test N1\"");
collection = (Collection) query.execute();
i = collection.iterator ();
Protocol firstProtocol = (Protocol)i.next();
try {
pm.currentTransaction().begin();
e = pm.getExtent (Person.class, true);
query = pm.newQuery (Person.class, e, "fname == \"Brian\"");
collection = (Collection) query.execute();
i = collection.iterator ();
while (i.hasNext ())
firstProtocol.addKeyPerson((Person)(i.next()));/*Exception
here!*/
pm.currentTransaction().commit();
} catch (Exception ex) {
pm.currentTransaction().rollback();
ex.printStackTrace(System.out);
I have following exception:
javax.jdo.JDOUserException: The given element "
=======Person=======
First Name: Brian
Last Name: Agricola
Phone: null
Email: null
====================" does not meet the requirements for the container.
at
com.solarmetric.kodo.util.SecondClassObjects.checkValue(SecondClassObjects.j
ava:224)
at com.solarmetric.kodo.util.ProxyLinkedList.add(ProxyLinkedList.java:71)
at peacetech.nih.nhlbi.iasp.dao.Person.addKeyProtocol(Person.java:176)
at peacetech.nih.nhlbi.iasp.dao.Protocol.addKeyPerson(Protocol.java:147)
at peacetech.nih.nhlbi.iasp.IASPTest.updateProtocol(IASPTest.java:142)
at peacetech.nih.nhlbi.iasp.IASPTest.updateProtocol(IASPTest.java:110)
at peacetech.nih.nhlbi.iasp.IASPTest.runTest(IASPTest.java:28)
at peacetech.nih.nhlbi.iasp.IASPTest.main(IASPTest.java:22)
I have the same problem also for one to many.
Can you help me with it?
Thanks,
Kirill.I have following two classes with many-to-many case:
public class Protocol {
private long protocolId;
private final Collection keyPersons = new ArrayList();
public void addKeyPerson(Person person) {
person.addKeyProtocol(this);
public void removeKeyPerson(Person person) {
person.removeKeyProtocol(this);
public class Person {
private long personId;
private final Collection keyProtocols = new ArrayList();
public void addKeyProtocol(Protocol protocol) {
protocol.getKeyPersonsCollection().add(this);
keyProtocols.add(protocol);
public void removeKeyProtocol(Protocol protocol) {
protocol.getKeyPersonsCollection().remove(this);
keyProtocols.remove(protocol);
The meta data is:
<?xml version="1.0"?>
<jdo>
<package name="peacetech.nih.nhlbi.iasp.dao">
<class name="Protocol" identity-type="application"
objectid-class="peacetech.nih.nhlbi.iasp.dao.oid.ProtocolOid">
<extension vendor-name="tt" key="table" value="protocol"/>
<extension vendor-name="tt" key="pk-column" value="int_protocol"/>
<extension vendor-name="tt" key="lock-column" value="none"/>
<extension vendor-name="tt" key="class-column" value="none"/>
<field name="protocolId" primary-key="true">
<extension vendor-name="tt" key="data-column" value="int_protocol"/>
</field>
<field name="keyPersons">
<collection element-type="Person"/>
<extension vendor-name="tt" key="inverse" value="keyProtocols"/>
<extension vendor-name="tt" key="table" value="KeyPersonnel"/>
<extension vendor-name="tt" key="personId-data-column" value="PID"/>
<extension vendor-name="tt" key="protocolId-ref-column"
value="int_protocol"/>
</field>
</class>
<class name="Person" identity-type="application"
objectid-class="peacetech.nih.nhlbi.iasp.dao.oid.PersonOid">
<extension vendor-name="tt" key="table" value="Personnel"/>
<extension vendor-name="tt" key="pk-column" value="PID"/>
<extension vendor-name="tt" key="lock-column" value="none"/>
<extension vendor-name="tt" key="class-column" value="none"/>
<field name="personId" primary-key="true">
<extension vendor-name="tt" key="data-column" value="PID"/>
</field>-
<field name="keyProtocols">
<collection element-type="Protocol"/>
<extension vendor-name="tt" key="inverse" value="keyPersons"/>
<extension vendor-name="tt" key="table" value="KeyPersonnel"/>
<extension vendor-name="tt" key="protocolId-data-column"
value="int_protocol"/>
<extension vendor-name="tt" key="personId-ref-column" value="PID"/>
</field>
</class>
The assignment works fine beetwen New Persistent Protocol and Persons, but
when ever I try to add new assignment between existing protocol and person:
void updateProtocol(PersistenceManager pm){
Extent e = pm.getExtent (Person.class, true);
Query query = pm.newQuery (Person.class, e, "fname == \"Alex\"");
Collection collection = (Collection) query.execute();
Iterator i = collection.iterator ();
Person alex = (Person)i.next();
System.out.println("Person to assign" + alex);
e = pm.getExtent (Protocol.class, true);
query = pm.newQuery (Protocol.class, e, "projectTitle == \"This is
JDO test N1\"");
collection = (Collection) query.execute();
i = collection.iterator ();
Protocol firstProtocol = (Protocol)i.next();
try {
pm.currentTransaction().begin();
e = pm.getExtent (Person.class, true);
query = pm.newQuery (Person.class, e, "fname == \"Brian\"");
collection = (Collection) query.execute();
i = collection.iterator ();
while (i.hasNext ())
firstProtocol.addKeyPerson((Person)(i.next()));/*Exception
here!*/
pm.currentTransaction().commit();
} catch (Exception ex) {
pm.currentTransaction().rollback();
ex.printStackTrace(System.out);
I have following exception:
javax.jdo.JDOUserException: The given element "
=======Person=======
First Name: Brian
Last Name: Agricola
Phone: null
Email: null
====================" does not meet the requirements for the container.
at
com.solarmetric.kodo.util.SecondClassObjects.checkValue(SecondClassObjects.j
ava:224)
at com.solarmetric.kodo.util.ProxyLinkedList.add(ProxyLinkedList.java:71)
at peacetech.nih.nhlbi.iasp.dao.Person.addKeyProtocol(Person.java:176)
at peacetech.nih.nhlbi.iasp.dao.Protocol.addKeyPerson(Protocol.java:147)
at peacetech.nih.nhlbi.iasp.IASPTest.updateProtocol(IASPTest.java:142)
at peacetech.nih.nhlbi.iasp.IASPTest.updateProtocol(IASPTest.java:110)
at peacetech.nih.nhlbi.iasp.IASPTest.runTest(IASPTest.java:28)
at peacetech.nih.nhlbi.iasp.IASPTest.main(IASPTest.java:22)
I have the same problem also for one to many.
Can you help me with it?
Thanks,
Kirill. -
NotSerializableException using PreparedStatement in 2.3.1
Hi,
I tried the new 2.3.1 and got a java.io.NotSerializableException using
query.executeWithMap(...) on a precompiled query. The same query without
precompilation succeeds.
We use an Oracle 8.1.7.
This is the query:
String filter = "fromStateNode == from && action.name == name";
Class cls = Class.forName("TransitionDef");
Extent extent = pm.getExtent (cls, true);
Query query = pm.newQuery (extent, filter);
query.declareParameters("StateNodeDef from, String name");
query.compile();
now let:
StateNodeDef fromState => be a PersistenceCapable class,
initialized by a former query
String actionName => a non-null-String
and execute the query:
HashMap params = new HashMap(2);
params.put("from",fromState);
params.put("name",actionName);
Collection result = (Collection)query.executeWithMap(params);
=> The precompiled query throws the java.io.NotSerializableException (the next
line of the stack trace is the method that executes the query)
=> If I remove the query.compile, the query succeeds.
The important parts of package.jdo:
<class name="TransitionDef">
<extension vendor-name="tt" key="table" value="VC_TRANSITION"/>
<extension vendor-name="tt" key="pk-column" value="ID"/>
<extension vendor-name="tt" key="lock-column" value="none"/>
<extension vendor-name="tt" key="class-column" value="none"/>
<!-- a StateNodeDef: -->
<field name="fromStateNode">
<extension vendor-name="tt" key="data-column" value="FROM_NODE_ID"/>
</field>
<!-- a StateNodeDef: -->
<field name="toNode">
<extension vendor-name="tt" key="data-column" value="TO_NODE_ID"/>
</field>
<!-- an ActionDef: -->
<field name="action">
<extension vendor-name="tt" key="data-column" value="ACT_ID"/>
</field>
</class>
<class name="NodeDef">
<extension vendor-name="tt" key="table" value="VC_TYPED_NODE"/>
<extension vendor-name="tt" key="pk-column" value="ID"/>
<extension vendor-name="tt" key="lock-column" value="none"/>
<extension vendor-name="tt" key="class-column" value="CLASS"/>
<field name="name">
<extension vendor-name="tt" key="data-column" value="NAME"/>
</field>
</class>
<class name="StateNodeDef" persistence-capable-superclass="NodeDef">
...some more fields...
</class>
<class name="ActionDef">
<extension vendor-name="tt" key="table" value="VC_ACTION"/>
<extension vendor-name="tt" key="pk-column" value="ID"/>
<extension vendor-name="tt" key="lock-column" value="none"/>
<extension vendor-name="tt" key="class-column" value="none"/>
<field name="type" persistence-modifier="none"/>
<field name="name">
<extension vendor-name="tt" key="data-column" value="NAME"/>
</field>
...some more fields...
</class>
Another hint for the solution could be this case:
The same query with the parameters
StateNodeDef fromState => be a PersistenceCapable class,
initialized by a former query
but now:
String actionName => a NULL-String
succeeds precompiled and compiled.
Any ideas?
Thanks,
ChristianAbe White wrote:
Could you please post the stack trace for the exception?As described before:
=> The precompiled query throws the java.io.NotSerializableException (the next
line of the stack trace is the method that executes the query)
The method that executes the query (calls query.executeWithMap) is a
business method, the stack trace doesn't contain any information that
spots to kodo-methods, I suppose the query-implementation does not catch
this exception.
Maybe kodo tries to serialize any objects of the query?
Hope this helps.
Christian -
Bad SQL from 2.3.4 (and 2.3.2)
Hi guys,
In the Maine Lighthouse Rental app for my book, there are a total of 48 Rental records. To start
with, all rentals are available. Mary reserves one rental. Subsequently a search for all of Mary's
reservations and all available records, returns 95 rental references in the result collection
instead of 48. The problem arises from bad sql generated by Kodo 2.3.2 and 2.3.4.
This particular query can be fixed in two ways, but I'm not sure about the general mapping issues.
One, SELECT DISTINCT will fix it. Two, dropping the CUSTOMERX table from the query and changing the
first AND clause from:
WHERE (((t1.JDOIDX = 1351 AND t0.CUSTOMERX = t1.JDOIDX)
OR (t0.CUSTOMERX IS NULL))
to
WHERE (t0.CUSTOMERX = 1351
OR t0.CUSTOMERX IS NULL)
Code and generated SQL are below.
Hope this helps.
David Ezzio
---- query setup -------------
// set up query for customer's rentals and available rentals
Extent extent = pm.getExtent(Rental.class, false);
queryCustomerAndAvailableRentals = pm.newQuery(extent, "customer == c || customer == null");
queryCustomerAndAvailableRentals.declareParameters("Customer c");
queryCustomerAndAvailableRentals.setOrdering("week.startDate ascending, lighthouse.name ascending");
----- generated SQL -------
[ C:1923370; S:1238221; T:700575; D:10/22/02 3:48 PM ]
SELECT
t0.JDOIDX,
t0.JDOCLASSX,
t0.JDOLOCKX,
t0.CUSTOMERX,
t0.LIGHTHOUSEX,
t0.PRICEX,
t0.WEEKX,
t2.STARTDATEX,
t3.NAMEX
FROM
CUSTOMERX t1,
LIGHTHOUSEX t3,
RENTALX t0,
WEEKX t2
WHERE (((t1.JDOIDX = 1351 AND t0.CUSTOMERX = t1.JDOIDX)
OR (t0.CUSTOMERX IS NULL))
AND t0.LIGHTHOUSEX = t3.JDOIDX
AND t0.WEEKX = t2.JDOIDX)
ORDER BY
t2.STARTDATEX ASC,
t3.NAMEX ASCSQL*Net 2.3.4 was shipped along 8.0 products:
* SQL*Plus
* ORACLE NET8 PRODUCTS
* ORACLE NETWORKING PRODUCTS (SQL*NET 2.3.4)
* ORACLE 8 JDBC DRIVERS
This is not supported to connect against a 10g database. The last valid combination was 8.0.6 vs 9.2.0
~ Madrid. -
ObjectListDataProvider doesn't work for me.
I'm working thru the examples in the Field Guide 2 with an up-to-date version of JSC2. I'm stumped on 8.3 Object List Data Provider.
No matter which way I try it, I can't add the objectListDataProvider to a table. Nor can I set the object List for the data provider.
If I drag the objectListDataProvider component from the palette to the table, the provider is added to the page but not the table. If I try to Bind to Data... for the table, I can select objectListDataProvider1 but it doesn't "stick." The table reverts back to defaultTableDataProvider.
For objectListDataProvider1 properties, there is nothing in the List drop down, even tho there is an ArrayList in loanBean in sessionBean1.
Anyone have any idea what's going on?Hi,
I am using JDO (JPOX JDO) tool for the database transaction. So I have the bean (Complexity.java) for Complexity table which has 2 fields
1. code
2. description
I execute the query using JDOQL and I am getting Collection object,
BackingBean code for Complexity.jsp
public String button1_action() {
// TODO: Process the button click action. Return value is a navigation
// case name where null will return to the same page.
System.out.println("Entering ApplicationBean1.button1_action()");
if (pm == null) {
System.out.println("pm is null");
else {
Transaction tx = pm.currentTransaction();
try {
tx.begin();
String dropDownValue = this.dropDown1.getSelected().toString();
System.out.println("dropDownValue : " + dropDownValue);
Extent extent = pm.getExtent(Complexity.class, true);
Query query = pm.newQuery(extent);
String strFilter = null;
if (dropDownValue != null) {
if (dropDownValue.equals("Complexity Name")) {
//strFilter = "Complexity Name = drop
else {
strFilter = "Description == dropDownValue";
Collection result = (Collection) query.execute(strFilter);
ComplexityListDataProvider cldp = new ComplexityListDataProvider(result);
_/*Iterator iterator = result.iterator();
while (iterator.hasNext()) {
Complexity jdoObj = (Complexity) iterator.next();
complexityList.add(jdoObj);
else {
tx.commit();
catch (Exception e) {
System.out.println("Leaving ApplicationBean1.button1_action()");
return null;
which I am passing as an argument to the constructor of ComplexityListDataProvider. In constructor of ComplexityListDataProvider I am able to get the Complexity object by iterating through the collection object that is passed as an argument. Thereafter I put the Complexity Object into the complexityList (of type ArrayList). At the end, ComplexityListDataProvider constructor has
this.setList(complexityList) (Please refer below for the code)
public class ComplexityListDataProvider extends ObjectListDataProvider {
private List complexityList = new ArrayList();
_/** Creates a new instance of ComplexityListDataProvider */
public ComplexityListDataProvider() {
public ComplexityListDataProvider(Collection c) {
System.out.println("Entering constructor ComplexityListDataProvider(Collection)");
Iterator iterator = c.iterator();
while (iterator.hasNext()) {
Complexity jdoObj = (Complexity) iterator.next();
//String code = jdoObj.getCode();
//String description = jdoObj.getDescription();
//Complexity comp = new docport.Complexity(code, description);
//Complexity comp = new Complexity(code, description);
//complexityList.add(comp);
complexityList.add(jdoObj);
this.setList(complexityList);
this.setObjectType(Complexity.class);
System.out.println("Leaving constructor ComplexityListDataProvider(Collection)");
Also I have added a property �complexityListDataProvider� in SessionBean1.java
I am able to see the complexityList in the table layout but not able to view the columns for Complexity (i.e Code and Description). As a result of which I am unable to view the records in table.
Can you please help me in populating the table on jsp
Thanks and Regards,
Dhaval Shah -
How to get SQL statement from (Collection) query.execute();
We have a JDO Persistence class ClassName that execute query using following code. After this statement get executed, record does not get updated in the DB. Is there a way to check what SQL statement got submitted in the (Collection) query.execute(); ??? <br><br>
Extent extent = pm.getExtent(ClassName.class, false); <br>
Query query = null; <br>
try { <br>
query = pm.newQuery(extent, filter); <br>
Collection results = (Collection) query.execute();<br>
Iterator i = results.iterator();<br>
if (i.hasNext()) {<br>
...<br>
}<br>You can always find out the names of tables that are views, using java.sql.DatabaseMetaData and its getTables() method.
This tends to be a nice source of examples:
javaalmanac.com
However, if you're asking for the underlying SQL used to CREATE VIEW, I don't see anything in the API that will give you that. After all, JDBC shouldn't have to know if it's dealing with an ordinary table or a view. I think you'd have to ask your DBA for the underlying SQL.
Once you have it, what do you plan to do with it?
% -
Kodo 3.4.1: how to limit # of sql query params when using collection param
Hi,
We have a problem when using Kodo 3.4.1 against SQL Server 2005, when we execute query:
Query query = pm.newQuery( extent, "IdList.contains( this )" );
query.declareParameters( "Collection IdList" );
query.declareImports( "import java.util.Collection;" );
return (List) query.execute( list );
We got:
com.microsoft.sqlserver.jdbc.SQLServerException: The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Too many parameters were provided in this RPC request. The maximum is 2100.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(Unknown Source)
at com.solarmetric.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:354)
at com.solarmetric.jdbc.PoolConnection$PoolPreparedStatement.executeQuery(PoolConnection.java:341)
at com.solarmetric.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:352)
at com.solarmetric.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:1106)
at com.solarmetric.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:352)
at kodo.jdbc.runtime.JDBCStoreManager$CancelPreparedStatement.executeQuery(JDBCStoreManager.java:1730)
at com.solarmetric.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:339)
at kodo.jdbc.sql.Select.execute(Select.java:1581)
at kodo.jdbc.sql.Select.execute(Select.java:1533)
at kodo.jdbc.runtime.SelectResultObjectProvider.open(SelectResultObjectProvider.java:102)
at com.solarmetric.rop.EagerResultList.<init>(EagerResultList.java:22)
at kodo.query.AbstractQuery.execute(AbstractQuery.java:1081)
at kodo.query.AbstractQuery.executeWithArray(AbstractQuery.java:836)
at kodo.query.AbstractQuery.execute(AbstractQuery.java:799)
It seems that there're too many ids in the list, and Kodo didn't limit the # of sql parameters when craft the sql query. Is there a way to ask Kodo to use multiple queries with smaller # of sql parameters instead of using one big sql query?
ThanksHi,
Sadly, there is no way to do that in Kodo currently. The closest is the inClauseLimit DBDictionary setting, but that setting just breaks things up into multiple IN statements put together with an OR clause. In your case, it looks like the network transport, not the SQL parser, is complaining about size limits.
You could force the query to run in-memory, but that would probably be prohibitively slow, unless the data set that you're querying against is relatively small.
-Patrick -
Why Kodo tries to reload deleted object?
Hello,
I'm deleting User object that has dependent child object. Child is removed
in jdoPreDelete() method. Than client application invokes different method
selecting all the Users by Extent (for different PersistenceManager
instance):
Extent userExt = pm.getExtent(User.class, true);
Iterator it = userExt.iterator();
while (it.hasNext()) {
User user = (User) it.next();
On the it.next() call I get the following exception:
javax.jdo.JDODataStoreException: The instance "253" does not exist in the
data store.
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectByIdFilter(Pers
istenceManagerImpl.java:860)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectById(Persistenc
eManagerImpl.java:781)
at com.solarmetric.kodo.runtime.PCData.lookup(PCData.java:518)
at com.solarmetric.kodo.runtime.PCData.getData(PCData.java:494)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:210)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:112)
at
com.solarmetric.kodo.runtime.datacache.DataCacheStoreManager.initialize(Data
CacheStoreManager.java:221)
at
com.solarmetric.kodo.runtime.StateManagerImpl.loadInitialState(StateManagerI
mpl.java:112)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectByIdFilter(Pers
istenceManagerImpl.java:859)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectById(Persistenc
eManagerImpl.java:781)
at com.solarmetric.kodo.runtime.PCData.lookup(PCData.java:518)
at com.solarmetric.kodo.runtime.PCData.getData(PCData.java:494)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:210)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:112)
at
com.solarmetric.kodo.runtime.datacache.DataCacheStoreManager.initialize(Data
CacheStoreManager.java:221)
at
com.solarmetric.kodo.runtime.StateManagerImpl.loadInitialState(StateManagerI
mpl.java:112)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectByIdFilter(Pers
istenceManagerImpl.java:859)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectById(Persistenc
eManagerImpl.java:781)
at com.solarmetric.kodo.runtime.PCData.lookup(PCData.java:518)
at com.solarmetric.kodo.runtime.PCData.getData(PCData.java:494)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:210)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:112)
at
com.solarmetric.kodo.runtime.datacache.DataCacheStoreManager.initialize(Data
CacheStoreManager.java:221)
at
com.solarmetric.kodo.runtime.StateManagerImpl.loadInitialState(StateManagerI
mpl.java:112)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectByIdFilter(Pers
istenceManagerImpl.java:859)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectById(Persistenc
eManagerImpl.java:781)
at com.solarmetric.kodo.runtime.PCData.lookup(PCData.java:518)
at com.solarmetric.kodo.runtime.PCData.getData(PCData.java:494)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:210)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:112)
at
com.solarmetric.kodo.runtime.datacache.DataCacheStoreManager.initialize(Data
CacheStoreManager.java:221)
at
com.solarmetric.kodo.runtime.StateManagerImpl.loadInitialState(StateManagerI
mpl.java:112)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectByIdFilter(Pers
istenceManagerImpl.java:859)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectById(Persistenc
eManagerImpl.java:781)
at com.solarmetric.kodo.runtime.PCData.lookup(PCData.java:518)
at com.solarmetric.kodo.runtime.PCData.getData(PCData.java:494)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:195)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:112)
at
com.solarmetric.kodo.runtime.datacache.DataCacheStoreManager.initialize(Data
CacheStoreManager.java:221)
at
com.solarmetric.kodo.runtime.StateManagerImpl.loadInitialState(StateManagerI
mpl.java:112)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectByIdFilter(Pers
istenceManagerImpl.java:859)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectById(Persistenc
eManagerImpl.java:781)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.createFromResultSet(
JDBCStoreManager.java:700)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager$2.getResultObject(JD
BCStoreManager.java:652)
at
com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.instantiateRow(LazyRes
ultList.java:168)
at
com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.get(LazyResultList.jav
a:114)
at java.util.AbstractList$Itr.next(AbstractList.java:416)
at
com.solarmetric.kodo.runtime.ResultListIterator.next(ResultListIterator.java
:49)
at
com.solarmetric.kodo.impl.jdbc.runtime.ResultListFactory.createResultList(Re
sultListFactory.java:85)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.executeQuery(JDBCSto
reManager.java:646)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCExtent.getIterator(JDBCExtent.jav
a:49)
at
com.solarmetric.kodo.runtime.ExtentImpl$TransactionAwareIterator.newIterator
(ExtentImpl.java:219)
at serp.util.MultiIterator.setIterator(MultiIterator.java:70)
at serp.util.MultiIterator.hasNext(MultiIterator.java:25)
at
com.solarmetric.kodo.runtime.ExtentImpl$TransactionAwareIterator.hasNext(Ext
entImpl.java:195)
at
net.xtrim.crm.system.persistence.UserFactory.getUsers(UserFactory.java:121)
at net.xtrim.crm.user.ejb.UserFacadeBean.getUsers(UserFacadeBean.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
..java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(Stateles
sSessionContainer.java:660)
at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(Cach
edConnectionInterceptor.java:186)
at
org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSe
ssionInstanceInterceptor.java:77)
at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor
..java:107)
at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.
java:151)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
at
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:13
0)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
at
org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.jav
a:313)
at org.jboss.ejb.Container.invoke(Container.java:712)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at
org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:382)
at sun.reflect.GeneratedMethodAccessor50.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
..java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:7
01)
at java.lang.Thread.run(Thread.java:536)
Am I doing something wrong?
P.S. Everything works fine if User has no child reference.I've disabled PMF cache but it didn't help.... :(
"Patrick Linskey" <[email protected]> wrote in message
news:[email protected]...
A temporary workaround is to disable the PMF cache.
-Patrick
Alexey Maslov wrote:
Hello,
I'm deleting User object that has dependent child object. Child is
removed
in jdoPreDelete() method. Than client application invokes different
method
selecting all the Users by Extent (for different PersistenceManager
instance):
Extent userExt = pm.getExtent(User.class, true);
Iterator it = userExt.iterator();
while (it.hasNext()) {
User user = (User) it.next();
On the it.next() call I get the following exception:
javax.jdo.JDODataStoreException: The instance "253" does not exist inthe
data store.
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectByIdFilter(Pers
istenceManagerImpl.java:860)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectById(Persistenc
eManagerImpl.java:781)
at com.solarmetric.kodo.runtime.PCData.lookup(PCData.java:518)
at com.solarmetric.kodo.runtime.PCData.getData(PCData.java:494)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:210)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:112)
at
com.solarmetric.kodo.runtime.datacache.DataCacheStoreManager.initialize(Data
CacheStoreManager.java:221)
at
com.solarmetric.kodo.runtime.StateManagerImpl.loadInitialState(StateManagerI
mpl.java:112)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectByIdFilter(Pers
istenceManagerImpl.java:859)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectById(Persistenc
eManagerImpl.java:781)
at com.solarmetric.kodo.runtime.PCData.lookup(PCData.java:518)
at com.solarmetric.kodo.runtime.PCData.getData(PCData.java:494)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:210)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:112)
at
com.solarmetric.kodo.runtime.datacache.DataCacheStoreManager.initialize(Data
CacheStoreManager.java:221)
at
com.solarmetric.kodo.runtime.StateManagerImpl.loadInitialState(StateManagerI
mpl.java:112)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectByIdFilter(Pers
istenceManagerImpl.java:859)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectById(Persistenc
eManagerImpl.java:781)
at com.solarmetric.kodo.runtime.PCData.lookup(PCData.java:518)
at com.solarmetric.kodo.runtime.PCData.getData(PCData.java:494)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:210)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:112)
at
com.solarmetric.kodo.runtime.datacache.DataCacheStoreManager.initialize(Data
CacheStoreManager.java:221)
at
com.solarmetric.kodo.runtime.StateManagerImpl.loadInitialState(StateManagerI
mpl.java:112)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectByIdFilter(Pers
istenceManagerImpl.java:859)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectById(Persistenc
eManagerImpl.java:781)
at com.solarmetric.kodo.runtime.PCData.lookup(PCData.java:518)
at com.solarmetric.kodo.runtime.PCData.getData(PCData.java:494)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:210)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:112)
at
com.solarmetric.kodo.runtime.datacache.DataCacheStoreManager.initialize(Data
CacheStoreManager.java:221)
at
com.solarmetric.kodo.runtime.StateManagerImpl.loadInitialState(StateManagerI
mpl.java:112)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectByIdFilter(Pers
istenceManagerImpl.java:859)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectById(Persistenc
eManagerImpl.java:781)
at com.solarmetric.kodo.runtime.PCData.lookup(PCData.java:518)
at com.solarmetric.kodo.runtime.PCData.getData(PCData.java:494)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:195)
at com.solarmetric.kodo.runtime.PCData.load(PCData.java:112)
at
com.solarmetric.kodo.runtime.datacache.DataCacheStoreManager.initialize(Data
CacheStoreManager.java:221)
at
com.solarmetric.kodo.runtime.StateManagerImpl.loadInitialState(StateManagerI
mpl.java:112)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectByIdFilter(Pers
istenceManagerImpl.java:859)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectById(Persistenc
eManagerImpl.java:781)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.createFromResultSet(
JDBCStoreManager.java:700)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager$2.getResultObject(JD
BCStoreManager.java:652)
at
com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.instantiateRow(LazyRes
ultList.java:168)
at
com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.get(LazyResultList.jav
a:114)
at java.util.AbstractList$Itr.next(AbstractList.java:416)
at
com.solarmetric.kodo.runtime.ResultListIterator.next(ResultListIterator.java
:49)
at
com.solarmetric.kodo.impl.jdbc.runtime.ResultListFactory.createResultList(Re
sultListFactory.java:85)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.executeQuery(JDBCSto
reManager.java:646)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCExtent.getIterator(JDBCExtent.jav
a:49)
at
com.solarmetric.kodo.runtime.ExtentImpl$TransactionAwareIterator.newIterator
(ExtentImpl.java:219)
at serp.util.MultiIterator.setIterator(MultiIterator.java:70)
at serp.util.MultiIterator.hasNext(MultiIterator.java:25)
at
com.solarmetric.kodo.runtime.ExtentImpl$TransactionAwareIterator.hasNext(Ext
entImpl.java:195)
at
net.xtrim.crm.system.persistence.UserFactory.getUsers(UserFactory.java:121)
at
net.xtrim.crm.user.ejb.UserFacadeBean.getUsers(UserFacadeBean.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
..java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(Stateles
sSessionContainer.java:660)
at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(Cach
edConnectionInterceptor.java:186)
at
org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSe
ssionInstanceInterceptor.java:77)
at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor
..java:107)
at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.
java:151)
at
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
at
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:13
0)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
at
org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.jav
a:313)
at org.jboss.ejb.Container.invoke(Container.java:712)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at
org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:382)
at sun.reflect.GeneratedMethodAccessor50.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
..java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:7
01)
at java.lang.Thread.run(Thread.java:536)
Am I doing something wrong?
P.S. Everything works fine if User has no child reference.
Patrick Linskey [email protected]
SolarMetric Inc. http://www.solarmetric.com
Maybe you are looking for
-
Safari 5.1.2 on Lion crashing when I view Downloads
Hello all! I've had this problem for a while now and figured I'd finally try the community for help. I've done my fair share of searching for answers, but I give up!! So Safari normally works great for me. Until I download something. Now it doesn't m
-
What's the best way to do authorization for my app?
The authorization situation is somewhat complicated for my app. Each component of the app is authorized based on not only the user, but also the page number, the value of at least one P0_ITEM. From what I've seen so far, there are two different optio
-
How do I find a photo Jpeg #? The photo book I want to buy will not allow me to buy it because there is a corrrupt photo with a jpeg # of 000_0068.JPG. How do I find this photo, I can't see jpeg #'s anywhere.
-
Generating feedback messages on server-side vs client-side?
Hello, I am maintening a client/server app (Swing client, no Web pages), basically an order processing system. The biggest part of it is to verify the conformity of orders to a set of business rules. As usual, some of the verification can be made ear
-
New portal forum for business packages?
I think it might be useful to have a separate forum under the portals area for business packages. There is often confusion if a question is related to portal content or portal implementation and a separate forum would help this. Cheers