-
1. Re: java query question
riddler3479 Sep 26, 2003 1:01 PM (in response to riddler3479)fixed to db driver issues
-
2. Re: java query question
caprieto Oct 2, 2003 3:03 AM (in response to riddler3479)The value pass to is a String? may need use quotes.
-
3. Re: java query question and example on how to use ejbSelect
tsg26 Oct 3, 2003 7:01 PM (in response to riddler3479)Hello,
Just a suggestion only, why don't you used entity CMP to managed your sql transaction and used EJB-QL language, to perform SQL query .
Just to help you to get started , in your entitybean do not specify finder used ejbselect instead ,as it prove much more flexible.
All the jboss book in the market just could not tell a simple thing on how to make use of ejbSelect
here are my suggestions.
1. specify the collection to make use of ejeSelect like eg given ejbSelectMat()
in your entity bean
public abstract Collection ejbSelectMat() throws FinderException;
2. specify the the query method in your entity bean to get the result through home interface QueryMat where ejbHome is a must
public Collection ejbHomeQueryMat() throws FinderException {
try {
return ejbSelectMat();
} catch (Exception e) {
return null;
}
}
3. in the ejb-jar.xml files
<![CDATA[]]>
<query-method>
<method-name>ejbSelectMat</method-name>
<method-params>
</method-params>
</query-method>
<result-type-mapping>Remote</result-type-mapping>
<ejb-ql><![CDATA[SELECT cmas.code FROM codemaster cmas where cmas.ctype='MAT']]></ejb-ql>
4. the above if translated to plain SQL query would equivalent to
[select code form codemaster where ctype="MAT"]
wouldn't it is much simpler to manage through CMP 2.0
using ejb 2 , the order by clause is only available in ejb 2.1 or some other J2ee server like resin for example but not jboss .
Thanks