Hi.
I work with the Gangster CMP example and reengineered the Xdoclet tags.
Everything works great, and without Xdoclet, I do not know how I could
have managed to do anything useful...

Problem is that this example does not cover some of the interesting cases.

I describe the simplest here. If someone is interested I can as well
deliver full Eclipse projects with Xdoclet.

Problem:

(JBoss 3.2.1-tomcat, CMP Gangster Example of 3.2.1 Documentation)

I try to use a simple CMP field in an EJB query, and I get a
"org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement
'SELECT OBJECT(u) FROM gangster u WHERE u.bestFriend = ?1';
- nested throwable: (java.lang.NullPointerException)"

Is it not possible to use CMP fields in EJB queries?

I did this as close to the JBoss 3.2.1 documentation as possible:
1) added setter/getter for 'bestFriend' to bean,
2) added declarations to local interface,
3) added finderdeclaration to local home
4) added CMP-field and query-definition of finder to ejb-jar.xml

My query is SELECT OBJECT(u) FROM gangster u WHERE u.bestFriend = ?1
and I get the Error compiling EJB-QL statement error.

What do I wrong?

One more info: it must be in the "WHERE u.bestFriend = ?1" part, if I leave that
away, everything works perfectly.

Best, Philipp

Details:
-------
I add the getter and setter for a new field bestFriend to the GansterBean.java:
/**
* @return
* @ejb.persistence
* column-name = "friend"
* @ejb.interface-method
*/
public abstract Gangster getBestFriend();
/**
* @param u
* @ejb.interface-method
*/ public abstract void setBestFriend(Gangster u);

Xdoclet adds them to the local interface Gangster.java:
//new:
    Gangster getBestFriend();
    void setBestFriend(Gangster u);

Xdoclet adds the CMP-field definition to ejb-jar.xml:
      <cmp-field>
           <description><![CDATA[]]></description>
           <field-name>bestFriend</field-name>
       </cmp-field>


I add the finder Xdoclet to the GangsterBean:

* @ejb.finder
* signature = "java.util.Collection findBestFriend(org.jboss.cmp2.crimeportal.Gangster g)"
* query = "SELECT OBJECT(u) FROM gangster u WHERE u.bestFriend = ?1"


Xdoclets adds to the ejb-jar.xml:
<query>
<query-method>
<method-name>findBestFriend2</method-name>
<method-params>
<method-param>org.jboss.cmp2.crimeportal.Gangster</method-param>
</method-params>
</query-method>
<ejb-ql><![CDATA[
SELECT OBJECT(u) FROM gangster u WHERE u.bestFriend = ?1
]]></ejb-ql>
</query>

Xdoclet adds the corresponding declaration to the local home interface GanagsterHome.java:

//new:
java.util.Collection findBestFriend2(org.jboss.cmp2.crimeportal.Gangster g) throws FinderException;



Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to