TopLink - Get sql code of a Named Query.

Hi everyone!
I'm wrinting to yours because I want to insert into a register of a table of my database the sql code generated of a named query. I mean, I have a named query with sql code, and I want to get that sql with the parameters that I used to execute that query.
What would I do to get that information..??..
I'll be wainting your responses.
Thanks!
Greetings, Lucho!

You might want to ask this on the TopLink Forum.
TopLink has levels of logging that will provide you with the queries executed.
That said, if you want to log each operation on a table at the database level, then maybe looking into the database audit features would make more sense.

Similar Messages

  • How to get sql server performance counters using query?

    Hai i want to see my sql server performance counters like, Full Scans/sec,  Buffer
    Cache Hit Ratio,  Database Transactions/sec, User
    Connections, Average Latch Wait Time (ms), Lock
    Waits/sec, Lock Timeouts/sec, Number
    of Deadlocks/sec, Total Server Memory, SQL
    Re-Compilations/sec, User Settable Query. If any one know how to get it by using query means, please help me.
    Thanks in advance

    Hello,
    Below is query created by Jonathan Kehayias for measuring Perfom counters using DMV sys.dm_os_performance_counter.
    You can download book from below link
    https://www.simple-talk.com/books/sql-books/troubleshooting-sql-server-a-guide-for-the-accidental-dba/
    DECLARE @CounterPrefix NVARCHAR(30)
    SET @CounterPrefix = CASE WHEN @@SERVICENAME = 'MSSQLSERVER'
    THEN 'SQLServer:'
    ELSE 'MSSQL$' + @@SERVICENAME + ':'
    END ;
    -- Capture the first counter set
    SELECT CAST(1 AS INT) AS collection_instance ,
    [OBJECT_NAME] ,
    counter_name ,
    instance_name ,
    cntr_value ,
    cntr_type ,
    CURRENT_TIMESTAMP AS collection_time
    INTO #perf_counters_init
    FROM sys.dm_os_performance_counters
    WHERE ( OBJECT_NAME = @CounterPrefix + 'Access Methods'
    AND counter_name = 'Full Scans/sec'
    OR ( OBJECT_NAME = @CounterPrefix + 'Access Methods'
    AND counter_name = 'Index Searches/sec'
    OR ( OBJECT_NAME = @CounterPrefix + 'Buffer Manager'
    AND counter_name = 'Lazy Writes/sec'
    OR ( OBJECT_NAME = @CounterPrefix + 'Buffer Manager'
    AND counter_name = 'Page life expectancy'
    OR ( OBJECT_NAME = @CounterPrefix + 'General Statistics'
    AND counter_name = 'Processes Blocked'
    OR ( OBJECT_NAME = @CounterPrefix + 'General Statistics'
    AND counter_name = 'User Connections'
    OR ( OBJECT_NAME = @CounterPrefix + 'Locks'
    AND counter_name = 'Lock Waits/sec'
    OR ( OBJECT_NAME = @CounterPrefix + 'Locks'
    AND counter_name = 'Lock Wait Time (ms)'
    OR ( OBJECT_NAME = @CounterPrefix + 'SQL Statistics'
    AND counter_name = 'SQL Re-Compilations/sec'
    OR ( OBJECT_NAME = @CounterPrefix + 'Memory Manager'
    AND counter_name = 'Memory Grants Pending'
    OR ( OBJECT_NAME = @CounterPrefix + 'SQL Statistics'
    AND counter_name = 'Batch Requests/sec'
    OR ( OBJECT_NAME = @CounterPrefix + 'SQL Statistics'
    AND counter_name = 'SQL Compilations/sec'
    -- Wait on Second between data collection
    WAITFOR DELAY '00:00:01'
    -- Capture the second counter set
    SELECT CAST(2 AS INT) AS collection_instance ,
    OBJECT_NAME ,
    counter_name ,
    instance_name ,
    cntr_value ,
    cntr_type ,
    CURRENT_TIMESTAMP AS collection_time
    INTO #perf_counters_second
    FROM sys.dm_os_performance_counters
    WHERE ( OBJECT_NAME = @CounterPrefix + 'Access Methods'
    AND counter_name = 'Full Scans/sec'
    OR ( OBJECT_NAME = @CounterPrefix + 'Access Methods'
    AND counter_name = 'Index Searches/sec'
    OR ( OBJECT_NAME = @CounterPrefix + 'Buffer Manager'
    AND counter_name = 'Lazy Writes/sec'
    OR ( OBJECT_NAME = @CounterPrefix + 'Buffer Manager'
    AND counter_name = 'Page life expectancy'
    OR ( OBJECT_NAME = @CounterPrefix + 'General Statistics'
    AND counter_name = 'Processes Blocked'
    OR ( OBJECT_NAME = @CounterPrefix + 'General Statistics'
    AND counter_name = 'User Connections'
    OR ( OBJECT_NAME = @CounterPrefix + 'Locks'
    AND counter_name = 'Lock Waits/sec'
    OR ( OBJECT_NAME = @CounterPrefix + 'Locks'
    AND counter_name = 'Lock Wait Time (ms)'
    OR ( OBJECT_NAME = @CounterPrefix + 'SQL Statistics'
    AND counter_name = 'SQL Re-Compilations/sec'
    OR ( OBJECT_NAME = @CounterPrefix + 'Memory Manager'
    AND counter_name = 'Memory Grants Pending'
    OR ( OBJECT_NAME = @CounterPrefix + 'SQL Statistics'
    AND counter_name = 'Batch Requests/sec'
    OR ( OBJECT_NAME = @CounterPrefix + 'SQL Statistics'
    AND counter_name = 'SQL Compilations/sec'
    -- Calculate the cumulative counter values
    SELECT i.OBJECT_NAME ,
    i.counter_name ,
    i.instance_name ,
    CASE WHEN i.cntr_type = 272696576
    THEN s.cntr_value - i.cntr_value
    WHEN i.cntr_type = 65792 THEN s.cntr_value
    END AS cntr_value
    FROM #perf_counters_init AS i
    JOIN #perf_counters_second AS s
    ON i.collection_instance + 1 = s.collection_instance
    AND i.OBJECT_NAME = s.OBJECT_NAME
    AND i.counter_name = s.counter_name
    AND i.instance_name = s.instance_name
    ORDER BY OBJECT_NAME
    -- Cleanup tables
    DROP TABLE #perf_counters_init
    DROP TABLE #perf_counters_second
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • Error when use stored procedure in Named Query and Custom SQL

    This is a toplink development on Jdev 1013. A package with a function is created which returns a "ref cursor" in a oracle 9i database. I tried to access the function in jdev toplink descriptor editor either through custom sql (Readall) or a named query (procedureTest) and I got java.sql.SQLException: SQL string is not Query. Note: I am NOT talking about programatic storedprocedurecall object.
    The client access code is following (where error was thrown):
    results = (Collection) session.executeQuery("procedureTest", WuTest.class);

    Any responses? Thanks.

  • Named query

    hi all,
    i am newbie in toplink.
    i want to define a named query in toplink mapping workbench (for example test).
    how can i call this named query and execute it.
    need help

    The query would depend on what your object model is, and what you are querying for. To use arguments with named-queries use the expressionBuilder.getParameter(/) method.
    Example:
    ReadAllQuery query = new ReadAllQuery();
    ExpressionBuilder niveau = new ExpressionBuilder();
    query.setSelectionCriteria(
    niveau.get("rubrique").get("morasse").get("entite").
    equal(niveau.getParameter("entite"));
    query.addArgument("entite");
    descriptor.getQueryManager().addQuery("findByEntite", query);
    List result = (List) session.executeQuery(Niveau.class, "entite-value");

  • Questions on Named Query

    We have a few questions about named query.
    According to the Toplink documentation, we can register the named query in 2 places.
    1. Register the name query in the “query manager” in a Session level - The documentation said that these are for “GLOBAL” queries.
    2. Register the name query in the “query manager” in a Descriptor level. These “Descriptor level” query can be defined via the Toplink workbench or defind via Java code and load in the Descriptor via a post-project load amendment method. The documentation also mentioned that once the project is login, we cannot add named query to the descriptor.
    We have a few questions.
    All querys are related to a class, so what do we mean by “GLOBAL” queries ? What is this “GLOBAL” means.
    Is there any restriction in adding query to a session. Can we add query to a session after the session is login ?
    What we like to achieve is something like this.
    Ask the session for a query “findElectionByEmployee”, if nothing returns, construct the query, add this named query to the session.
    Can we ask a clientSession for a query using getQuery(string)?
    Or we can only ask a serverSession for a query ?
    How about adding query to a session, can a clientSession add a query back to the parent ServerSession, or we need to add the query directly to a serverSession ?
    We have hundreds of queries, not all of them used all the time, so adding the query to the session “on demand, or Just in Time addition”, will be most memory saving rather than starting the system with hundreds of query.
    Another issue we have about using descriptor based query, specially those that is define via the toplink workbench, is that it create sort of an administrative single point of entry. For a system that have a lot of query, to single file the creation of the query to a single person, or a few people, can be administratively difficult, even though we appreciate the “central and single point of control aspect of it.
    So what is your observation in the use of named queries with your other clients ?
    Is that a popular feature that your customer use ? Do they like to define the query in Workbench, can this solution “administratively scale” ?
    Do you see “just in time” add of query to a session, if that is all possible.
    Currently we have a simple query mechanism, each DAO method eg findElectionByEmployee, will contruct the query, with the expression builder, expressions etc and after one execution, throw that away and redo the same thing again in the next method invocation.
    We want to avoid that but we do not want to centralized the definition to a central “Toplink Mapping” person. For a fairlt big system like ours, that have 20-30 DAO with hundreds of “finder” methods, it is too difficult to centralized.
    What is your thoughts on this and if there is any white paper of best practice that you can point us to, we be most appreciated.

    In answer to your technical questions, the only difference between descriptor level named queries and session level named queries is where the query is stored. Queries stored at the session level must have unique signatures, queries stored in the descriptor require unique signatures from other queries on the same descriptor but not queries on other descriptors or sessions.
    Queries at the session level can be on any class, queries at the descriptor level must on that descriptor's class.
    A ServerSession's query can be found from a ClientSession but queries added to a ClientSession will only be available to that ClientSession and will dispose when the ClientSession is released.
    As to the questions about manageability it really is up to you to evaluate. If it is important to your organization that queries are moderated centrally then controlling them at the project level would provide for that. If that is not an important requirement then moving to a dynamic model would be less overhead, and headaches of having numerous people working on the source to and redeploying the same application repeatedly. But in general a combination of the two approaches, based on how often a particular query is used, would probably be best.
    --Gordon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Some question about sql code

    for example:
    select
    from testtable
    outputs below results:
    item_desc
    950gapple(z)110ml*40
    650gbanana(z)215ml 1x18
    make above example outputs below result:
    item_desc
    a950gapplez110ml40
    a650gbananaz215ml1x18
    how to write above sql code?
    who can help me?
    thanks

    Jameel Provided solution to one of your other thread
    a question about sql code
    Try the below query. You can modify the TRANSLATE function to add the characters you want to remove from the string.
    select 'a'||replace(translate(str,'()* ','`'),'`') from testtable

  • SetMaxRows on a Named query

    Hi
    Does anyone know the best way to limit the number of rows in the result set at runtime for a named query?
    There is a setMaxRows method for ReadAllQuery objects, but not for DatabaseQuery objects, and this is what I am getting from looking up the named query via the descriptor.
    DatabaseQuery query = getReadSession().getDescriptor(Service.class).getQueryManager().getQuery("ServicesByLeaseTimeAndStatus", parameters);
    I tried this
    query.getCall().setMaxRows(maxServices);
    but getCall returns null.
    Many thanks if you can help - this must be a FAQ!
    James

    Thanks Tom
    Thank looks fine. By the way, is there a non-deprecated approach to getting hold of a named query in 10.1.3 dp3? The method I am using seems to work but comes up with a deprecation warning:
    DatabaseQuery query = getReadSession().getDescriptor(Service.class).getQueryManager().getQuery("ServicesByLeaseTimeAndStatus", parameters);
    James

  • SQL Code Output

    Hello All,
    Does anyone know if it possible to get SQL code ouput for the rules resulting from clustering?
    Thanks,
    Alan

    I'm still not sure that I understand what you are doing...
    You're using SQL Developer. Are you using Oracle Data Mining? Unfortunately, Oracle the corporation and Oracle the database use the term "cluster" in a lot of different places so it has a lot of potential meanings. It sounds like you're trying to run a clustering algorithm using Oracle Data Miner on a sample data set.
    If that's the case, you probably want to post this over in the Data Mining
    Justin

  • How to use : bind character in DB adapter Select Query SOA11g. Getting Error code :17003 .java.sql.SQLException: Invalid column index error

    Hi All,
    The Actual query to perform is below.
    SELECT name,number from emp  WHERE CASE WHEN :1='T' AND term_date IS Not NULL THEN 1 WHEN :1='A' AND term_date IS NULL THEN 1 WHEN :1='ALL' THEN 1 ELSE  1 END = 1;
    I have tried in DB adapter like below as a parameter for :1 as #vInputParam
    SELECT name,number from emp  WHERE CASE WHEN #vInputParam='T' AND term_date IS Not NULL THEN 1 WHEN #vInputParam='A' AND term_date IS NULL THEN 1 WHEN #vInputParam='ALL' THEN 1 ELSE  1 END = 1;
    Getting Error code :17003 .java.sql.SQLException: Invalid column index error.
    Please suggest me on using ':' bind character in DB adapter Select Query SOA11g.
    Can someone help me on this please?
    Thanks,
    Hari

    Hi,
    Could you please make sure your binding style(Oracle Positional,Oracle named..etc) of the Seeded VO and Custom Vo are same.
    This is the option you will get when you are extending your vo. So make sure that both are same.
    You can refer the below link too
    VO extension leads to "Invalid column index" exception
    Thanks
    Bharat

  • Query SQL code gets deleted after export to Excel. "Query must have at least one destination field"

    Hi all,
    I'm getting really frustrated by this Access error. It happens when I export the result of a query through an Access macro to Excel, the first time it runs well but the next time, there is a chance that the query won't run and the error "Query
    must have at least one destination field" will be displayed. After that, I try to check the query SQL code and discover the code has vanished. I'm using simple Select query without joins, only "where", "group by" and "order by"
    statements.
    Thank you in advance for your help,
    Jesus 
    Edit:
    One of these queries are like the following (all of them are of this type):
    SELECT Field1, field2, field3, field4, field5, Sum(Field6) AS SumOfField6, Sum(Field7) AS SumOfField7
    FROM Table1
    WHERE Field6 is not null
    GROUP BY Field1, field2, field3, field4, field5
    Order By Sum(Field6) desc

    Hi Peter, 
    Thank you for your response, I updated the original question with one of the codes.
    Thanks,
    Jesus

  • TOPLINK-4002 SQL string is not Query Error Code: 17128

    I got following exception when trying to execute native SQL query via session EJB. The query is defined in orm.xml file using JDev 11g Preview:
    javax.ejb.EJBException: Exception [TOPLINK-4002] (Oracle TopLink - 11g Release 1 (11.1.1.0.0) (Build 070502)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: SQL string is not QueryError Code: 17128
    Call:findProfilesByLastName
    I have following native query defined:
    select o.last_name,
    o.first_name,
    o.middle_name,
    o.birth_date,
    o.sex_code,
    a.height_cm,
    a.weight_kg,
    o.PERSON_ID
    from persons o,
    person_bookings b,
    person_physical_attributes a
    where o.PERSON_ID = b.PERSON_ID
    and b.PERSON_BOOK_ID = a.PERSON_BOOK_ID
    and o.last_name like '%?1%'
    I also tried these versions of the same query but got the same exception:
    select o.last_name,
    o.first_name,
    o.middle_name,
    o.birth_date,
    o.sex_code,
    a.height_cm,
    a.weight_kg,
    o.PERSON_ID
    from persons o,
    person_bookings b,
    person_physical_attributes a
    where o.PERSON_ID = b.PERSON_ID
    and b.PERSON_BOOK_ID = a.PERSON_BOOK_ID
    and o.last_name like '%:1%'
    select o.last_name,
    o.first_name,
    o.middle_name,
    o.birth_date,
    o.sex_code,
    a.height_cm,
    a.weight_kg,
    o.PERSON_ID
    from persons o,
    person_bookings b,
    person_physical_attributes a
    where o.PERSON_ID = b.PERSON_ID
    and b.PERSON_BOOK_ID = a.PERSON_BOOK_ID
    and o.last_name like '%#partialName%'
    select o.last_name,
    o.first_name,
    o.middle_name,
    o.birth_date,
    o.sex_code,
    a.height_cm,
    a.weight_kg,
    o.PERSON_ID
    from persons o,
    person_bookings b,
    person_physical_attributes a
    where o.PERSON_ID = b.PERSON_ID
    and b.PERSON_BOOK_ID = a.PERSON_BOOK_ID
    and o.last_name like '%#partialName#%'
    Log trace:
    Query:DataReadQuery(); nested exception is:
    Exception [TOPLINK-4002] (Oracle TopLink - 11g Release 1 (11.1.1.0.0) (Build 070502)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: SQL string is not QueryError Code: 17128
    Call:findProfilesByLastName
    Query:DataReadQuery(); nested exception is: oracle.oc4j.rmi.OracleRemoteException: Exception [TOPLINK-4002] (Oracle TopLink - 11g Release 1 (11.1.1.0.0) (Build 070502)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: SQL string is not QueryError Code: 17128
    Call:findProfilesByLastName
    Query:DataReadQuery(); nested exception is:
    Exception [TOPLINK-4002] (Oracle TopLink - 11g Release 1 (11.1.1.0.0) (Build 070502)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: SQL string is not QueryError Code: 17128
    oracle.oc4j.rmi.OracleRemoteException: Exception [TOPLINK-4002] (Oracle TopLink - 11g Release 1 (11.1.1.0.0) (Build 070502)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: SQL string is not QueryError Code: 17128
    Call:findProfilesByLastName
    Query:DataReadQuery()
    at com.evermind.server.ejb.EJBUtils.getUserException(EJBUtils.java:127)
    at com.evermind.server.ejb.interceptor.system.AbstractTxInterceptor.convertAndHandleMethodException(AbstractTxInterceptor.java:91)
    at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:52)
    at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
    at com.evermind.server.ejb.interceptor.system.JAASInterceptor$1.run(JAASInterceptor.java:52)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
    at oracle.oc4j.security.SecurityServices.doAsPrivileged(SecurityServices.java:150)
    at oracle.oc4j.security.SecurityServices.doAsPrivileged(SecurityServices.java:420)
    at oracle.oc4j.security.JaasModeImpl$DoAsPrivilegedExecutor.execute(JaasModeImpl.java:280)
    at com.evermind.server.ejb.interceptor.system.JAASInterceptor.invoke(JAASInterceptor.java:57)
    at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
    at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
    at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
    at com.evermind.server.ejb.InvocationContextPool.invoke(InvocationContextPool.java:58)
    at com.evermind.server.ejb.StatelessSessionEJBObject.OC4J_invokeMethod(StatelessSessionEJBObject.java:104)
    at SearchFacade_RemoteProxy_43jlpm9.queryProfilesByLastName(Unknown Source)
    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:585)
    at com.evermind.server.rmi.RmiMethodCall.invokeMethod(RmiMethodCall.java:104)
    at com.evermind.server.rmi.RmiMethodCall.run(RmiMethodCall.java:59)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
    at java.lang.Thread.run(Thread.java:595)
    Nested exception is:
    Local Exception Stack:
    Exception [TOPLINK-4002] (Oracle TopLink - 11g Release 1 (11.1.1.0.0) (Build 070502)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: SQL string is not QueryError Code: 17128
    at oracle.toplink.exceptions.DatabaseException.sqlException(DatabaseException.java:283)
    at oracle.toplink.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:583)
    at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:443)
    at oracle.toplink.internal.sessions.AbstractSession.executeCall(AbstractSession.java:749)
    at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193)
    at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:179)
    at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:250)
    at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeSelect(DatasourceCallQueryMechanism.java:232)
    at oracle.toplink.queryframework.DataReadQuery.executeNonCursor(DataReadQuery.java:122)
    at oracle.toplink.queryframework.DataReadQuery.executeDatabaseQuery(DataReadQuery.java:114)
    at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:671)
    at oracle.toplink.queryframework.DataReadQuery.execute(DataReadQuery.java:100)
    at oracle.toplink.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:594)
    at oracle.toplink.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2632)
    at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1014)
    at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:986)
    at oracle.toplink.internal.ejb.cmp3.base.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:395)
    at oracle.toplink.internal.ejb.cmp3.base.EJBQueryImpl.getResultList(EJBQueryImpl.java:502)
    at ejbmodel.SearchFacadeBean.queryProfilesByLastName(SearchFacadeBean.java:107)
    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:585)
    at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:27)
    at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
    at com.evermind.server.ejb.interceptor.system.SetContextActionInterceptor.invoke(SetContextActionInterceptor.java:44)
    at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
    at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
    at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
    at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:50)
    at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
    at com.evermind.server.ejb.interceptor.system.JAASInterceptor$1.run(JAASInterceptor.java:52)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
    at oracle.oc4j.security.SecurityServices.doAsPrivileged(SecurityServices.java:150)
    at oracle.oc4j.security.SecurityServices.doAsPrivileged(SecurityServices.java:420)
    at oracle.oc4j.security.JaasModeImpl$DoAsPrivilegedExecutor.execute(JaasModeImpl.java:280)
    at com.evermind.server.ejb.interceptor.system.JAASInterceptor.invoke(JAASInterceptor.java:57)
    at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
    at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
    at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101)
    at com.evermind.server.ejb.InvocationContextPool.invoke(InvocationContextPool.java:58)
    at com.evermind.server.ejb.StatelessSessionEJBObject.OC4J_invokeMethod(StatelessSessionEJBObject.java:104)
    at SearchFacade_RemoteProxy_43jlpm9.queryProfilesByLastName(Unknown Source)
    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:585)
    at com.evermind.server.rmi.RmiMethodCall.invokeMethod(RmiMethodCall.java:104)
    at com.evermind.server.rmi.RmiMethodCall.run(RmiMethodCall.java:59)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
    at java.lang.Thread.run(Thread.java:595)
    Caused by: java.sql.SQLException: SQL string is not Query
    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:72)
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:105)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:168)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:224)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:439)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1302)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3522)
    at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3574)
    at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:267)
    at oracle_jdbc_driver_OraclePreparedStatementWrapper_Proxy.executeQuery(Unknown Source)
    at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:754)
    at oracle.toplink.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:518)
    ... 51 more

    Does this error only occur when the SQL is defined in orm.xml ? Have attempted to run this query in code only?
    --Gordon                                                                                                                                                                                                                                                   

  • Clone of TopLink named query

    One of our projects here has a requirement where they'd like to modify, at runtime, the named query defined in the Mapping Workbench.
    One example is to set the refresh depth level (cascadePrivateParts, cascadeAll, for example) for the named query so that the defined query could be used in different scenarios with slightly different query options to get different query results.
    To support this, we will need to clone the query. See the sample code below:
    ObjectLevelReadQuery toplinkQuery = null;
    ObjectLevelReadQuery queryClone = null;
    Descriptor descriptor = session.getDescriptor(targetClass);
    DescriptorQueryManager queryManager = descriptor.getQueryManager();
    toplinkQuery = (ObjectLevelReadQuery)queryManager.getQuery(queryName);
    queryClone = (ObjectLevelReadQuery)toplinkQuery.clone();
    We try to use the clone method in DatabaseQuery. It seems to be working fine from the unit testing.
    Could someone provide me some information regarding the overhead (performance penalty) the clone method introduces?
    Thanks.
    Haiwei

    James,
    Thanks very much for your quick response.
    "The difference between using the clone vs not using the clone, is that clone (and changing the query) will trigger the query to no longer be prepared. This means that the query will need to re-generate the SQL for every execution."
    Is this always true or it depends on what query options got changed?
    I tried the cloneQuery with cloneQuery.cascadePrivateParts(). It seems that (from the trace) it still uses the prepared SQL. Here is the trace:
    in testQuery .....
    [3/8/05 15:27:47:027 EST] d510d51 SystemOut O 2005.03.08 03:27:47.027--ServerSession(1090797828)--Thread[Servlet.Engine.Transports : 1,5,main]--Connection(290525521)--SELECT * FROM QUOTE WHERE ID IN (?,?)
         bind => [1, 2]
    [3/8/05 15:27:47:037 EST] d510d51 SystemOut O 2005.03.08 03:27:47.037--ServerSession(1090797828)--Thread[Servlet.Engine.Transports : 1,5,main]--Connection(759639367)--SELECT NAME, ID, VERSION FROM USER04.SUBQUOTE WHERE (QUOTE_ID = ?)
         bind => [1]
    [3/8/05 15:27:47:037 EST] d510d51 SystemOut O 2005.03.08 03:27:47.037--ClientSession(219090191)--Thread[Servlet.Engine.Transports : 1,5,main]--client released
    A separate question, the cascade option is not configurable in the Mapping Workbench, is this something that TopLink deliberately does not provide?
    Thanks again for your assistance.

  • TopLink doesn't sort data received using Named query

    Hello!
    I'm trying to build a Tree table using a TopLink Named query in my application.
    There are Id, Parent|_Id, Code and Name columns in the corresponding database table, where Id and Parent|_Id are linked together by Foreign key (typical tree). I used TopLink to describe this table in the Model part of my application. There I wrote a Named query, without using a query constructor (not Expression radio button, but SQL radio button). Here the text of query:
    select * from regions a connect by prior a.Id = a.Parent_Id start
    with a.Id is null order by a.Code
    Then I created a Data control and tried to build a JSF page with data based on this query, as tree-table.
    But I discovered the fact, that data under the same node on the same leaf level of the Tree are not sorted by code on the JSF page. For example, data may be situated as follows (Code - Name):
    2. wwwwwwwwwwww
    2.3.kkkkkkkkkkkk
    2.1.fffffffffffffffffffff
    2.2.oooooooooo
    1. qqqqqqqqqqqqqqqq
    1. 2. lllllllllllllllllllllllllllll
    1. 1. hhhhhhhhhhhhhh
    etc.
    I verified this query on other environment (PL/SQL Developer, SQL+), but didn't found such unsorted results anywhere.
    Please, give me an advice to avoid this problem.
    Thanks.

    Hi
    Something to do with TreeMap(TreeSet). I tried with TreeSet but it didn't work. Here is the code :
    In servlet :
    Connection lConnection = getConnection(pRequest);
    String lSQL = "";
    Statement lStatement;
    ResultSet lResultSet;
    Hashtable lLtypeHashtable = new Hashtable();
    lStatement = lConnection.createStatement();
    lSQL = "SELECT RCID,RCMEANING FROM REFERENCECODES WHERE RCDOMAIN = 'LOCATIONTYPE' AND RCROWSTATE > 0 order by RCMEANING";
    lResultSet = lStatement.executeQuery(lSQL);
    while(lResultSet.next())
    String lRcid = lResultSet.getString(1);
    String lRcmeaning = lResultSet.getString(2);
    lLtypeHashtable.put(lRcid.trim(),lRcmeaning.trim());
    if(lResultSet != null) lResultSet.close();
    if(lStatement != null) lStatement.close();
    pRequest.setAttribute("LtypeHashtable",lLtypeHashtable);
    //Below Query is executed when one data from select element is selected
    String lLType = DisplayUtilities.getString(pRequest.getParameter("LType"),true);
    //LType is name of select element in JSP.
    if (lLType != null)
    lSQL = lSQL + " AND " + lUpperCaseFunction + "(LOCATIONTYPE)" +
    " = " + DBUtilities.formatString(lLType.toUpperCase());
    pRequest.setAttribute("rLType",lLType+"");
    In JSp :
    <%
    Hashtable lLtypeHashtable = (Hashtable)request.getAttribute("LtypeHashtable");
    %>
    <TR>
    <TD width="15%"> <div align="left">
    <select name="LType" size="1" >
    <option Value="">< Select ></option>
    <%
    if(lLtypeHashtable != null)
    Enumeration enum = lLtypeHashtable.keys();
    while(enum.hasMoreElements())
    String key = (String)enum.nextElement();
    String value = (String)lLtypeHashtable.get(key);
    String flagBack = "";
    if(key.equals((String)request.getAttribute("rLType")))
    flagBack = "selected";
    %>
    <option Value="<%=key%>" <%=flagBack%>><%=value%></option>
    <%
    %>
    </select></div>
    </TD>
    </TR>
    How should I implement TreeSet?
    Looking forward for an early reply.
    Thanks.

  • Getting the sql code of an expression(by Anizio)

    Hi to All
    I want to know if is possible get the real string sql of an expression using some class of toplink?
    For example:
    I have an expression "Expression ex = new ExpressionBuilder().get("CadTitular").get("titId").equal(5)"
    This is equals the following sql command "select * from CadTitular where tit_id = 5"
    I need get the sql value to leave an expression toplink
    Thank

    Yes, really this functioned, but help me again
    I tryed with other object "InsertObjectQuery", so, the result is "null"
    see the code
    public static void insertObjectQuery(DatabaseSession session){
    InsertObjectQuery query = new InsertObjectQuery();
    Address end = new Address();
    Employee empregado = new Employee();
    empregado.setEmpId(new Long(560));
    end.setAddressId(new Long(102));
    end.setCity("Manaus");
    end.setCountry("Brasil");
    end.setPCode("21547");
    end.setProvince("CN");
    end.setStreet("AV.");
    end.addEmployee(empregado);
    query.setObject(end);
    query.dontCascadeParts();
    DatabaseRow row = new DatabaseRow();
    query.prepareCall(session, row);
    String sql = query.getTranslatedSQLString(session, row);
    System.out.println("VALOR DE STRING SQL: " + sql); //print null
    session.executeQuery(query);
    }

  • 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

Maybe you are looking for

  • Can No Longer Connect To iChat

    Am running 10.4.11 on iMac Intel core 2 duo. iChat AV 3.1.9 (v446) Instant Message framework v429. Connected via a Netgear DG834GT router by ethernet cable and all normal internet and email functions ok. Never had a problem selecting and connecting t

  • No audio out on internal speakers or headphones from external device

    I'm using an intel iMac 17" I tried to plug in an external cassette deck, and listen to it through the internal speakers. Even though all system prefs for audio work as expected, and I can see the audio meters on screen operating, nothing will induce

  • Order related billing

    27.01.2011 Hi friends, I am trying to create order related billing. The material is a service, but i need to have a delivery created in the background. I have created an order and the delivery is created automatically. But when i am trying to create

  • Safari Freezes in Yosemite on File/Save As and File/Export As pdf

    Since I installed Yosemite a few days ago I can no longer save a webpage to a file or export to a pdf.  All I get is the spinning beach ball on top of a finder window and need force quit safari. The same problem occurs in Safe Mode.  The problem does

  • MySQL problem with 1and1 hosting

    I have just discovered this group.  I posted a similar post in the Dreamweaver area, but it probably needs to be here. I was asked to add database functionality to a website hosted by 1and1.  I just started to use DW CS5 recently and when I tried to