Named Query problem

Hi,
I have a new Query proplem: Following named Query doesn't work.
<?xml version="1.0"?>
<jdoquery>
<query name="findByArticleId">
select from salt.domain.orderservice.entity.TestOrder where
testOrderPositions.contains(testOrderPosition) &&
testOrderPosition.idArticle==:t</query>-->
</jdoquery>

Sorry, please ignore my posting! I've found the mistake!

Similar Messages

  • Named query problem, [TOPLINK-6008] error

    I created a simple table in database (one column, two rows). I created java class and Data Control and dragged the Data Control onto JSP page. Data were shown ok. Then I tried to create named query (simple SELECT MyCol FROM FROM MyTable). This time the new Data Control on JSP didn't work (no data shown). So I tried this scriptlet on jsp:
    <%
    String sDC = "MyDataControl";
    DCDataControl dc = HttpBindingContext.getContext(request).findDataControl(sDC);
    ClientSession cs = ((ToplinkDataControl)dc).getClientSession();
    Vector all = (Vector)cs.executeQuery("MyNamedQuery",mypackage.MyTable.class);
    %>
    Last row causes error
    Exception [TOPLINK-6008] (OracleAS TopLink - 10g (9.0.4) (Build 031126)): oracle.toplink.exceptions.QueryException
    Description: Missing descriptor for [mypackage.MyTable] for query named [MyNamedQuery].
         at oracle.toplink.exceptions.QueryException.descriptorIsMissingForNamedQuery(QueryException.java:282)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:878)
         at dataPage.jspService(dataPage.jsp:26)
    Does anybody have an idea why the jsp page with Data Control based on named query is empty and why above scriptlet causes that error ? Thanks.

    This solution only applies to earlier version of JDeveloper. In 10.1.3 the TopLink metadata (XML deployment descriptor) is automatically generated during the build/make process as required. In earlier version this is a required step after any change is made to the mappings .
    Doug

  • Named query problem with "like" statement

    I'm having issues with a named query that contains a 'like' statement in it. I have other named queries that have like statements that have hardcoded like values in them that work fine.
    (i.e. select * from foo where foo.col1 like 'foo%' )
    But when the like value to be tested is a parameter, it doesn't seem to work at all, no matter what variation i've tried, other than no wildcards.
    (i.e.
    this DOES work
    select * from foo where foo.col1 like #fooParm
    this DOES NOT work
    select * from foo where foo.col1 like '%#fooParm%'
    Any suggestions on how to get this to work?
    Thanks in advance

    Try building your select statement in a different way.
    Instead of:
    select * from foo where foo.col1 like '%#fooParm%'
    Try something like:
    select * from foo where foo.col1 like '#fooParm'
    And include the wild cards in the parameter.
    i.e. if fooParam was 'abc', make fooParm = '%abc%'

  • Named query in Entity Bean - Problem with embedded class

    Hello Forum,
    I'm trying to set up a named query in my Entity Bean and I'm unable to get
    it up and running for an embedded class object.
    The class hierarchy is as follows:
             @MappedSuperclass
             AbstractSapResultData (contains dayOfAggregation field)
                     ^
                     |
            @MappedSuperclass
            AbstractSapUserData (contains the timeSlice field)
                     ^
                     |
              @Entity
              SapUserDataThe named query is as follows:
    @NamedQuery(name = SapUserDataContext.NAMED_QUERY_NAME_COUNT_QUERY,
                                query = "SELECT COUNT(obj) FROM SapUserData AS obj WHERE "
                                         + "obj.sapCustomerId"
                                         + "= :"
                                         + SapResultDataContext.COLUMN_NAME_SAP_CUSTOMER_ID
                                         + " AND "
                                         + "obj.sapSystemId"
                                         + "= :"
                                         + SapResultDataContext.COLUMN_NAME_SAP_SYSTEM_ID
                                         + " AND "
                                         + "obj.sapServerId"
                                         + "= :"
                                         + SapResultDataContext.COLUMN_NAME_SAP_SERVER_ID
                                         + " AND "
                                         + "obj.dayOfAggregation.calendar"
                                         + "= :"
                                         + DayContext.COLUMN_NAME_DAY_OF_AGGREGATION
                                         + " AND "
                                         + "obj.timeSlice.startTime"
                                         + "= :"
                                         + "timeSliceStartTime"
                                         + " AND "
                                         + "obj.timeSlice.endTime"
                                         + "= :"
                                         + "timeSliceEndTime")The query deploys and runs except that part:
                                         + "obj.dayOfAggregation.calendar"
                                         + "= :"
                                         + DayContext.COLUMN_NAME_DAY_OF_AGGREGATIONI don't see any difference to the part of the query accessing the timeSlice
    field which is also an embedded class object - I access it in exactly the same way:
                                         + "obj.timeSlice.startTime"
                                         + "= :"
                                         + "timeSliceStartTime"
                                         + " AND "
                                         + "obj.timeSlice.endTime"
                                         + "= :"
                                         + "timeSliceEndTime"The problem is that the complete query runs on JBoss application server
    but on the SAP NetWeaver application server it only rund without the
                                         + "obj.dayOfAggregation.calendar"
                                         + "= :"
                                         + DayContext.COLUMN_NAME_DAY_OF_AGGREGATIONpart - If I enable that part on SAP NetWeaver the server complains:
    [EXCEPTION]
    {0}#1#java.lang.IllegalArgumentException: line 1: Comparison '=' not defined for dependent objects
    SELECT COUNT(obj) FROM SapUserData AS obj WHERE obj.sapCustomerId= :sap_customer_id AND obj.sapSystemId= :sap_system_id AND obj.sapServerId= :sap_server_id AND obj.dayOfAggregation.calendar= :day_of_aggregation AND obj.timeSlice.startTime= :timeSliceStartTime AND obj.timeSlice.endTime= :timeSliceEndTime
                                                                                                                                                                                                 ^I know that this isn't an application server specific forum but the SAP NetWeaver server is the most strict EJB 3.0 and JPA 1.0 implementation I've seen so far so I think I'm doing something wrong there.
    Someone in the SAp forum mentioned:
    The problem here is that you compare an input-parameter with an embeddable field of your entity.
    Regarding to the JPQL-grammer (spec 4.14) you are not allowed to compare
    with the non-terminal embeddable field but with the terminal fields of your
    embeddable. Stating that your embedded class might have the fields
    startTime and endTime your JPQL query might look like this:
    Query q = em.createQuery("SELECT count(obj.databaseId) FROM SapUserData obj WHERE obj.timeSlice.startTime = :startTime AND obj.timeSlice.endTime = :endTime");
    q.setParameter("startTime", foo.getStartTime());
    q.setParameter("endTime", foo.getEndTime());
    q.getResultList();
    This limitation in the JPQL grammar is rather uncomfortable.
    An automatic mapping of the parameter's fields to the terminal fields of your
    embedded field would be more convenient. The same can be said for lists
    as parameter-values which is possible in HQL, too. I think we have to wait
    patiently for JPA 2.0 and hope for improvements there. :-)
    With that help I was able to get it up and running for the timeSlice field but
    I don't see the difference to the dayOfAggregation field which is also just
    another embedded class using an object of a class annotated with
    @Embeddable.
    The get method of the dayOfAggregation field is as follows:
         * Get method for the member "<code>dayOfAggregation</code>".
         * @return Returns the dayOfAggregation.
        @Embedded
        @AttributeOverrides({@AttributeOverride(name = "calendar", /* Not possible to use interface constant here - field name must be used for reference */
                                                column = @Column(name = DayContext.COLUMN_NAME_DAY_OF_AGGREGATION,
                                                                 nullable = false)),
                             @AttributeOverride(name = "weekday",
                                                column = @Column(name = DayContext.COLUMN_NAME_WEEKDAY,
                                                                 nullable = false)),
        public Day getDayOfAggregation() {
            return this.dayOfAggregation;
        }The link to my question in the SAP forum for reference:
    https://www.sdn.sap.com/irj/sdn/thread?messageID=3651350
    Any help or ideas would be greatly appreciated.
    Thanks in advance.
    Henning Malzahn

    Hello Forum,
    got a response in the SAP forum - Issue is a bug in the SAP NetWeaver
    app. server.
    Henning Malzahn

  • Derby db named query causes parse error when using derby db MONTH function

    Hi all!
    I'm trying to create an application using the persistance api and beans binding. I have created my database and entity classes.
    My problem is creating a named query that uses some of the functionality from the derby database (which is embedded in the application).
    I have a named query:
    @NamedQuery(name = "Vehicles.findbymotmonth", query = "SELECT v FROM Vehicles v WHERE MONTH(v.lastmotdate) = :monthnumber") The actual query works fine when I send it directly to the db (with the parameter filled in) but causes an exception when used as a named query:
    Local Exception Stack:
    Exception [TOPLINK-8025] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.EJBQLException
    Exception Description: Syntax error parsing the query [Vehicles.findbymotmonth: SELECT v FROM Vehicles v WHERE MONTH(v.lastmotdate) = :monthnumber], line 1, column 32: unexpected token [MONTH].
    Internal Exception: line 1:32: unexpected token: MONTH
            at oracle.toplink.essentials.exceptions.EJBQLException.unexpectedToken(EJBQLException.java:389)
    ... I've tried looking for solutions online but it seems evryone just writes up the original java db application example provided by sun and no one has tried doing more than "select c from customers c".
    I'm using the netbeans ide (6.5).
    Please tell me there is a simple solution to this and the persistance API can handle complex queries!
    Thanks in advance.

    one solution: assume the toplink library to be so full of bugs as to be unusable and switch to the hibernate persistance manager where it works fine.
    Edited by: pointer2null on Feb 17, 2009 11:02 AM

  • Can't execute SQL Named query that uses connect by...

    I'm having problems using the connect by with ReportQuery.setHierarchicalQueryClause (detailed in earlier post) so I defined a named query to execute the following sql;
    select distinct(role_id)
    from role_principal
    connect by prior role_id = principal_id
    start with principal_id = #principalId
    When I run similar SQL in SqlPlus, i get results like this;
    ROLE_ID
    202
    500
    501
    502
    503
    But when I run the query using Toplink like this;
    Vector args = new Vector();
    args.add(principal.getId());
    roles = (Vector) session.executeQuery("orclGetRolesOfPrincipal", args);
    I get this exception;
    TopLink Warning]: 2005.10.05 10:58:14.362--ClientSession(18082301)--Thread(Thread[main,5,main])--Local Exception Stack:
    Exception [TOPLINK-6044] (Oracle TopLink - 10g Developer Preview 3 (10.1.3.0 ) (Build 041116)): oracle.toplink.exceptions.QueryException
    Exception Description: The primary key read from the row [DatabaseRecord(
         ROLE_PRINCIPAL.ROLE_ID => 202)] during the execution of the query was detected to be null. Primary keys must not contain null.
    Query: ReadAllQuery(oracle.xdo.server.security.authorization.model.RolePrincipalRelation)
         at oracle.toplink.exceptions.QueryException.nullPrimaryKeyInBuildingObject(QueryException.java:662)
         at oracle.toplink.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:349)
         at oracle.toplink.internal.descriptors.ObjectBuilder.buildObjectsInto(ObjectBuilder.java:633)
         at oracle.toplink.internal.queryframework.DatabaseQueryMechanism.buildObjectsFromRows(DatabaseQueryMechanism.java:141)
         at oracle.toplink.queryframework.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:440)
         at oracle.toplink.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:727)
         at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:559)
         at oracle.toplink.queryframework.ReadAllQuery.execute(ReadAllQuery.java:408)
         at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:1977)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:973)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:945)
         at oracle.xdo.server.dataservices.impl.toplink.TLDataAccessManagerImpl.getObjects(TLDataAccessManagerImpl.java:346)
    It seems to have a problem that there's not a parent record for role_id 202, which is a root level record and so should not have a parent.
    I appreciate any help that can be provided.
    Thanks,
    -Tim Watson

    Hello Tim,
    Not sure of the problem in the first post, but in this one, you are executing the query as a ReadAllQuery. The results only contain the role_id, but TopLink expecting atleast all the primary key fields inorder to build the objects to return them to you. Try executing this SQL in a report query instead, or set the results to return all the fields so TopLink can build the objects.
    Best Regards,
    Chris

  • Using sysdate in a ejb 3.0 named query

    Hello,
    Giving the following ejb 3 Named query:
    @NamedQuery(name = "DcaMessage.findNew", query = "select o from DcaMessage o where o.nbAvisEmis<1 or (o.indMsgConsulte=0 and sysdate-o.dtDernierAvis>:nbJours)")
    The result is:
    Exception [TOPLINK-8004] (Oracle TopLink Essentials - 2006.8 (Build 060829)): oracle.toplink.essentials.exceptions.EJBQLException
    Exception Description: A parsing problem was encountered resolving the alias - [sysdate].
    How do I use sysdate (or any other element) to compute the number of days between now and the date defined in dtDernierAvis?
    Thanks

    Hi,
    According to the EJB 3.0 specification, there are three date and time functions that can be used in EQL:
    functions_returning_datetime:=
    CURRENT_DATE |
    CURRENT_TIME |
    CURRENT_TIMESTAMP
    The datetime functions return the value of current date, time, and timestamp on the database server.
    I suppose your query should look like this
    @NamedQuery(name = "DcaMessage.findNew", query = "select o from DcaMessage o where o.nbAvisEmis<1 or (o.indMsgConsulte=0 and CURRENT_DATE-o.dtDernierAvis>:nbJours)")
    I never used these three functions myself, but it should be something like that.
    HTH, Wouter van Reeven

  • Named query with join tables

    I have two tables
    - Process_Master (EVENT_ID, EVENT_TYP, STATUS)
    - Rel_Event( EVENT_ID, USERID, EVENT_DATE, RMKS)
    They have one-to-one relationship linked by EVENT_ID.
    I would like to create a named query like below joining 2 tables together.
    Do I need to create any class descriptor first and how? I want this query to be available from the ADF data control so I can drag and drop this to my JSP page as a ADF table. I have no problem in working with single table. I have read thru the developer guide and try out many things like multitable info, aggregate mapping and couldn't figure out how this can be done. Please help!!!
    SELECT A.EVENT_ID,B.EVENT_DATE, A.STATUS, B.RMKS
    FROM PROCESS_MASTER A, REL_EVENT B
    WHERE A.EVENT_ID = B.EVENT_ID
    AND A.STATUS = 'P';
    ********/

    I have tried the below but fail to retrieve any rows. Please help!
    Expression aid = new ExpressionBuilder(ProcEventMaster.class).get("event_id");
    Expression bid = new ExpressionBuilder(RelEvent.class).get("event_id");
    ReportQuery reportQuery = new ReportQuery(ProcEventMaster.class,aid.equal(bid));
    reportQuery.addAttribute("a_id", aid);
    reportQuery.addAttribute("b_id", bid);
    reportQuery.addAttribute("eventDate",bid.get("event_date"));
    reportQuery.addAttribute("remarks",bid.get("rmks"));
    reportQuery.setSelectionCriteria(aid.get("status").equal("P"));
    List<RelEvent> results =
    (List<RelEvent>)session.executeQuery(reportQuery);session.release();
    return results;

  • Named query creates wrong cast: CAST (? AS VARCHAR(32672))

    Hello!
    I'am working with Toplink on DB2 - which works great, so far - but now I face the following problem:
    A named query produces the following sql-code:
    ... WHERE (SAMPLEFIELDNAME = CAST (? AS VARCHAR(32672) ))
    The problem ist the cast: the data-base-fieldtype is a VARCHAR(255) so get an SQL-Exception. I can't change the database-schema, because this is legacy-stuff. I tried a lot (columnDefinition and length in @Column-annotation seem to be ignored at all) - but nothing worked.
    Thank you!
    Siegfried

    Hi,
    The DB2 Platform hard coded the casting of Strings to VARCHAR(32672) in the oracle.toplink.platform.database.DB2Platform class' writeParameterMarker method. So if the type is set to a String class on the argument, it will always be cast to VARCHAR(32672). You will need to override the writeParameterMarker method on a custom platform (extending DB2Platform) in such a way that if a string is given, VARCHAR(255) is used instead. That is, assuming all your strings are of size 255.
    Best Regards,
    Chris

  • Named query cache not hit

    Hi,
    I'm using Toplink ORM 10.1.3.
    I have a table called STORE_CONFIG which has a primary key called KEYWORD (a VARCHAR2). The POJO mapped to this table is called StoreConfig.
    In the JDeveloper (10.1.3.1.0) mapping workbench I've defined a named query to query by the PK called "getConfigPropertyByKeyword". The type of the named query is ReadObjectQuery.
    SELECT keyword, key_value
    FROM STORE_CONFIG
    WHERE (keyword = #key)
    Under the options tab I have the following settings:
    Cache Statement: true
    Bind Parameters: true
    Cache Usage: Check Cache by Primary Key
    The application logs show that the same database queries are executed multiple times for the same PK (keyword)! Why is that? Shouldn't it be checking the Object Cache rather than going to the DB?
    I've tried it with "Cache Statement: false" and "Bind Parameters: false" with the same problem.
    If I click the Advanced tab and check "Cache Query Results" then the database is not hit twice for the same record. However it was my understanding that since I am querying by PK that I wouldn't need to set "Cache Query Results".
    Doesn't "Cache Query Results" apply to the Query Cache and not the Object Cache?

    Your issue seems to be that you are using custom SQL for the query, not a TopLink expression. When you use an Expression query TopLink's know if the query is by primary key and can get a cache hit.
    When you use custom SQL, TopLink does not know that the SQL is by primary key, so does not get a cache hit.
    You could either use an Expression for the query,
    or when using custom SQL you should be able to name your query argument the same as your database field defined as the primary key in your descriptor (case sensitive).
    i.e.
    SELECT keyword, key_value
    FROM STORE_CONFIG
    WHERE (keyword = #KEYWORD)

  • Named query, primary keys must not contain null

    We have an question on the named query. Here is the scenario:
    Class JoinClassC (id, name, desc, comment) is mapped to two tables Join_Table_A (id, name, description) and Join_Table_B (id, name, comments); Join_Table_A is the primary table; two tables are associated via primary key.
    Defined a named query (findByName, ReadAllQuery/SQL) for JoinClassC descriptor. The sql is:
    SELECT a.ID,a.NAME,a.DESCRIPTION,b.COMMENTS FROM JOIN_TABLE_A a, JOIN_TABLE_B b WHERE a.NAME=#name AND a.ID=b.ID AND a.NAME=b.NAME
    Getting QueryException while executing the query. Here is the trace:
    [3/2/05 13:50:24:795 EST] f8b62aa SystemOut O 2005.03.02 01:50:24.795--ServerSession(738697921)--Thread[Servlet.Engine.Transports : 4,5,main]--Connection(1095574161)--SELECT a.ID,a.NAME,a.DESCRIPTION,b.COMMENTS FROM JOIN_TABLE_A a, JOIN_TABLE_B b WHERE a.NAME='persistence' AND a.ID=b.ID AND a.NAME=b.NAME
    2005.03.02 01:50:24.835--ClientSession(1127670417)--Thread[Servlet.Engine.Transports : 4,5,main]--Exception [TOPLINK-6044] (OracleAS TopLink - 10g (9.0.4.4) (Build 040627)): oracle.toplink.exceptions.QueryException
    Exception Description: The primary key read from the row [DatabaseRow(
         USER04.JOIN_TABLE_B.ID =&gt; 2
         USER04.JOIN_TABLE_A.NAME =&gt; persistence
         USER04.JOIN_TABLE_A.DESCRIPTION =&gt; FJF Persistence Fram
         USER04.JOIN_TABLE_B.COMMENTS =&gt; The Persistence Fram)] during the execution of the query was detected to be null. Primary keys must not contain null.
    Query: ReadAllQuery(com.ford.it.persistence.unittest.dom.JoinClassC)Local Exception Stack:
    Exception [TOPLINK-6044] (OracleAS TopLink - 10g (9.0.4.4) (Build 040627)): oracle.toplink.exceptions.QueryException
    Exception Description: The primary key read from the row [DatabaseRow(
         USER04.JOIN_TABLE_B.ID =&gt; 2
         USER04.JOIN_TABLE_A.NAME =&gt; persistence
         USER04.JOIN_TABLE_A.DESCRIPTION =&gt; FJF Persistence Fram
         USER04.JOIN_TABLE_B.COMMENTS =&gt; The Persistence Fram)] during the execution of the query was detected to be null. Primary keys must not contain null.
    Query: ReadAllQuery(com.ford.it.persistence.unittest.dom.JoinClassC)
         at oracle.toplink.exceptions.QueryException.nullPrimaryKeyInBuildingObject(QueryException.java:542)
    Adding b.ID to the sql select will solve the problem.
    Question: does the primary key must be present in the sql select to run this kind of query? Any way to work around the restriction?
    Your help would be greatly appreciated.
    Haiwei

    The problem is that you need to select both primary keys for the multiple table descriptor.
    i.e.
    SELECT a.ID,a.NAME,a.DESCRIPTION,b.ID, b.COMMENTS FROM JOIN_TABLE_A a, JOIN_TABLE_B b WHERE a.NAME=#name AND a.ID=b.ID AND a.NAME=b.NAME
    Your SQL needs to return the same data that TopLink would have selected, which includes the primary key for both tables. TopLink expects both a.ID and b.ID fields in the select, because your only select one and the field names are the same TopLink thought the ID field was for b.ID not a.ID, if you select both it will be ok.

  • Named query question

    Hi Guys,
    I have the following problem - I know I did something wrong, but I cannot figure out how to correct it. Here is my question:
    I have a table tableA, with composite key (col1, col2, col3, col4). I mapped the table, and create a Toplink named query (findCol3List)as such:
    select distinct col3
    from tableA
    where col1=#col1 and col2=#col2
    I created an EJB session method getCol3List(col1, col2) -
    now when I run the application to call this EJB method, I got the following error at line:
    List results = (List)session.executeQuery("findCol3List", String.class, params);
    Exception Description: Missing descriptor for [java.lang.String] for query named [findCol3List].
    I know there are multiple mistakes in my approach, but with my limited Toklink knowledge, I could not figure out.
    Any help with be appreciated!

    hello,
    The executeQuery method is trying to look up the "findCol3List" in the descriptor for the class passed in. It is complaining because you passed in String.class which does not have a valid descriptor.
    How/where did you define the named query? Chances are you defined it in the class used for TableA, and so should specify it in the executeQuery method:
    session.executeQuery("findCol3List", tableA.class, params);
    Best Regards,
    Chris

  • Named Query Error

    Hi,
    I'm having trouble passing argument to a named query in the mapping workbench.
    Here is my SQL:
    SELECT COUNT(*) FROM VALID_PARTY_CLASSIF, CLASSIF_TYPE WHERE CLASSIF_TYPE.CLASSIF_TYPE_ID = VALID_PARTY_CLASSIF.CLASSIF_TYPE_ID AND CLASSIF_TYPE.CLASSIF_TYPE_ID = #ID
    and when I find and execute the query, getting following error
    Execute query ReadObjectQuery(com.amgen.bria.business.bizobject.ClassificationTypeBO)
    SELECT COUNT(*) FROM VALID_PARTY_CLASSIF, CLASSIF_TYPE WHERE CLASSIF_TYPE.CLASSIF_TYPE_ID = VALID_PARTY_CLASSIF.CLASSIF_TYPE_ID AND CLASSIF_TYPE.CLASSIF_TYPE_ID = ?
         bind => [56]
    Exception [TOPLINK-6044] (OracleAS TopLink - 10g (9.0.4) (Build 031018)): oracle.toplink.exceptions.QueryException
    Exception Description: The primary key read from the row [DatabaseRow(
         => 0)] during the execution of the query was detected to be null. Primary keys must not contain null.
    Query: ReadObjectQuery(com.amgen.bria.business.bizobject.ClassificationTypeBO)Local Exception Stack:
    Exception [TOPLINK-6044] (OracleAS TopLink - 10g (9.0.4) (Build 031018)): oracle.toplink.exceptions.QueryException
    Exception Description: The primary key read from the row [DatabaseRow(
         => 0)] during the execution of the query was detected to be null. Primary keys must not contain null.
    Query: ReadObjectQuery(com.amgen.bria.business.bizobject.ClassificationTypeBO)
         at oracle.toplink.exceptions.QueryException.nullPrimaryKeyInBuildingObject(QueryException.java:541)
         at oracle.toplink.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:262)
         at oracle.toplink.queryframework.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:226)
         at oracle.toplink.queryframework.ReadObjectQuery.execute(ReadObjectQuery.java:344)
         at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:498)
         at oracle.toplink.queryframework.ReadQuery.execute(ReadQuery.java:111)
         at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:1968)
         at oracle.toplink.threetier.ServerSession.internalExecuteQuery(ServerSession.java:629)
         at oracle.toplink.threetier.ClientSession.internalExecuteQuery(ClientSession.java:392)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1096)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1065)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:966)
         at com.amgen.bria.persistence.module.toplink.TopLinkPersistenceService.internalExecuteQuery(TopLinkPersistenceService.java:137)
         at com.amgen.bria.persistence.PersistenceService.executeQuery(PersistenceService.java:97)
         at com.amgen.cma.persistence.service.ClassificationPersistenceService.findCustomerForClassifTypeCount(ClassificationPersistenceService.java:405)
         at com.amgen.cma.persistence.service.ClassificationPersistenceServiceTest.testFindCustomerForClassifTypeCount(ClassificationPersistenceServiceTest.java:193)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at junit.framework.TestCase.runTest(TestCase.java:154)
         at junit.framework.TestCase.runBare(TestCase.java:127)
         at junit.framework.TestResult$1.protect(TestResult.java:106)
         at junit.framework.TestResult.runProtected(TestResult.java:124)
         at junit.framework.TestResult.run(TestResult.java:109)
         at junit.framework.TestCase.run(TestCase.java:118)
         at junit.framework.TestSuite.runTest(TestSuite.java:208)
         at junit.framework.TestSuite.run(TestSuite.java:203)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
    client released
    Please let me know if I am missing anything.
    Thanks
    Saket

    Saket, the problem is right here:
    ReadObjectQuery(com.amgen.bria.business.bizobject.Clas
    ificationTypeBO)
    When you read a an object mapping back, the primary key you have specified for that object mapping in Toplink has to be part of this search criteria (it is how it's stored in toplink's identity map/cache)
    Since you are only executing a 'select count(*)', it is erroring out
    HTH,
    Sean

  • Named query, nested

    If I defined a named query like the following select * from (
         select q.*, rownum r from user04.quote q
         where version = 1
         order by id     
    where r between #startIndex and #endIndex I can achieve the 'paging' function by specifying the starting row and ending row for the query at runtime.
    However, if I modify the query by supplying an argument in the inner select, like this select * from (
         select q.*, rownum r from user04.quote q
         where version =#id
         order by id     
    where r between #startIndex and #endIndex my code will fail with NullPointerException in SQLCall. Here is the trace: [5/28/05 19:48:40:816 EDT] 468db180 SystemOut     O 2005.05.28 07:48:40.816--ClientSession(1108210094)--Thread[Servlet.Engine.Transports : 2,5,main]--java.lang.NullPointerExceptionjava.lang.NullPointerException
         at oracle.toplink.queryframework.SQLCall.translate(SQLCall.java:266)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(CallQueryMechanism.java:133)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(CallQueryMechanism.java:115)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelectCall(CallQueryMechanism.java:197)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.selectAllRows(CallQueryMechanism.java:567)
         at oracle.toplink.queryframework.ReadAllQuery.execute(ReadAllQuery.java:447)Is this an expected behavior of named query or a bug in named query? Thanks.
    Haiwei

    Solved the problem by
    1) adding an space (i.e. blank) after #id
    and 2) removing the blank line at the end of the SQL query.
    It seems that there is a bug in the TopLink code parsing the SQL. My best advice is to not use new line, tab. Use hard space as de-limiter instead. The debugging is very time-consuming.
    Please feel free to comment on my findings.
    Haiwei

  • Named Query Expression in Toplink workbench

    Hi! All,
    I have a problem which I am not sure how to solve and would appreciate any help on this.
    I have Tables
    Company, Employee, EmployeeTaxType , TaxTypeVal
    Each is mapped to a java class with the same name
    I would like to find all Employee Objects for a company where (taxTypeVal.year=2005 and taxType.quarter=2)
    I cant seem to be able to build a Named Query expression which would produce the same result.
    It always returns All employees who belong to a company and have liabilities in either year =2005 OR quarter=2
    The expression that I wrote was
    AND
    1.companyBO.companyID EQUAL COMPANY_ID
    2.AND
    2.1.employeeTaxTypeBOs.taxTypeValBOs.quarter EQUAL QUARTER
    2.2.employeeTaxTypeBOs.taxTypeValBOs.year EQUAL YEAR

    Please post the SQL that is generated from TopLink, and the xml where you define the NamedQuery. What version of the MappingWorkbench and TopLink runtime are you using?
    Deepak

Maybe you are looking for

  • T500 Freezes Often

    I have a T500 (model 2081-CTO) which freezes at random (and inopportune) times, several times per week. I had this problem since I first got the computer and the people at lenovo tech support keep suggesting the problem will be solved by reloading wi

  • Is there a function that will retrieve working directory?

    I'm writing an application that conjugates Spanish and I'm putting all irregulars into different databases according to their tense. The databases will list the information on what kind of irregular it is as well as other things. In the end there wil

  • Itunes 9.2 not working please help

    i am trying to upgrade my itunes so that i can updated my software for my iphone but everytime i try to download itunes 9.2 a sign pops up that says Windows has found a problem with this file. And the publisher is unknown. At the bottom it reads: The

  • New PC: cant install vista

    Hi, I get my new PC last week and build it up. Everything seemed fine but when I tried to install Windows vista a problem came up. Installing doesn't even begin. I only get black screen when it should start windows installing. I have normally changed

  • Why can i not open some dvd's

    I can not run all DVD's. Why do some open right away and some pop back out. I am only using store bought DVD's.