How-to-ejbql

Hi! I got an error 'java.sql.SQLException: ORA-01008: not all variables bound' when i run the 'how-to-ejbql' sample code from otn.oracle.com. I checked the generated sql in orion-ejb-jar.xml and they seem to look good. In fact I runned the generated sql in sqlplus and they all worked. Also run the container with -Denable.ejbql=true. Any ideas?
Thanks
Win2000
OC4J1.3 Dev. prev.

Hi Jeff, here's the portion of the ejb-jar.xml with custom finder..
<query>
<description></description>
<query-method>
<method-name>findByDeptno</method-name>
<method-params>
<method-param>double</method-param>
</method-params>
</query-method>
<ejb-ql>select distinct object(e) from Emp e where e.deptno = ?1 </ejb-ql>
</query>
and here's the equivalent generated file orion-ejb-jar.xml
<finder-method query="SELECT DISTINCT OBJECT(e) FROM Emp e WHERE (e.deptno = ? )">
     <!-- Generated SQL: "SELECT DISTINCT e.empno, e.ename, e.job, e.mgr, e.hiredate, e.sal, e.comm, e.deptno FROM Emp e WHERE (e.deptno = ? )" -->
     <method>
     <ejb-name>Emp</ejb-name>
     <method-name>findByDeptno</method-name>
     <method-params>
     <method-param>double</method-param>
     </method-params>
     </method>
</finder-method>
As previously written, the custom finder method 'findByDeptNo' will cause an sql exception.
Thanks.
Win2000
Oracle9iAS (9.0.3.0.0)

Similar Messages

  • How to write join queries in EJBQL

    Hi
    I have a join query as follows:
    SELECT a.person_seq_id FROM fr_node_employees a,fr_nodes b,fr_node_owners c
    WHERE b.node_seq_id=c.node_seq_id AND a.node_seq_id=c.node_seq_id AND c.person_seq_id=?
    O/R mapping for tables:
    fr_node_employees - NodeEmployee
    fr_nodes - Node
    fr_node_owners - NodeOwner
    How to write this query in ejbql or can anyone give some information about ejbql will be helpful.
    Thanks,
    Satish.

    http://www.hibernate.org/hib_docs/entitymanager/reference/en/html/queryhql.html

  • How to join entity in the EJBQL?

    Dear all,
    I have written the following EJBQL:
    select o from Commitment o join o.invoiceStat i where o.companyCode = 'HKC' and o.item = 'ABCD01' and i.year = 2008
    The entity class is as follows:
    public class Commitment implements Serializable {
    @Column(name="commitment_amt",nullable = false)
    private Double commitmentAmt;
    @Id
    @Column(name="item_code",nullable = false)
    private String item;
    @Id
    @Column(name="institution_code",nullable = false)
    private String companyCode;
    @OneToMany(mappedBy = "commitment")
    private List<InvoiceStatistic> invoiceStat;
    I join the invoiceStat in the EJBQL and also I need to filter, ie. i.year = 2008,
    but maybe because of invoiceStat is a OneToMany List Object, the EJBQL didn't filter using i.year=2008.
    How could I filter the OneToMany ? Please help
    Thanks.

    What is this forum called? What languages does it focus on?
    Have you bothered to even read what stands at the top of this page and every other page in this forum?
    h2. SQL and PL/SQL
    Not Enterprise Java Beans bastardised query language called EJBQL.

  • Where Clause. AND how to in ejbql??

    Hi This is what I want to add:
    select e from DataBean where e.userId = ?1 AND e.name = ?2
    How can I do this?? Please respond asap if you know the ans.
    Thanks, Bhavna.

    SELECT OBJECT(p) FROM DataBean AS p WHERE p.userId=?1 AND p.name=?2
    Note: 'DataBean' is the <abstract-schema-name> as defined in the ejb-jar.xml.

  • How to limit the number of Entitiy Beans returned by an EJBQL ??

    Hi developpers,
    I'm working on an application using EJB 3.0, TOPLINK and JSF with JDeveloper 10g,
    I want to get just the four first items from a database using an entity bean so i used this query :
    @NamedQuery(name="chercherNDerniersDSalaire", query="select object(o) from DSalaire o where o.dImmatricule.immVNumImm = :nCNSS ORDER BY o.salNAnnee DESC, o.salNPeriode DESC LIMIT 4")
    but it returns all the items (10) !!
    please help me :-( I don't know why it ignores the LIMIT clause
    thanks all

    Hello
    Rownum works fine with oracle target database and query in sql mode instead of ejb-ql. Ejb-ql Limit declaration is normally translated as sql rownum <= and rownum > form.
    I didn't find anything in the ejb 3.0 final release specification about the limit declaration in a ejb-ql order by clause.
    May be it will be interesting to debug the sql statement that is generated for the database.

  • How to write EJB-QL query with IN notation and list values EJB3.0?

    hi,
    I would like to write an EJB-QL query where the query would return the objects whose name equals to one of the names in the list.
    SELECT DISTINCT OBJECT(feature) FROM MAPSHEET_LOCK feature WHERE feature.name IN ?1
    For ?1 I would like to pass in a list. How can I write this query?
    Thanks

    List<String> names;
    StringBuilder sb = new StringBuilder("SELECT DISTINCT OBJECT(feature) FROM MAPSHEET_LOCK feature WHERE feature.name IN (");
    String separator = "";
    for (String name : names) {
      sb.append(separator);
       sb.append("'");
       sb.append(name);
       sb.append("'");
       separator = ", ";
    sb.append(")");
    String ejbql = sb.toString();
    // Code for execute query
    ....Message was edited by:
    Rulas

  • ReadAllQuery using named EJBQL from Mapping Workbench

    Hi,
    how to use named EJBQL queries defined in Mapping Workbench in code.
    ReadObject queries can be done using:
    MyObject o = (MyObject)getUnitOfWork().executeQuery("findById", MyObject.class, id);
    But I need to a Collection back. So how do I have to do this???
    Andy

    If you want a collection back you must define the query as a ReadAllQuery in the Mapping Workbench.
    then your code will be,
    List objects = (List)getUnitOfWork().executeQuery("findById", MyObject.class, id);
    However you will probably use something other than id for the query, as the id will normally only return a single object.
    If you just want a colleciton back from the ReadObject then just create and add the object to the collection.

  • EJBQL syntax in OC4J

    Hi,
    I am migrating an application from Weblogic to OC4J. I'm getting an error while using a SQL statement for EJB-QL in Oc4J. It works fine from Weblogic app server. The EJB-QL SQL used in ejb-jar.xml is something like the following:
    <ejb-ql>SELECT      OBJECT(o) FROM tableA AS o WHERE (o.column1 = ?1 OR (?1 IS NULL AND o.column1 IS NULL)) AND     (o.column2 = ?2 OR ( ?2 IS NULL AND o.column2 IS NULL)) AND (o.column3 = ?3 OR ( ?3 IS NULL AND o.colum3 IS NULL)) AND (o.column4 = ?4 OR ( ?4 IS NULL AND o.column4 IS NULL)) AND     (o.column5 = ?5 OR ( ?5 IS NULL AND o.column5 IS NULL))</ejb-ql>
    Can somebody point out what could be wrong in the SQL? The same EJB-QL SQL executes properly from the SQL*Plus command. Is there a syntax error in the statement?
    How can I modify this so that it does not affect the result of the SQL? There is some problem with the use of brackets. I tried some combinations but no luck.
    When deploying the EJB to OC4J with the above SQL as EJB QL SQL, I got the following error:
    com.evermind.client.orion.AdminCommandException: Deploy error: deploy failed!: ; nested exception is:
         oracle.oc4j.admin.internal.DeployerException: Error initializing ejb-module; Exception Error translating EJBQL: Encountered "?1 IS" at line 1, column 31.
    Was expecting one of:
    "NOT" ...
    "+" ...
    "IdentificationVar" ...
    <CHAR_LITERAL> ...
    <STRING_LITERAL> ...
    <INPUT_PARAM> "*" ...
    <INPUT_PARAM> "/" ...
    <INPUT_PARAM> "+" ...
    <INPUT_PARAM> "-" ...
    <INPUT_PARAM> ")" ...
    <INPUT_PARAM> "NOT" ...
    <INPUT_PARAM> "BETWEEN" ...
    <INPUT_PARAM> "MEMBER" ...
    "CONCAT" ...
    "SUBSTRING" ...
    "LOCATE" ...
    "LENGTH" ...
    "ABS" ...
    "SQRT" ...
    EJB QL statement : 'SELECT      OBJECT(o) FROM tableA AS o WHERE (o.column1 = ?1 OR (?1 IS NULL AND o.column1 IS NULL)) AND     (o.column2 = ?2 OR ( ?2 IS NULL AND o.column2 IS NULL)) AND (o.column3 = ?3 OR ( ?3 IS NULL AND o.colum3 IS NULL)) AND (o.column4 = ?4 OR ( ?4 IS NULL AND o.column4 IS NULL)) AND     (o.column5 = ?5 OR ( ?5 IS NULL AND o.column5 IS NULL))
    Thanks for your help.
    vadi.

    Hi,
    Can somebody please give me few pointers or clues?
    Thanks,
    Vadi

  • OC4J EJBQL and EJB 2.0 features

    Hello Debu Panda and All
    I've got all howtos and I mangaged to get some parts of OC4J [Oracle9iAS (9.0.3.0.0) Containers for J2EE (build 020323.1689)] working.
    There are still some issues that are stalling our development. Could you please comment on them, maybe providing an estimate of when they will be solved/implemented?
    First of all, a little background. Our application uses many Java Swing application clients that connect to the EAR application in the container.
    The ear application has the following structure:
    All database access (Oracle 8i, located in its own server) is done exclusively by means of CMP entity beans. A entity bean may access other entity beans. There are workflow session beans (stateful and stateless) that access the entity beans. All clients see only the workflow session beans (session beans fagade).
    Our applicatoin is complex, having more than 80 session beans and more than 25 entity beans (not counting entity beans that exist only to represent relationships among entity beans).
    There goes the questions:
    1) It seems that entity beans cannot currently be referenced by remote interfaces. We couldn't deploy our application using it. Since we could use only local interfaces fot entity beans, thats what is been done now.
    2) There is no CMR supported. Is this true?
    3) EJBQL seems to be very limited. In the howto examples there are EJBQL statements that compare two numbers. However, when we tried to use String comparisons, it didn't work. Here is the statement:
    "SELECT DISTINCT OBJECT(p) FROM Person p WHERE p.name = ?1"
    If I compile, package and deploy the ear applicatin with the above EJBQL statement, OC4J generates an exception when executing the finder method. The exception is:
    "java.rmi.NoSuchObjectException: Session has timed out
    at com.evermind.server.ejb.StatefulSessionEJBObject.throwPassivisat
    ception(StatefulSessionEJBObject.java:188)
    at Cad023Remote_StatefulSessionBeanWrapper0.obterPessoasPorParteNom
    023Remote_StatefulSessionBeanWrapper0.java:754)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:8
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64)"
    If I remove the where clause, the expection is gone. However, I get all records. ;-)
    4) It seems that all EJBQL clauses must be capitalized. Is this true?
    FINALY)
    Is there a newer OC4J build that could use to get the development going? Do you know where there will be one? Is there any way of contacting the OC4J development team to report bugs?
    If you would like, we could discuss it in private e-mail (please use my private mail [email protected]).
    Thanks for your attention,
    Luis Fernando Soeiro
    Hi !! OC4J 9.0.3 developer's preview has most features of EJB 2.0. We are working on updating on our docs and samples for EJB 2.0
    Please look at the following URL that has some How Tos on EJB 2.0 features such Local Interfacea, EJB QL, etc : http://otn.oracle.com/tech/java/oc4j/htdocs/oc4j-how-to.html#ejb
    regards
    Debu Panda
    Oracle --------------------------
    Luis Soeiro <mailto:[email protected]> <mailto:[email protected]>Type : Question Date : Apr 11, 2002 15:15 PT Hello
    Some colleagues and I are trying to port a large project from JBOSS to OC4J. We used JBOSS 3.0 (beta) in order to evaluate EJB2.0 features and see if we could use it. We already have OC4J in production, but only as a JSP/Servlet container. The next step would be to deploy our EJB application to OC4J.
    We have read the material and it is written that OC4J (developers preview) is EJB 2.0 compliant. However, the specific documentation and the examples don't show how to specify OC4J specifc XML files. We absolutely need CMR and Local Interfaces, because we don't have the time required to downgrade our JBoss EJB2.0 application to the EJB 1.1 specification. We have over 80 Session Beans and over 20 Entity Beans.
    Is there anybody there that can confirm that OC4J developer's preview is really EJB2.0 compliant? If so, could you send me some pointers to information about OC4J container specifc deployment descriptors? The docs listed at the web site don't have EJB2.0 features listed, nor does the Oracle samples.
    Thanks for your attention,
    desperately,
    Luis Fernando Soeiro

    HI,
    I worked out CMR and EJB-QL with single bean.
    Using CMR, it is possible to get one bean reference through other bean, but
    When I tried EJB-QL with bean to bean navigation then I run into problem.

  • EJBQL IN or not IN?

    I'm trying to develop an EJBQL query, and I can't seem to express what I want - there may be a way, please let me know what you think.
    The schema: I have a table called 'Vouchers', and a table called 'Courses'. There is a many-to-many relationship between the two, represented by a join table - 'VouchersCourses'. But some vouchers always relate to all courses; these vouchers have field 'courseCoverage' set to 3, and are not represented in the join table.
    The finder: I want to find all the vouchers for a given courseID. The result should include all the vouchers that specifically reference the course, plus all the vouchers that are valid for all courses.
    I tried the following:
    * @ejb.finder
    *           view-type = "local"
    *           signature="Collection findByCourse(java.lang.String crsId)"
    *      query="SELECT DISTINCT OBJECT(v) FROM VoucherSchema v, IN (v.courses) AS c WHERE v.courseCoverage = 3 OR c.id = ?2"But the resulting Collection ignores all those with courseCoverage = 3. I guess this is because these vouchers are not IN v.courses!
    How do I retrieve all the relevant vouchers in v.courses, PLUS all those that are not in v.courses, but have courseCoverage = 3?
    Thank you for your help.
    Bruno.

    Correction - the query should read:
    *      query="SELECT DISTINCT OBJECT(v) FROM VoucherSchema v, IN (v.courses) AS c WHERE v.courseCoverage = 3 OR c.id = ?1"But the problem remains.
    Hope someone can suggest a solution.
    Bruno.

  • Using sub quries in EJBQL

    Hi
    I am using EJBQL to extract the employee records from database with EJB3 using toplink
    query is as follows
    "SELECT e FROM Employee e WHERE e.empId not in (Select a.empId.empId FROM Attendancerecord a WHERE a.date = :date)"
    where each employee has many attendance record and in reverse each attendance record tuple has one employee relation
    what I want to do is to 'select all those employees for which there is no record in Attendance record for specific date '
    when executing the exception caught is that
    java.sql.SQLException: Subquery returns more than 1 row
    e.empId is an integer
    kindly help
    rgards
    Hina

    Think about how the e-mail will look to the person reading it. There will be some links, of course. And how should those links look? They should look like something that somebody could use from anywhere on the Internet. So obviously "C:\data\wombat.gif" isn't going to work. Your best bet is for the link to look something like "http://www.animallovers.org/wombat.gif", and that means you need a web server that can serve out those files.

  • Does EJBQL in JDeveloper support max aggregate function ?

    Does EJBQL in JDeveloper support max aggregate function ?
    I can't get it to work using select max(o.time) from MyObject o; It always returns the MyObject to me.
    Anybody knows how to do this ?
    Thanks.

    No one knows how exactly this works in JDeveloper 11g? As I see it, it's most likely a bug. For one, JDeveloper already supports plenty of databases and enforces some limitations on the useability of these databases where necessary (for instance, JDBC Positioning instead of Oracle's way of binding for the bind variables in a query). However, this enforcement does not happen with the WHERE clause of the view criteria in MySQL when you choose an operator that concatenates strings together in the WHERE clause, such as "contains". You'd expect it's smart enough to use different syntax for concatenating the strings, depending on the database (e.g., CONCAT for MySQL, || for Oracle). Second, lack of this enforcement should not break functionality, and here it does (searching with wildcards in LOV is just not possible declaratively with MySQL), which resembles a bug in the software.
    For now, I've completely rewritten the LOV in Java, so it's not declarative anymore, but programmatic. It works, resembles searching with "contains" and it stays that way, despite of the higher difficulty in maintenance, until this issue can be solved declaratively, by any means: via a patch release or via a workaround. I hope someone can provide me (and quite possibly others facing this issue) with insight upon this.
    Thanks in advance.

  • EJBQL joining entity problem

    Dear all,
    I have written the following EJBQL:
    select o from Commitment o join o.invoiceStat i where o.companyCode = 'HKC' and o.item = 'ABCD01' and i.year = 2008
    The entity class is as follows:
    public class Commitment implements Serializable {
    @Column(name="commitment_amt",nullable = false)
    private Double commitmentAmt;
    @Id
    @Column(name="item_code",nullable = false)
    private String item;
    @Id
    @Column(name="institution_code",nullable = false)
    private String companyCode;
    @OneToMany(mappedBy = "commitment")
    private List<InvoiceStatistic> invoiceStat;
    I join the invoiceStat in the EJBQL and also I need to filter, ie. i.year = 2008,
    but maybe because of invoiceStat is a OneToMany List Object, the EJBQL didn't filter using i.year=2008.
    How could I filter the OneToMany ? Please help
    Thanks.

    from Commitment c
    left join fetch c.invoiceStat s
    where s.year = 2008
    something like that?

  • How to sort collections with EJB 2.0?

    As you know there is no ORDER BY statement in EJB QL; so I receive unsorted collection of objects from finder-methods. The process of Collections.sort() is very slow... Any ideas how to make a quick sort?

    Order by is a EJBQL 2.1 feature. It can be found in coming release of s1AS8.
    In JDK 1.4, merge sort is used in Collections.sort. It has a O(nlogn) algorithm. While quick sort only has an average O(nlogn) algorithm. If you are using custom Comparator, then you may to check about its implementation.

  • How to deploy CMP entity bean 2.0 ?

    Dear all,
    How should I write the EJB-QL for all the finder methods in my home bean during deployment? I�m using the j2sdkee-1_3_01-win to test out this bean. I have tried the following query:
    SELECT OBJECT(a) FROM ProductBean AS a WHERE basePrice > ?1 but when I try to verify the bean, an error message appeared:
    Error: [ SELECT OBJECT(a) FROM ProductBean AS a WHERE basePrice > ?1 ] has parsing error(s)
    Here is the detail:
    Test Name: tests.ejb.entity.ejbql.EjbQLFromCmpEntityDescriptor
    Test Assertion: EJB 2.0 Spec Chapter 10 Container managed persistent queries should comply with specification in its sytax and semantic rules
    Detailed Messages:
    Error: [ SELECT OBJECT(a) FROM ProductBean AS a WHERE basePrice > ?1 ] has parsing error(s)

    Hope this is not too late...
    SELECT OBJECT(a) FROM ProductBean AS a WHERE a.basePrice > ?1

Maybe you are looking for

  • DB Table for logical systems

    Hi all, Does anyone know, in which database table we can find the list of  logical systems, which are RFC targets of a system. In table TBDLS, I found the logical systems for the clients of a system, but I want to know if a logical system given as a

  • Sparsebundle could not be created (error 45)

    I just bought my first ever Mac a little over 30 days ago and also purchased a 1TB Seagate FreeAgent GoFlex Home network storage system. I immediately installed the GoFlex software that included a full integration into Time Machine. This worked perfe

  • How do i detect am empty text field condition?

    Hi im a newbie with swing. I have a small problem. I have a text field. When user types some text into it i display a pane in the GUI. When the text field is cleared, i need to hide the pane. So basically i need to detect the condition when the text

  • Blackout

    I received my new MBA 13" for three day, but it encountered blackout( black screen) twice a day when using in normal condition. Is this a software or hardware issue? If it is the former, I prefer to waiting for a update. If it is a issue relating to

  • Remote will not scroll down.

    After downloading an update, the remote will not scroll down.  Unable to do anything except buy iTunes movies.