为什么在CMP entity bean加入EJB QL就不行啊?

04-04-25 MatrixJava
只是在bean里面加入了一个finder函数,(由于是CMP,所以是通过JBX自己的向导在在remotehome接口中添加的)

重新编译打包的时候出现下面提示:

"Cmp.jar": Spaces in the temporary directory path may cause WebLogic EJBC utility to produce fatal compile errors.

"Cmp.jar": D:\bea\jdk131_02\bin\javaw -classpath "D:\bea\weblogic700\server\lib\weblogic.jar;D:\JBuilderX\lib\jdsremote.jar;" weblogic.ejbc -keepgenerated -compiler D:/bea/jdk131_02/bin/javac E:/jbproject/ejb2/cmpSample/Cmp.jar.jar E:/jbproject/ejb2/cmpSample/Cmp.jar

"Cmp.jar": ERROR: Error from ejbc: Error while reading 'META-INF/weblogic-cmp-rdbms-jar.xml'. The error was:

"Cmp.jar":

"Cmp.jar": weblogic.ejb20.cmp.rdbms.finders.IllegalExpressionException:

"Cmp.jar": While trying to process Query

"Cmp.jar": Method Name: findByName

"Cmp.jar": Parameter Types: (java.lang.String)

"Cmp.jar": EJB Query: SELECT name FROM Student AS name WHERE name.stuname=?1

"Cmp.jar": )

"Cmp.jar": Could not parse EJB QL expression: SELECT name FROM Student AS name WHERE name.stuname=?1

"Cmp.jar": ERROR: ejbc found errors

下面是我的EJB-XML文件

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

<ejb-jar>

<display-name>Cmp</display-name>

<enterprise-beans>

<entity>

<display-name>Student</display-name>

<ejb-name>Student</ejb-name>

<home>cmpsample.StudentRemoteHome</home>

<remote>cmpsample.StudentRemote</remote>

<local-home>cmpsample.StudentHome</local-home>

<local>cmpsample.Student</local>

<ejb-class>cmpsample.StudentBean</ejb-class>

<persistence-type>Container</persistence-type>

<prim-key-class>java.lang.Integer</prim-key-class>

<reentrant>False</reentrant>

<cmp-version>2.x</cmp-version>

<abstract-schema-name>Student</abstract-schema-name>

<cmp-field>

<field-name>lockerid</field-name>

</cmp-field>

<cmp-field>

<field-name>stuid</field-name>

</cmp-field>

<cmp-field>

<field-name>stuname</field-name>

</cmp-field>

<primkey-field>stuid</primkey-field>

<query>

<query-method>

<method-name>findByName</method-name>

<method-params>

<method-param>java.lang.String</method-param>

</method-params>

</query-method>

<ejb-ql>SELECT name FROM Student AS name WHERE name.stuname=?1</ejb-ql>

</query>

</entity>

</enterprise-beans>

<assembly-descriptor>

<container-transaction>

<method>

<ejb-name>Student</ejb-name>

<method-name>*</method-name>

</method>

<trans-attribute>Required</trans-attribute>

</container-transaction>

</assembly-descriptor>

</ejb-jar>

不知道是为什么,有朋友说CMP的EJB-QL好多问题,不知道是不是真的

huzhigang
2004-04-26 09:05
试试:SELECT OBJECT(name) FROM Student AS name WHERE name.stuname=?1

JFan
2004-04-27 09:22
The return type of a finder

method on the remote home interface must be the entity bean’s remote interface, or a type representing

a collection of objects that implement the entity bean’s remote interface

ccmoon
2004-04-29 09:13
EJB-XML:

select object(o) from Student o where o.stuname=?1

StudentRemoteHome

StudentHome

需要声明

public java.util.Collection findByName

(java.lang.String userid) throws javax.ejb.FinderException;

猜你喜欢