Query class

Hi Experts,
I am really stuck on this issue now.
I am trying to get an attribute of BuilMarketing object(Industry attribute) on my lead screen corresponding to the prospect selected.
I am using query object for this.I am writing this code in the event handler EH_ONSEL_PROSPECT(I have redefined it).I am writing such code for the first time and i m really stuck.I am getting syntax error:
Method "GET_PROPERTY_AS_VALUE" is unknown or PROTECTED or PRIVATE.
Is my approach correct.
Please help me!!!
method EH_ONSEL_PROSPECT.
CALL METHOD SUPER->EH_ONSEL_PROSPECT
EXPORTING
HTMLB_EVENT = HTMLB_EVENT
HTMLB_EVENT_EX = HTMLB_EVENT_EX
DATA : industry(4) type c,
query_service TYPE REF TO cl_crm_bol_dquery_service,
query_result TYPE REF TO if_bol_entity_col,
lr_builheader TYPE REF TO cl_crm_bol_entity,
lv_builbc TYPE REF TO if_bol_entity_col,
lr_partnerno TYPE string.
query_service = cl_crm_bol_dquery_service=>get_instance( 'BuilHeaderAdvancedSearch' ).
IF query_service IS BOUND.
CALL METHOD query_service->add_selection_param
EXPORTING
iv_attr_name = 'PARTNER'
iv_sign = 'I'
iv_option = 'EQ'
iv_low = lr_partnerno.
query_result = query_service->get_query_result( ).
lr_builheader = query_result->get_first( ).
endif.
CHECK lr_builheader IS BOUND.
lv_builbc = lr_builheader->get_related_entities( iv_relation_name = 'BuilMarketingRel').
lv_builbc->get_property_as_value( EXPORTING iv_attr_name = 'INDUSTRY'
IMPORTING ev_result = industry ).
call method lv_builbc->set_property (iv_attr_name = 'INDUSTRY' iv_value = ev_result ).
endmethod.

Hi, Phie.
I hope that still it can be useful, despite the delay.
One option to your report is set a condition to hide all the vendors out of the selection.
The bad news is regard performance, because the report always retrieve data of all vendors. But, I guess, this is the only way to knows the class of all vendors and display only the desired.
Regards,
Henrique

Similar Messages

  • Error in adding attachment to the workitem. load:class Query.class not foun

    Hi,
    We are using WebGui to access the Business Workplace(SBWP transaction) through Portal. For any work item, when i try to import a file from the local PC, i get a screen with the header -"Enter Some FIle attributes". Text displayed in the screen is "Please wait. You will be forwarded automatically. This page had to be included for techincal reasons". And i am struck in that screen. I believe a java popup winddow should come up at this point to select the PC File but it never happened. The screen also has a status message "
    Loading Java applet failed. Applet Query.class not inited ".
    WHen i look at the java console, i find the following error trace. Please let me know if anybody experienced this problem before and how to fix it. Thanks for the help.
    Trace ---
    load: class Query.class not found.
    java.lang.ClassNotFoundException: Query.class
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.IOException: open HTTP connection failed.
         at sun.applet.AppletClassLoader.getBytes(Unknown Source)
         at sun.applet.AppletClassLoader.access$100(Unknown Source)
         at sun.applet.AppletClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         ... 10 more
    Regards
    hari

    Hi all,
    I have encountered same problem in ITS 6.20.
    Query.class is packed in ws.jar which is stored at C:\Inetpub\wwwroot\<SID>\sap\its\mimes\webgui\99\applets and C:\Inetpub\wwwroot\<SID>\sap\its\mimes\webgui\2002\applets in ITS server.
    I increased the trace level to 3 in the Java console to inevestigate the problem further.
    == Java console (Trace level 3 ) ===
    network: cache entry not found URL: https://hostname.domain.co.jp:443/sap/its/mimes/webgui/2002/applets/ws.jar、version: null
    network: Connect to https://hostname.domain.co.jp:443/sap/its/mimes/webgui/2002/applets/ws.jar (Proxy=DIRECT)
    network: Connect to http://hostname.domain.co.jp:443/  (Proxy=DIRECT)
    java.net.ConnectException: Connection refused: connect
    load: class Query.class not found.
    java.lang.ClassNotFoundException: Query.class
    ==========================
    Then I found out that when system tried to load class Qery.class the connection to ITS was refused becase the incorrect protocol ( https ) was chosen.  In my case, SSL was not setup, therefore protocol must be http.
    I activated http by changing the configuration file for WGate in C:\Program Files\SAP\ITS\6.20\config\ ItsRegistryWGATE.xml
    After that, I restarted the WGate by accessing to http://hoostname.domain.co.jp:port/scripts/wgate/wgate-restart to activate the configuration.
    And also I restarted the AGate by restarting the Windows Service "SAP ITS Manager - <SID>".
    Anyway, the html (BHTML) file that displays the message below is stored at C:\Program Files\SAP\ITS\620\templates\system\dm\itsdoc.html
    "Please Wait. You will be forwarded automatically"
    "This page has been loaded due to technical Reasons"
    Best regards,
    Akira

  • Database DAO - JDBC Query Class - Code review please

    I use the following class (Database.java) as a DAO for handling all database calls. The class works. You can use this if you're looking for a DAO solution (i.e. a way to query databases using connection pools / JNDI). I am looking for some suggestions on improving this class. Can you help? I.e. suggestions for improving SELECT speed, logic? The class is used by a moderately heavily used Web application (ca. 2000 - 3000 queries a day - so not too much) on a Sun Web Server system.
    This class had the following interfaces:
    getErrors() // for retrieving any errors that occurred during an query
    setSql() // one way to set the SQL that must be run
    setDbName() // one way to set the JNDI name of the database resource
    getInsertDelete() // run the INSERT/DELETE statement that was provided with setSql
    getInsertDelete(String givenSql, String givenDb) // run with provided sql and db
    getClobInsert(String givenSql, String givenDb, Hashtable clobHash, String identifierSql) // clobHash contains the column name and the value (which is a string over 4000 chars). Identifier SQL is the SQL for identifying the row, into which the Clob must be inserted. This interface is specific to Oracle.
    getSelect() // Query database with set SQL. Return as a vector of hashes so I can close connection.
    getSelect(String givenSql, String givenDb) // select with given sqlAnd here is the full class. I know, this is a weird post, but we don't really have a code review process here at work, and I don't have a specific problem. Just want some feedback concerning the way I query our databases. So, any tips or comments are welcome.
    package melib.network;
    import java.io.Writer;
    import java.io.StringReader;
    import java.io.IOException;
    import java.util.Vector;
    import java.util.Hashtable;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.Clob;
    import javax.sql.DataSource;
    import javax.naming.InitialContext;
    import melib.system.PropertiesReader; // This is just a simple class for pulling values from a .properties file
    * Manages database connections.
    * @author jetcat33
    * @version 2.0, 2006-07-09
    public class Database {
        protected String sql = "";
        protected String dbName = "";
        private StringBuffer errors = new StringBuffer();
        /** Creates a new instance of Database */
        public Database() {
         * Check completeness of data
         * for example to check if dbname given or
         * sql given or to make sure that yikes
         * used instead of sccweb in test conditions
        protected boolean checkData(){
            if(dbName.equals("") || sql.equals("")){
                Email.sendMail(PropertiesReader.getValue("statusEmail"),null,"MelibLibraryError","melib error: [Database]","No database selected for query (db: "+dbName+" or sql not included (sql: "+sql+")");
                setErrors("No database selected for query (db: "+dbName+" or sql not included (sql: "+sql+")");
                return false;
            }else{
                return true;
         * Sets and gets errors resulting from
         * exceptions - otherwise would have to
         * somehow include errors in the results
         * that are returned but that would include
         * other more complicated stuff.
        private void setErrors(String e){
            errors.append("\n"+e);
        public StringBuffer getErrors(){
           return errors;
         * Setter for the sql variable.
         * @param givenSql The sql required to process
        public void setSql(java.lang.String givenSql) {
            sql = givenSql;
         * Sets the dbName needed to commect
         * to the correct database.
         * @param givenDbName Name of the database - name and connections specified within this class
        public void setDbName(java.lang.String givenDbName) {
            dbName = givenDbName;
         * Processes Insert and Delete requests with given SQL and DB Name.
         * @param givenSql
         * @param givenDbName
         * @return String Number of rows affected
        public String getInsertDelete(String givenSql, String givenDbName){
            sql = givenSql;
            dbName = givenDbName;
            return getInsertDelete();
         * Takes care of insert, update and delete requests.
         * Must have set both dbName as well as the sql String.
         * Will return number of rows affected as String.
         * @return String Number of rows affected
         * @exception Exception
        public String getInsertDelete() {
            int returnValue = 0;
            if(checkData()){
                Connection conn = null;
                InitialContext initContext = null;
                DataSource source = null;
                Statement stmt = null;
                try{
                    // Get connection from configured pool
                    initContext = new InitialContext();
                    source = (DataSource) initContext.lookup("java:comp/env/jdbc/" + dbName);
                    conn = source.getConnection();
                    if(conn != null){
                        stmt = conn.createStatement();
                        returnValue = stmt.executeUpdate(sql);
                }catch (Exception e){
                    Email.sendMail(PropertiesReader.getValue("statusEmail"),null,"MelibLibraryError","melib error: [Database.getInsertDelete]","getInsertDelete Exception: "+e.toString()+"\nWith: "+sql);
                    setErrors(e.toString());
                }finally{
                    try{
                        stmt.close();
                    }catch(Exception e){
                        e.printStackTrace();
                    try{
                        conn.close();
                    }catch(Exception e){
                       e.printStackTrace();
                    try{
                        initContext.close();
                    }catch(Exception e){
                        e.printStackTrace();
            return returnValue+"";
         * Processes Insert requests for SQL containing CLOBS
         * @param givenSql
         * @param givenDbName
         * @param clobHash Contains column name of clob and clob text
         * @param identifierSql Contains SQL to identify the just entered SQL so the clobs can be filled in.
         * @return String Number of rows affected
        public String getClobInsert(String givenSql, String givenDbName, Hashtable clobHash, String identifierSql){
            sql = givenSql;
            dbName = givenDbName;
            String returnValue="";
            int rv = 0;
            if(checkData()){
                Connection conn = null;
                InitialContext initContext = null;
                DataSource source = null;
                Statement stmt = null;
                try{
                    // Get connection from configured pool
                    initContext = new InitialContext();
                    source = (DataSource) initContext.lookup("java:comp/env/jdbc/" + dbName);
                    conn = source.getConnection();
                    if(conn != null){
                        conn.setAutoCommit(false);
                        stmt = conn.createStatement();
                        rv = stmt.executeUpdate(sql); // write first time
                        // Now get and overwrite "EMPTY_CLOB()"
                        ResultSet lobDetails = stmt.executeQuery(identifierSql);
                        ResultSetMetaData rsmd = lobDetails.getMetaData();
                        if(lobDetails.next()){
                            for(int i = 1; i <= rsmd.getColumnCount(); i++){
                                if(clobHash.get(rsmd.getColumnName(i))!=null && !clobHash.get(rsmd.getColumnName(i)).equals("")){
                                    Clob theClob = lobDetails.getClob(i);
                                    Writer clobWriter = ((oracle.sql.CLOB)theClob).getCharacterOutputStream();
                                    StringReader clobReader = new StringReader((String) clobHash.get(rsmd.getColumnName(i)));
                                    char[] cbuffer = new char[30* 1024]; // Buffer to hold chunks of data to be written to Clob, the slob
                                    int nread = 0;
                                    try{
                                        while((nread=clobReader.read(cbuffer)) != -1){
                                            clobWriter.write(cbuffer,0,nread);
                                    }catch(IOException ioe){
                                       //System.out.println("E: clobWriter exception - " + ioe.toString());
                                    }finally{
                                        try{
                                            returnValue+=" Writing: "+rsmd.getColumnName(i);
                                            clobReader.close();
                                            clobWriter.close();
                                        }catch(IOException ioe2){
                                            //System.out.println("E: clobWriter close exception - " + ioe2.toString());
                        conn.commit();
                }catch (Exception e){
                    Email.sendMail(PropertiesReader.getValue("statusEmail"),null,"MelibLibraryError","melib error: [Database.getClobInsert]","getClobInsert Exception: "+e.toString()+"\nWith: "+sql+"\nAND\n"+identifierSql);
                    setErrors(e.toString());
                }finally{
                    try{
                        stmt.close();
                    }catch(Exception e){
                        e.printStackTrace();
                    try{
                        conn.close();
                    }catch(Exception e){
                       e.printStackTrace();
                    try{
                        initContext.close();
                    }catch(Exception e){
                        e.printStackTrace();
                returnValue=rv+" "+returnValue;
            return returnValue;
         * Takes care of Select statements.
         * Must have set both dbName as well as the sql String.
         * Will return a vector.
         * @return Vector of Hashes containing the Results of the query
         * @exception SQLException
         * @exception Exception
        public Vector getSelect(){
            Vector returnValue = new Vector();
            if(checkData()){
                Connection conn = null;
                InitialContext initContext = null;
                DataSource source = null;
                ResultSet result = null;
                ResultSetMetaData rsmd = null;
                Statement stmt = null;
                try{
                    // Get connection from configured pool
                    initContext = new InitialContext();
                    source = (DataSource) initContext.lookup("java:comp/env/jdbc/" + dbName);
                    conn = source.getConnection();
                    if(conn != null){
                        stmt = conn.createStatement();
                        result = stmt.executeQuery(sql);
                        rsmd = result.getMetaData();
                        while(result.next()){
                            Hashtable hash = new Hashtable();
                            for(int i = 1; i <= rsmd.getColumnCount(); i++){
                                if(result.getString(i) != null){
                                    hash.put(rsmd.getColumnName(i),result.getString(i));
                                }else{
                                    hash.put(rsmd.getColumnName(i),"");
                            returnValue.addElement(hash);
                }catch (Exception e){
                    Email.sendMail(PropertiesReader.getValue("statusEmail"),null,"MelibLibraryError","melib error: [Database.getSelect]","getSelect Exception: "+e.toString()+"\nWith: "+sql);
                    setErrors(e.toString());
                }finally{
                    try{
                        result.close();
                    }catch(Exception e){
                        e.printStackTrace();
                        setErrors(e.toString());
                    try{
                        stmt.close();
                    }catch(Exception e){
                        e.printStackTrace();
                        setErrors(e.toString());
                    try{
                        conn.close();
                    }catch(Exception e){
                       e.printStackTrace();
                       setErrors(e.toString());
                    try{
                        initContext.close();
                    }catch(Exception e){
                        e.printStackTrace();
                        setErrors(e.toString());
            return returnValue;
         * Takes care of Select statements with given SQL.
         * Must have set both dbName as well as the sql String.
         * Will return a vector.
         * @return Vector with Results of the query
         * @exception SQLException
         * @exception Exception
        public Vector getSelect(String givenSql, String givenDbName){
            sql = givenSql;
            dbName = givenDbName;
            return getSelect();
    }Thank you,
    dailysun

    too much code that's repeated. refactor all the code you have for closing resources into a utility class and simply call its methods.
    your dao creates the connection, so it can't participate in a transaction. if there are several daos that should be one unit of work, you can't manage it with this framework.
    transactions are under the control of a service layer. I think it's better to have the service object get the connection, pass it to all the DAOs needed for that unit of work, and then have the service close it.
    e-mailing errors? I don't like it. if you have 2-3K queries a day failing because the database you'll have 2-3K e-mails to delete. better to log messages. if you really want e-mail, you can have Log4J add an e-mail appender. at least that way it's configurable outside the code.
    CRUD operations without an UPDATE? You're missing something important.
    What if I don't want to get the database from a JNDI datasource? Now you can't use this DAO without an app server.
    Your error messages are less informative than a stack trace. Why not throw an exception with detailed info?
    have a look at Spring and how it handles persistence. if you insist on writing your own, might want to look at Spring. Rod Johnson has developed a much better, more general way to handle persistence.
    http://www.springframework.org
    You return a Vector of Hashtables for queries? Two old-school data structures. You understand the implication of choosing those, right? I'd recommend that you change that to a List of Maps. Let the concrete types be ArrayList and HashMap. Interfaces are preferred, because they let you change the implementation without affecting clients. Vector and Hashtable are synchronized by default; ArrayList and HashMap are not. Synchronization is thread safe but slower.
    I understand why you chose to return Vector, because you wanted something general that wouldn't force you to deal with object-relational mapping. This way you can just worry about ResultSetMetaData.
    A Vector of Hashtables is a row-based view of the ResultSet (one Hashtable per row). Sometimes a column based view can be more convenient. Then it's a Map of Lists.
    You gave it a good try, but I think there's a lot of room for improvement.
    %

  • Can I query class created in current transaction?

    I want to do the following:
    manager.currentTransaction().begin();
    manager.makePersistent(myObject);
    Query q = manager.newQuery(myObject.getClass());
    Collection objs = (Collection)q.execute();
    manager.currentTransaction().commit();
    and I want myObject to show up in the objects collection. Is there a way
    to do that?
    I thought of using read-uncommitted as the transaction isolation level,
    but Oracle complained when I tried that.
    Overrall what I'm trying to do is write unit tests such that I can set up
    the test data, run the test, and rollback the transaction to clean it all
    up.
    Thanks!
    -joel

    It worked great.
    This is just for code testing, so performance isn't critical.
    Thanks!
    Abe White wrote:
    Set the query's IgnoreCache property to false:
    q.setIgnoreCache (false);
    You can also set this property at the PM level (affecting all queries
    and extents from that PM) and the PMF level via the
    javax.jdo.option.IgnoreCache setting (affecting everything).
    However, note that if you are not ignoring PM cache changes and do not
    set kodo.FlushBeforeQueries to true, we will have to perform the query
    in-memory, which is a very slow process compared to database queries.

  • Query.setRange() not available on standard javax.jdo.Query interface?

    Hi Kodo people, I'm trying out Kodo 3.2.0, most specifically for the
    spiffy new setRange() functionality. However, I'm somewhat confused
    because while the docs clearly indicate that the setRange() method is
    available on the standard javax.jdo.Query interface, it's not available
    on the javax.jdo.Query class that ships with Kodo 3.2.0. I have to cast
    my query to a KodoQuery in order for this to work. Is this expected?
    Thanks,
    -Mike
    Michael Allen
    Technical Lead
    PGP Corporation

    I think you missed the note at the beginning of the query chapter in the docs:
    Much of the functionality we discuss in this chapter is new to JDO 2. Though
    Kodo supports all of the features defined in the following sections, many JDO
    implementations may not. Additionally, because official JDO 2 jars are not yet
    available, you will have to cast your query objects to kodo.query.KodoQuery to
    access any JDO 2 APIs. The UML diagram above depicts these APIs in bold. For
    simplicity, casts have been left out of the example code throughout the chapter.

  • How to create custom BOL object for dynamic query in CRM 7.0

    Hi,
    Could anyone please explain me with steps that how to create the custom BOL object for dynamic query in CRM 7.0, I did it in previous version but its throwing exception when i try to create the object of my dynamic query class. I just defined the entry of my in crmv_obj_btil to create the dynamic query BOL object. do i need to do any other thing also to make it work?
    Regards,
    Kamesh Bathla
    Edited by: Kamesh Bathla on Jul 6, 2009 5:12 PM

    Hi Justin,
    First of thanks for your reply, and coming to my requirement, I need to report the list of items which are there in the dynamic select statement what am getting from the DB. The select statement number of columns may vary in my example for different countries the select item columns count is different. For US its '15', for UK it may be 10 ...like so, and some of the column value might be a combination or calculation part of other table columns (The select query contains more than one table in the from clause).
    In order to execute the dynamic select statement and return the result i choose to write a function which will parse the cursor for dynamic query and then iterate the values and construct a Type Object and append it to the pipe row.
    Am relatively very new for these sort of things, welcome in case of any suggestions to make it simple (Instead of the function what i thought to work with) also a sample narrating the new procedure will be appreciated.
    Thanks in Advance,
    mallikj2.

  • Can we set the query timeout value in a global control place?

    hi everyone,
    We use the FullTextSqlQuery class to do query stuff, but we have the query timeout issue, the query sometimes timeout, sometimes is normal.  I know there is a property from Query class called Timeout, and the default
    time is 15 seconds, but we have lots of code involving FullTextSqlQuery.
    I want to know is there a gloabal place like the web.config or regedit or somewhere to set the timeout value?
    Thanks

    Did you ever get an answer?  I'm in the same boat...the only way I can seem to not charge tax to my wholesale clients is to set "tax never applies".  But I got over 300 products...how can I do it "en mass"???
    Anybody??
    I tried creating a special tax code at 0% but that didn't do it either.
    thanks in advance,
    Scot.

  • Af:query how to control the query combobox and change it's label text

    My colleague designed a well working af:query search page with several selectable predefined queries. Now it's up to me to control this combobox from outside the component with big colored buttons for user convenience. If the user clicks on one of the big buttons, the assigned item of the combobox is selected and then the query is submitted.
    I though about doing this with javascript, but the difficulty is, that I have no idea and didn't find a way to reference the id of the combobox? The combobox is a 'built in' component in he af:query component and there is no way to give it an id in the properties.
    The second problem is that I didn't find a way to change the label text of the combobox. It seems to be hard coded?
    Thanks in advance for your suggestion!

    Hi,
    the text should be coming from a message bundle and some other look and feel related elements should be settable through skinning in CSS
    http://www.oracle.com/technology/products/adf/adffaces/11/doc/skin-selectors.html
    search for af|query
    Regarding the JavaScript access, use firebug JS debugger. The af query class is AdfRichQuery.js
    http://www.oracle.com/technology/products/adf/adffaces/11/doc/multiproject/adf-richclient-api/js_docs_out/AdfRichQuery.html
    Note however that you should be able to do in Java what you are aimning for in JavaScript. However the usecase you want to implement is not fully clear to me - to be honest
    Frank

  • JDQL named query syntax error

    Hi,
    we have a syntax error in our JDOQL-namedQuery. We want to do a join over
    two tables "TestOrder" and "TestOrderPosition" and get this error:
    (we use Kodo 4.0)
    <?xml version="1.0"?>
    <jdoquery>
    <package name="salt.domain.orderservice.entity">
    <class name = "TestOrder">
         <query name="findByOrderId">select where
    testOrderPositions.contains(testOrderPosition) and
    testOrderPosition.description==:t variables
    salt.domain.orderservice.entity.TestOrderPosition testOrderPosition</query>
    </class>
    </package>
    </jdoquery>
    <4|false|4.0.0EA3> kodo.jdo.UserException: An error occurred while parsing the
    query filter "testOrderPositions.contains(testOrderPosition) and
    testOrderPosition.description==:t". Error message: The JDOQL string is not
    valid. Make sure all parentheses are matched and that you use proper Java
    syntax.
         kodo.query.AbstractExpressionBuilder.parseException(AbstractExpressionBuilder.java:92)
         kodo.query.jdoql.JDOQLExpressionBuilder.evalExpression(JDOQLExpressionBuilder.java:508)
         kodo.query.jdoql.JDOQLExpressionBuilder.eval(JDOQLExpressionBuilder.java:265)
         kodo.query.jdoql.JDOQLParser.eval(JDOQLParser.java:98)
         kodo.query.ExpressionStoreQuery$DataStoreExecutor.<init>(ExpressionStoreQuery.java:542)
         kodo.query.ExpressionStoreQuery.newDataStoreExecutor(ExpressionStoreQuery.java:154)
         kodo.query.QueryImpl.createExecutor(QueryImpl.java:807)
         kodo.query.QueryImpl.compileForDataStore(QueryImpl.java:741)
         kodo.query.QueryImpl.compileForExecutor(QueryImpl.java:721)
         kodo.query.QueryImpl.compile(QueryImpl.java:635)
         kodo.kernel.BrokerImpl.namedQuery(BrokerImpl.java:3681)
         kodo.kernel.DelegatingBroker.namedQuery(DelegatingBroker.java:1587)
         kodo.jdo.PersistenceManagerImpl.newNamedQuery(PersistenceManagerImpl.java:1028)
         salt.domain.orderservice.dao.jdo.JDOOrderRepositoryImpl.findOrderWithPositionById(JDOOrderRepositoryImpl.java:85)
         salt.domain.orderservice.OrderRepositoryImpl.findOrderWithPositions(OrderRepositoryImpl.java:91)
         salt.domain.orderservice.OrderServiceImpl.getOrderWithPosition(OrderServiceImpl.java:15)
         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         java.lang.reflect.Method.invoke(Unknown Source)
         org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)
         org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
         org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
         org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
         org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
         org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
         $Proxy0.getOrderWithPosition(Unknown Source)
         salt.application.DddTestController.handleRequest(DddTestController.java:40)
         org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
         org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:717)
         org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:658)
         org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:392)
         org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:347)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    Does anyone have an idea?
    Thanks,
    Ingo Schneider

    Thanks for your help! It works now!
    I have another problem with a very simple query:
    I always get a ClassCastException with the follwoing query. If I left the
    result parameter out the query works. Parameter "t" is an integer, but
    there shouldn't be any cast problems between integer and long.
    <?xml version="1.0"?>
    <jdoquery>
         <package name="salt.domain.orderservice.entity">
              <class name="TestOrder">
         <query name="findByOrderIdPosition">select idOrder where
    idOrder==:t</query>
    </class>
    </package>
    </jdoquery>
    public class TestOrder implements Serializable{
         private String description;
         private long idOrder;
         private Set testOrderPositions = new HashSet();
    getters & setters...
    java.lang.ClassCastException: java.lang.Long
         salt.domain.orderservice.dao.jdo.JDOOrderRepositoryImpl.findOrderWithPositionById(JDOOrderRepositoryImpl.java:99)
         salt.domain.orderservice.OrderRepositoryImpl.findOrderWithPositions(OrderRepositoryImpl.java:91)
         salt.domain.orderservice.OrderServiceImpl.getOrderWithPosition(OrderServiceImpl.java:15)
         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         java.lang.reflect.Method.invoke(Unknown Source)
         org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)
         org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
         org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
         org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
         org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
         org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
         $Proxy0.getOrderWithPosition(Unknown Source)
         salt.application.DddTestController.handleRequest(DddTestController.java:40)
         org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
         org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:717)
         org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:658)
         org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:392)
         org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:347)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    Thanks,
    Ingo Schneider

  • Equivalent of a prepared stmt (with mapping table to a java class) ?

    Hi,
    We can fire raw-sql using SQLCall(). Do we have something similar to make and use prep stmts ?
    If we have mapped tables to some java classes, this cud be done with the use of toplink 'Query' classes.
    But if I dont have anything mapped and want to use the raw-sql kinda method, is it possible to make and use a prep stmt in toplink ?
    Thanks,
    Krishna

    Hi Donald, You are right...I was actually looking for something to use JDBC code directly for these parts. So is there a way to get a java.sql.Connection out of the TopLink session and then fire prepared statements (JDBC code) using that connection ?
    Can we do something like this... (do let me know if this is not the right way to do it at all...or if it is not possible at all)
    ConnectionPool oCP = RuntimeServices.getConnectionPools().elementAt(0); // plz ignore that i assumed pools are returned as Vector
    java.sql.Connection oCon = oCP.getDatabaseLogin().connect(prop); // is it necessary to give prop (since I got it from existing conn pools that are already setup in the server session)
    Thanks,
    Krishna

  • Data from BI query

    Hi ,
    I'm stuck on an Abap program
    I have to execute a Bex Query then store the retreived data, the old logic uses classe cl_RSR_Query_variables, this doesn't exist any more.
    I want to keep my logic and substitute only the type of my query variable
    here it is the part of logic to modify
    DATA: wf_query_var TYPE REF TO cl_rsr_query_variables .
    DATA: r_request TYPE REF TO cl_rsr_request.
    DATA: r_dataset TYPE REF TO cl_rsr_data_set.
    MOVE: query_name TO cube_name .
    Convert the query name to technical id
    CLEAR p_genuniid .
    CALL FUNCTION 'CONVERSION_EXIT_GENID_INPUT'
    EXPORTING
    input = query_name
    IMPORTING
    output = p_genuniid.
    IF p_genuniid IS INITIAL .
    RAISE query_not_found .
    ENDIF.
    Create instance of cl_rsr_request
    CREATE OBJECT r_request
    EXPORTING i_genuniid = p_genuniid .
    Create instance of cl_rsr_variables
    i_var[] = query_variables[] .
    CREATE OBJECT wf_query_var
    EXPORTING
    i_r_request = r_request
    i_t_nvar = i_var
    EXCEPTIONS
    user_not_authorized = 1
    no_processing = 2
    bad_value_combination = 3
    x_message = 4
    OTHERS = 5.
    IF sy-subrc <> 0.
    CASE sy-subrc .
    WHEN 1 .
    RAISE user_not_authorized .
    WHEN 3 .
    RAISE bad_value_combination .
    WHEN OTHERS .
    RAISE unknown_error .
    ENDCASE .
    ENDIF.
    Set the variable and execute the query
    TRY.
    r_request->variables_set( i_t_var = i_var ).
    r_request->variables_start( ).
    r_request->read_data( ).
    r_dataset = cl_rsr_data_set=>get( i_r_request = r_request ).
    Thanks for any suggestion

    You Might (I say Might) possibly have better luck if you can use the BI accelerator. On 640 of course the old BW methods and classes are still in the system.
    I haven't actually used the BI accelerator but I'm told by people who have that it's an excellent tool for almost limitless queries. I'm sure some "Googling" or browsing the BI Forum might also help you.
    Often when a new release is installed people try and "replicate" old stuff. In general (although I know it's not always true in SAP's case) if stuff has been removed in  a new release it's either because the old method is "deprecated" or there's a hugely better method available.
    I'm sorry I can't be more helpful than that but if you MUST have this query class you can always I suppose try and get it "Retrofitted" to your system. I'd advise against that approach however.
    Cheers
    Jimbo

  • Bug or DUE attempting navigation to Date field in query

    I am encountering trouble executing a query that involves
    navigating a one-way one-to-one relationship
    (persistent reference to PC object) to use a Date field.
    The query is the following: "period.endingDate <=
    p.endingDate" with a query class of Vote. The right side of the
    query has been varied and varying it yields different errors,
    but the query will not execute. The parameter is defined as:
    "VotingPeriod p". The import string is present and appears
    okay.
    For the current form, the error is:
    javax.jdo.JDOUserException: The given filter/ordering String
    "period.endingDate <= p.endingDate" is not valid.
    Make sure all parentheses are properly matched and that the filter uses
    proper Java syntax.
         at com.solarmetric.kodo.query.FilterParser.evaluate(FilterParser.java:536)
         at com.solarmetric.kodo.query.QueryImpl.getExpression(QueryImpl.java:371)
         at com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.getExpression(JDBCQuery.java:49)
         at com.solarmetric.kodo.query.QueryImpl.executeWithMap(QueryImpl.java:312)
         at com.solarmetric.kodo.query.QueryImpl.executeWithArray(QueryImpl.java:393)
         at com.solarmetric.kodo.query.QueryImpl.execute(QueryImpl.java:285)
    The Vote class is defined as:
    public class Vote
    // The pair (topic, period) is unique for all votes
    private Topic topic;
    private VotingPeriod period;
    private int count;
    The VotingPeriod class is defined as:
    public class VotingPeriod
    // the pair (startingDate, endingDate) are unique for all voting periods
    private Date startingDate;
    private Date endingDate;
    If the query is modified to be: "period.endingDate <= d" and
    the parameter is declared as "java.util.Date d", then the error
    is:
    javax.jdo.JDOException: com.ysoft.jdo.book.voting.VotingPeriod
    NestedThrowables:
    java.io.NotSerializableException: com.ysoft.jdo.book.voting.VotingPeriod
         at
    com.solarmetric.kodo.impl.jdbc.schema.dict.GenericDictionary.toSQL(GenericDictionary.java:122)
         at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCExpressionFactory$Constant.<init>(JDBCExpressionFactory.java:419)
         at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCExpressionFactory.getConstant(JDBCExpressionFactory.java:213)
         at com.solarmetric.kodo.query.FilterParser.eval(FilterParser.java:562)
         at com.solarmetric.kodo.query.FilterParser.getValue(FilterParser.java:668)
         at com.solarmetric.kodo.query.FilterParser.eval(FilterParser.java:601)
         at com.solarmetric.kodo.query.FilterParser.getExpression(FilterParser.java:677)
         at com.solarmetric.kodo.query.FilterParser.evaluate(FilterParser.java:527)
         at com.solarmetric.kodo.query.QueryImpl.getExpression(QueryImpl.java:371)
         at com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.getExpression(JDBCQuery.java:49)
         at com.solarmetric.kodo.query.QueryImpl.executeWithMap(QueryImpl.java:312)
         at com.solarmetric.kodo.query.QueryImpl.executeWithArray(QueryImpl.java:393)
         at com.solarmetric.kodo.query.QueryImpl.execute(QueryImpl.java:285)
    David Ezzio
    Yankee Software

    Hi Patrick,
    Okay, there is a bug. Your parser doesn't know how to handle the ProxyDate class. So if a "Date"
    is passed into the query that came from a persistent object, then a ProxyDate object is passed. If
    the date is a simple "Date" object then all is well. For the simple date, the parser constructs a
    query in nice JDBC escape syntax, but for ProxyDate objects, it generates garbage.
    David
    David Ezzio wrote:
    >
    I am encountering trouble executing a query that involves
    navigating a one-way one-to-one relationship
    (persistent reference to PC object) to use a Date field.
    The query is the following: "period.endingDate <=
    p.endingDate" with a query class of Vote. The right side of the
    query has been varied and varying it yields different errors,
    but the query will not execute. The parameter is defined as:
    "VotingPeriod p". The import string is present and appears
    okay.
    For the current form, the error is:
    javax.jdo.JDOUserException: The given filter/ordering String
    "period.endingDate <= p.endingDate" is not valid.
    Make sure all parentheses are properly matched and that the filter uses
    proper Java syntax.
    at com.solarmetric.kodo.query.FilterParser.evaluate(FilterParser.java:536)
    at com.solarmetric.kodo.query.QueryImpl.getExpression(QueryImpl.java:371)
    at com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.getExpression(JDBCQuery.java:49)
    at com.solarmetric.kodo.query.QueryImpl.executeWithMap(QueryImpl.java:312)
    at com.solarmetric.kodo.query.QueryImpl.executeWithArray(QueryImpl.java:393)
    at com.solarmetric.kodo.query.QueryImpl.execute(QueryImpl.java:285)
    The Vote class is defined as:
    public class Vote
    // The pair (topic, period) is unique for all votes
    private Topic topic;
    private VotingPeriod period;
    private int count;
    The VotingPeriod class is defined as:
    public class VotingPeriod
    // the pair (startingDate, endingDate) are unique for all voting periods
    private Date startingDate;
    private Date endingDate;
    If the query is modified to be: "period.endingDate <= d" and
    the parameter is declared as "java.util.Date d", then the error
    is:
    javax.jdo.JDOException: com.ysoft.jdo.book.voting.VotingPeriod
    NestedThrowables:
    java.io.NotSerializableException: com.ysoft.jdo.book.voting.VotingPeriod
    at
    com.solarmetric.kodo.impl.jdbc.schema.dict.GenericDictionary.toSQL(GenericDictionary.java:122)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCExpressionFactory$Constant.<init>(JDBCExpressionFactory.java:419)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCExpressionFactory.getConstant(JDBCExpressionFactory.java:213)
    at com.solarmetric.kodo.query.FilterParser.eval(FilterParser.java:562)
    at com.solarmetric.kodo.query.FilterParser.getValue(FilterParser.java:668)
    at com.solarmetric.kodo.query.FilterParser.eval(FilterParser.java:601)
    at com.solarmetric.kodo.query.FilterParser.getExpression(FilterParser.java:677)
    at com.solarmetric.kodo.query.FilterParser.evaluate(FilterParser.java:527)
    at com.solarmetric.kodo.query.QueryImpl.getExpression(QueryImpl.java:371)
    at com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.getExpression(JDBCQuery.java:49)
    at com.solarmetric.kodo.query.QueryImpl.executeWithMap(QueryImpl.java:312)
    at com.solarmetric.kodo.query.QueryImpl.executeWithArray(QueryImpl.java:393)
    at com.solarmetric.kodo.query.QueryImpl.execute(QueryImpl.java:285)
    David Ezzio
    Yankee Software

  • Converting String to Class?

    I'm trying to convert a String to a Class name and then instantiate an object from that class. It's proving to be quite difficult. I have a Query object which is a superclass and has several subclasses, one of which is CommonQuery. Here's my code so far. Basically I need "c" to be the specific type of Query that it should be. What am I doing wrong?
    for(Query q:results)
                Class cl = Class.forName(myClass);//myClass is the String that I'd like to convert to a class, CommonQuery for example
                Constructor ct = cl.getConstructor(new Class[]{Query.class});//Query is the superclass but they all have the same constructor
                Query c = (Query)(ct.newInstance(new Object[]{q.getWords(),q.getFile()}));
                c.computeRank();
                unsorted.add(c);
    }

    This is the error that I'm getting:
    Exception in thread "main" java.lang.NoSuchMethodException: nano.CommonQuery.<init>(nano.Query)
         at java.lang.Class.getConstructor0(Unknown Source)
         at java.lang.Class.getConstructor(Unknown Source)I guess this is what you meant about not overriding the constructors. How do I get the constructor from a class that I don't know what it is yet?
    What goes in here where I have Query.class?
    Constructor ct = cl.getConstructor(new Class[]{Query.class});I'm not familiar with the reflection forums. Should I go post in there now?

  • Java reflection query

    hi,
    I have a class B that inherits from a class A. Now, in a class C, I have a following method :
    Class C
    public void foo( A ){ ..}
    if I query class C for a method "foo" that takes params of type B, it does not return the above defined method.
    Why is this so?

    the short answer is "because that's how Class.getMethod() behaves". it kind of assumes that you know the exact signature of the method in advance. most of the time this suffices, but other times, like what you're doing, it doesn't work. the above article discusses some of the issues with reflective method lookup, and provides some code that should help you replace Class.getMethod() with something a little more dynamic.

  • X.class in MyObject X

    X.class in the following code won't compile, but I need it. Is it possible to do this?
    public class MyObject<X> {
       public void loadAll() {
          MyHibernateTemplate.loadAll(X.class);
    }

    Reading your post I was really suprise, because I had the same idea using the Hibernate Support from Spring, nevertheless I took a different approach without requiring an abstract class. I am sending to you my idea:
    package com.amena.cac.data;
    import java.io.Serializable;
    import java.util.List;
    public interface EntityDao<Reg, PK extends Serializable> {
        public void save(Reg register);
        public List<Reg> getAll();
        public void delete(Reg register);
        public Reg getById(PK id);  
    }where Reg represent the Entity Class (Register) and PK its corresponding primary key class.
    Now we can do the Hibernate implementation as follows:
    import java.io.Serializable;
    import java.lang.reflect.ParameterizedType;
    import java.util.List;
    import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
    import com.amena.cac.data.EntityDao;
    public class HibernateEntityDao<E, PK extends Serializable>
        extends HibernateDaoSupport implements EntityDao<E,PK> {
        private Class<E> eClass; // I don't know how instance it?????
        public void save(E register) {
            getHibernateTemplate().saveOrUpdate(register);
        @SuppressWarnings(value={"unchecked"})
        public List<E> getAll() {
            return getHibernateTemplate().loadAll(this.eClass);
        public void delete(E register) {
            getHibernateTemplate().delete(register);
        @SuppressWarnings(value={"unchecked"})
        public E getById(PK id) {
            return (E)(getHibernateTemplate().load(this.eClass, id));
    (I am waiting for people of the forum to get some input about how to
    get an instance of eClass) see the following link:
    http://forum.java.sun.com/thread.jspa?threadID=684429&tstart=0
    I assume you are using Spring, and for the moment the Hibernate Template class doesn't provide a method for deleting a given register directly on the database, that is why I have not defined a method like this: deleteById (PK id); so it just delete register on the database, but the corresponding objet doesn't not exist, in case the objet exist just you can use delete(Reg register)
    The solution for that could be to use the new method ( from Spring 1.2.6):
    bulkUpdate(String queryString) from HibernateTemplate. In such case we have to add another parameter on the class definition for considering getting the query information for specific case, for example, somethink like this:
    public class HibernateEntityDao<E, PK extends Serializable, Q extends EnumMap<QueryKeys,String>>
        extends HibernateDaoSupport implements EntityDao<E,PK> {
    // Remember QueryKeys.class doesn't compile
    private Q<EnumMap<QueryKeys, String>> queries =
    new EnumMap<QueryKeys, String>(QueryKeys.class);
    }where Q represent an EnumMap class for storing the queries. The enum keys are all the same, for example DELETE, FIND, etc, now you have just extends a given EnumClass class with the particular values for each case, for example for deleting a customer: "delete from Customer where id=?"
    This solution is quite general, but I need to think more about the Query
    For example something like this:
    public enum QueryKeys { DELETE, FIND}Now we can create a particular query class:
    public class CustomerQuery extends EnumMap<QueryKeys, String>{
    // initialize the query field.
      CustomerQuery(){   
        queries.put(QueryKeys.DELETE, "delete from Customer");
    }Now we can instance the corresponding Hibernate case:
    HibernateEntityDao<Customer, String, CustomerQuery> customerDao;
    on the HibernateEntityDao definition, the deleteById would look like this:
    public void deleteById(PK id) {
            getHibernateTemplate().bulkUpdate(this.queries.get(QueryKeys.DELETE));
    It is just a template I have to think more in order to get this compile.
    another solution for delete by Id, could be to get the Hibernate Session and then to invoke the delete(id). But you have to explicitly work with the hibernate sesssion. The solution that use the EnumMap class, just use the Spring Hibernate Template class.
    Thanks for any idea about that,
    David
    ([email protected])

Maybe you are looking for