Hi All,
I have a subscription to the yearly documentation. In the documentation I
found an example on how to use Dynamic QL.
Because my code uses XDoclet for code generation I had to modify the
example somewhat. This is what I came up with:
In my EntityBean:
/**
* @param jbossQl
* @param args
* @return
* @throws FinderException
*/
public abstract Collection ejbSelectGeneric(java.lang.String
jbossQl, Object[] args) throws FinderException;
/**
* @ejb.home-method view-type = "local"
* @param edition
* @param week
* @param status
* @param relno
* @param brand
* @return
*/
public Collection ejbHomeSelectBySearchCriteria(
String edition,
String week,
String status,
String relno,
String brand) throws FinderException {
StringBuffer jbossQl = new StringBuffer();
jbossQl.append("SELECT OBJECT(a) ");
jbossQl.append("FROM Advertisement ");
jbossQl.append("WHERE ");
Collection arguments = new Vector();
int count = 0;
if (!edition.equals("%")) {
count++;
jbossQl.append("a.edition = ?" + count);
arguments.add(edition);
}
if (!week.equals("-1")) {
count++;
jbossQl.append("AND a.weekNo = ?" + count);
arguments.add(week);
}
if (!status.equals("-1")) {
count++;
jbossQl.append(" AND a.status = ?" + count);
arguments.add(status);
}
if (!relno.equals("%")) {
count++;
jbossQl.append(" AND a.relation.relationId = ?" +
count);
arguments.add(relno);
}
count++;
if (count == 1) {
jbossQl.append("a.brand = ?" + count + " ORDER BY
a.status");
} else {
jbossQl.append(" AND a.brand = ?" + count + "
ORDER BY a.status");
}
arguments.add(brand);
System.out.println(jbossQl.toString());
System.out.println("Arguments:");
Iterator it = arguments.iterator();
count = 0;
while (it.hasNext()) {
count++;
System.out.println("" + count + " : " + (String)
it.next());
}
// pack arguments in Object[]
Object[] args = arguments.toArray();
return ejbSelectGeneric(jbossQl.toString(), args);
}
In my Session Facade:
/**
* @ejb.interface-method
* @param edition
* @param week
* @param status
* @param relno
* @return
*/
public Collection getAdvertisementBySearchCriteria(
String edition,
String week,
String status,
String relno,
String brand) {
AdvertisementLocalHome home = getAdvertisementLocalHome();
Collection col = home.selectBySearchCriteria(edition,
week, status, relno, brand);
return null;
}
When I run XDoclet I get the following jboss-cmp-jdbc.xml (part):
<query>
<query-method>
<method-name>ejbSelectGeneric</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>Object[]</method-param>
</method-params>
</query-method>
<dynamic-ql/>
</query>
This look good to me... Then I package my EAR and try to deploy, I get the
following error:
10:41:51,617 INFO [EARDeployer] Init J2EE application:
file:/usr/java/jboss-3.2.2RC4/server/om/deploy/ordermanager-ejb.ear
10:42:00,808 WARN [verifier] EJB spec violation:
Bean : Advertisement
Method : public abstract Collection ejbSelectGeneric(String, Object;)
throws FinderException
Section: 12.2.11
Warning: Each local home method must match a method defined in the entity
bean class.
10:42:01,207 ERROR [MainDeployer] could not create deployment:
file:/usr/java/jboss-3.2.2RC4/server/om/tmp/deploy/tmp9917ordermanager-ejb.ear-contents/ordermanager-ejb.jar
org.jboss.deployment.DeploymentException: Verification of Enterprise Beans
failed, see above for error messages.
at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:490)
at org.jboss.deployment.MainDeployer.create(MainDeployer.java:776)
at org.jboss.deployment.MainDeployer.create(MainDeployer.java:768)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:631)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
at $Proxy6.deploy(Unknown Source)
What am I doing wrong here? I can't find any more examples neither in the
'pay' documentation or on the net...
Thanks a lot,
Harm de Laat
Informatiefabriek
The Netherlands
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user