Firstly, I figured out the setClassLoader issues; I was creating the objects in the wrong sequence, and the class loader wasn't set yet.
But one of my queries also gave me problems. The query:
db.getOQLQuery("SELECT s FROM Shop s WHERE id=$1")
doesn't work at all. Even though the class Shop is used elsewhere in the program, and a call to "jdo.create(new Shop())" works okay, the query above still throws a QueryException: "cannot find class Shop."
So, I modified it:
db.getOQLQuery("SELECT s FROM com.rjkcomm.Shop s WHERE id=$1")
which works fine. However, this is going to get onerous if I define my classes as part of a package and have to specify them in full every time. Is there a way to get around this in the OQL?
Also, and perhaps as a more general answer to this, is there a definitive reference to OQL as used in Castor?
Thanks for any help,
Rob
Robert Kent writes:
Hi all. I'm new to Castor; I've been reading the documentation on the website, and also download the shop/shoptest example from the "articles" page (URL of that example: http://www.drrockit.com/space/castorcodeexample)
I was having path problems, so I put all of the classes into a package, com.rjkcomm, to try and alleviate that. My path:
./ <-- this ("./") is in the classpath
database.xml
shop-mapping.xml
com/
rjkcomm/
Shop.class
ShopTest.class
The problem:
when I try to run the ShopTest class via "java com.rjkcomm.ShopTest", I get this exception:
org.exolab.castor.mapping.MappingException: Nested error: org.exolab.castor.mapping.MappingException: Could not find the class com.rjkcomm.Shop
So, how do I get the Shop class to load? It's in the appropriate path for its package, and the path is in the classpath.
Pertinent Source Code:
ShopTest.java:
try {
JDO.loadConfiguration( "database.xml" );
} catch (MappingException e) {
System.out.println("Exception: "+e);
}
database.xml
[ has a mapping element pointing to relative path "shop-mapping.xml" ]
shop-mapping.xml:
<mapping>
<class name="com.rjkcomm.Shop" identity="id">
<!-- ... -->
</mapping>
Prior Messages:
I did search the list archives, and came up with this message:
http://castor.exolab.org/list-archive/msg19773.html
... which suggests using the "setClassLoader" method to fix problems like this. Except that JDO.loadConfiguration() is a static method, and JDO.setClassLoader() is not, and it's my understanding that you're supposed to do a loadConfiguration() before you allocate an instance of JDO with the appropriate database name in the constructor. So, I'm not sure how to use setClassLoader in this situation.
If this has been addressed elsewhere, please point me to the reference.
Platform Details:
JDK 1.4.0_02
[ executing from the command line, no servlets or jsp ]
Castor 0.9.4.2
MySQL 3.23.49-8
on debian 3.0
Thanks for any assistance,
_________________________________
Robert Kent - (617) 413-3510
http://www.rjk-comm.com/
_________________________________
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
_________________________________
Robert Kent - (617) 413-3510
http://www.rjk-comm.com/
_________________________________
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
