I'm trying to figure out how to use a direct sql call and make castor spit
out a QueryResult set of persistence objects.
I'm building a pretty run of the mill Group/Role/Permission security system.
What I want is to retrieve a ResultSet listing all the
group/roles/permissions a particular User has. I realize I can't retrieve a
ResultSet direct from a Castor query, so my next best option is to get
castor to transform the ResultSet into Persistent Objects. I've got the
query all built, which returns a ResultSet of gname,rname,pname (more than
one row of course). The values are taken from multiple tables with various
joins etc... The SQL statement works as I've tried it direct on my database.
Direct SQL statement returns
gname,rname,pname.
Mapped Persistent object (FakeACL) has methods
get/set Gname (String)
get/set Rname (String)
get/set Pname (String)
Mapping file is as follows:
<class name="FakeACL" identity="gname rname pname">
<map-to table="fake_acl" />
<field name="gname" type="string" required="true">
<sql name="gname" type="varchar"/>
</field>
<field name="rname" type="string" required="true">
<sql name="rname" type="varchar"/>
</field>
<field name="pname" type="string" required="true">
<sql name="pname" type="varchar"/>
</field>
</class>
What I run in code is:
q = db.getOQLQuery( "CALL SQL SELECT g.gname, r.rname, p.pname
FROM .......grum.user_id=? AS " +
FakeACL.class.getName() );
q.bind( bUser.getId() );
qr = q.execute();
What I get as an error message is:
java.lang.IllegalArgumentException: Only 0 fields in this query
at
org.exolab.castor.jdo.engine.OQLQueryImpl.bind(OQLQueryImpl.java:153)
at ......
If anybody knows how to make this work I would be forever in their debt
(well I'd be mighty happy and very thankful atleast)
Cheers,
Bert.
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev