How to use ReportQuery to query against two types of objects?

I have two loosely related classes Account and AccountState. They are not mapped to each other, have no inheritance or other relationships, but they both have account_id as their key attribute.
I would like to build a ReportQuery to return selective attributes across Account and AccountState. Is there anyway to do so?
Thanks in advance.
George Zou

George,
Typically for the scenario you are describing I would recommend adding a 1:1 relationship from Account to state using the shared PK. If this is an option you should note that to keep the ID napped in each as a direct-to-field you will need to set-up the 1:1 using a target foreign key.
For every 1:1 relationship in your model TopLink automatically creates a 1:1 query key. It is these query keys that you are implicitly using when defining expressions.
If you really don't want to add the 1:1 mapping to your model then you can alternatively add a 1:1 query key yourself to your Account class that allows for the relationship to be used in an expression and thus a Report Query.
Example 6-21 in the 9.0.4 application developers guide shows how to create a OneToOneQueryKey programmatically.
I would guess your descriptor after-load method would look something like:
public static void addToAccontDescriptor(Descriptor descriptor)
OneToOneQueryKey ownerQueryKey = new OneToOneQueryKey();
ownerQueryKey.setName("state");
ownerQueryKey.setReferenceClass(AccountState.class);
ExpressionBuilder builder = new ExpressionBuilder();
ownerQueryKey.setJoinCriteria(builder.getField("ACCOUNT.ID").equal(builder.getParameter("ACCOUNT_STATE.ID")));
descriptor.addQueryKey(ownerQueryKey);
Now whether you added the 1:1 mapping or the 1:1 query key the ReportQuery would look the same:
ReportQuery rq = new ReportQuery(Account.class, new ExpressionBuilder());
rq.addAttribute("id");
rq.addAttribute("State Value", rq.getExpressionBuilder().get("state").get("value"));
I hope this helps,
Doug

Similar Messages

  • How to use one commandButton to execute two tasks in JSF

    I have a form in JSF page which contains different faces components. These faces bind to ADF BC to insert one row in the database when the user press commandButton. Also I need to bind the value of one inputText in that form to managed bean to execute another task in the application when the user press the same commandButton.
    The code of the inputText:
    <h:inputText value="#{bindings.ProjectNumber.inputValue}"
    id="pn"
    size="10"
    required="#{bindings.ProjectNumber.mandatory}">
    The code of commandButton:
    <h:commandButton actionListener="#{bindings.Commit.execute}"
    value="Save"
    disabled="#{bindings.Commit.actionEnabled}"/>
    The managed bean is �findInspector�. I tried to insert inputHidden inside commandButton tag and assign the value of the inputText to the inputHidden as follows:
    <h:commandButton actionListener="#{bindings.Commit.execute}"
    value="Save"
    disabled="#{bindings.Commit.actionEnabled}">
    <h:inputHidden value="#{bindings.ProjectNumber.inputValue}" binding="#{findInspector.project}"/>
    </h:commandButton>
    But it was not work
    Please how can I write the code to use the value of the inputText more than one time in the JSF(one to insert one row by using ADF BC and another to use the same value to bind to a managed bean) and how to use one commandButton to execute two tasks in JSF.
    Thank you
    Waheed

    Just dopublic void execute() {
        anotherAction(inputValue);
    I guess those articles might be interesting about passing params and the usage of inputHidden and also about using datatables:
    http://balusc.xs4all.nl/srv/dev-jep-com.html
    http://balusc.xs4all.nl/srv/dev-jep-dat.html

  • How to use one commandButton  to execute two task in JSF

    I have a form in JSF page which contains different faces components. These faces bind to ADF BC to insert one row in the database when the user press commandButton. Also I need to bind the value of one inputText in that form to managed bean to execute another task in the application when the user press the same commandButton.
    The code of the inputText:
    <h:inputText value="#{bindings.ProjectNumber.inputValue}"
    id="pn"
    size="10"
    required="#{bindings.ProjectNumber.mandatory}">
    The code of commandButton:
    <h:commandButton actionListener="#{bindings.Commit.execute}"
    value="Save"
    disabled="#{bindings.Commit.actionEnabled}"/>
    The managed bean is “findInspector”. I tried to insert inputHidden inside commandButton tag and assign the value of the inputText to the inputHidden as follows:
    <h:commandButton actionListener="#{bindings.Commit.execute}"
    value="Save"
    disabled="#{bindings.Commit.actionEnabled}">
    <h:inputHidden value="#{bindings.ProjectNumber.inputValue}" binding="#{findInspector.project}"/>
    </h:commandButton>
    But it was not work
    Please how can I write the code to use the value of the inputText more than one time in the JSF(one to insert one row by using ADF BC and another to use the same value to bind to a managed bean) and how to use one commandButton to execute two task in JSF.
    Thank you
    Waheed

    Yes I did
    <managed-bean>
    <description>The bean for get project No</description>
    <managed-bean-name>projectBean</managed-bean-name>
    <managed-bean-class>
    mcscm.model.ProjectBean
    </managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
    <property-name>bindings</property-name>
    <value>#{bindings}</value>
    </managed-property>
    </managed-bean>
    Also I changed the method in the managed bean as follows:
    public String commandButton_action() {
    FacesContext fctx = FacesContext.getCurrentInstance();
    ValueBinding vb = fctx.getApplication().createValueBinding("#{bindings}");
    DCBindingContainer dcb = (DCBindingContainer) vb.getValue(fctx);
    OperationBinding operation = (OperationBinding) dcb.get("projectNumber");
    operation.execute();
    return null;
    where projectNumber is my method in the java class of the application module "TaskInformationImpl". I made this method to be accessed from outside of ADF BC.
    I just create a sample code for projectNumber method for testing only as:
    public void projectNumber (String data){
    System.out.print(data);
    In the page Pagedef file I added this :
    <methodAction id="projectNumber"
    InstanceName="TaskInformationDataControl.dataProvider"
    DataControl="TaskInformationDataControl"
    MethodName="projectNumber" RequiresUpdateModel="true"
    Action="999" IsViewObjectMethod="false">
    <NamedData NDName="data" NDValue = "#{bindings.ProjectNumber.inputValue}" NDType="java.lang.String"/>
    After I did all of this I get a new error like:
    javax.faces.FacesException: #{projectBean.commandButton_action}: javax.faces.el.EvaluationException: java.lang.ClassCastException: oracle.adfinternal.view.faces.model.binding.FacesCtrlAttrsBinding cannot be cast to oracle.adf.model.OperationBinding
    Is it very difficult to do this in JDeveloper?. yes ADF BC provide me a lot of facilities, but when I want to do a specific task I face a lot of troubles

  • How to use WMI to query to distinguish legacy and UEFI mode Windows?

    How to use WMI to query to distinguish legacy and UEFI mode Windows?

    This document covers requirements for UEFI support.
    http://msdn.microsoft.com/en-us/windows/hardware/gg463144.aspx
    One of the requirements seems to be ACPI. The Win32_BIOS class of WMI has a BIOSCharacteristics property that indicates if ACPI is supported. See this link for properties exposed by Win32_BIOS:
    http://msdn.microsoft.com/en-us/library/aa394077(v=VS.85).aspx
    There is a PowerShell example showing how to get this information at the bottom. You will need to study the document in the first link to see what else is required.
    Richard Mueller - MVP Directory Services

  • How to use INVOKE function with INT parameter types

    Can you tell me how to use invoke function with int parameter type ?

    Pass the int as an Integer.

  • How to use one af:query for multiple VOs

    Hi all,
    How can we use an af:query component to query on multiple VOs?
    Think of a page with search area and a tabbed pannel with two tables based on different view objects.
    Any ideas?
    Thanks
    Version
    ADF Business Components 11.1.1.56.60
    Java(TM) Platform 1.6.0_18
    Oracle IDE 11.1.1.3.37.56.60
    Edited by: Barbara Gelabert on 28-dic-2010 6:55

    Hi Santosh,
    Not yet implemented, but I was thinking on overriding the query listener and creating a view critera on the second view object as a copy of the first one. That involves capturing operands, operators and values set and then applying the criteria and executing the query.
    Anyway, in case you don't need complex operators in the search area but can add them as where clauses to the query statement, you can use search forms instead of query components as Shay Shmeltzer suggests in [url http://blogs.oracle.com/shay/2010/12/combining_multiple_queries_and.html?goback=.gde_1002457_news_308820955]his post.
    Regards,
    Barbara

  • How to use this sql query in oracle?

    Hi all,
    i am using one sql query that is
    SELECT @ToDate = '2012-10-03 00:00:00.000'
    select @BetweenDate = DATEADD(MM,-1,@ToDate)
    select @FromDate = DATEADD(m,DATEDIFF(m,0,@BetweenDate),0)
    SELECT @ToDate = DATEADD(month, ((YEAR(@BetweenDate) - 1900) * 12) + MONTH(@BetweenDate), -1)
    so @todate value is = '2012-10-03 00:00:00.000'
    so in @betweendate value will come 1 month before like '2012-09-03 00:00:00.000'
    again in @fromdate value will come like that '2012-09-01 00:00:00.000' means first date of @betweendate
    and again @todate value will come like that '2012-09-30 00:00:00.000' means last date of @betweendate
    it's happening in sql and i have to use same logic in oracle also.
    how to use it??
    thanks

    declare
    todate date:= to_date('2012-10-03 00:00:00','yyyy-mm-dd hh:mi:ss');
    betwendate date := add_months(todate,-1);
    for datediff / additions you can direct subtract/add two different date variables
    like
    datediff = betweendate -todate
    dateadd := todate+1;

  • How to use dynamic select query which queries from 3 different table.

    Hi All,
    I am new to Toplink, i would like to use a named query to select some of the columns from 3 different tables with dynamic where clause.
    I have used the following lines. Please tell me how to get code for the dynamic where clause.
    First try :
    Vector objPersons = (Vector)session.executeQuery("findPersonByGlobalID",Person.class,vQueryArguments);
    The above method is not returning the vector or collection.
    Second Try:
    ReadAllQuery query = new ReadAllQuery(Person.class);
    query.useCollectionClass(LinkedList.class);
    LinkedList person = (LinkedList) session.executeQuery(query);
    The second try is returning the collection but, this fetches all the record from the table.
    1. How to query for range of records?
    2. How to query from multiple tables for some range. How to use dynamic range values ?
    Please reply with your answers or some pointers would help.
    Thanks and Regards,
    Vijay.B

    Hi,
    Did you try using a SQLCall ? It might be able to satisfy you requirements .. :-
    Employee employee = (Employee) session.executeSelectingCall(
        new SQLCall("SELECT * FROM EMPLOYEE WHERE EMP_ID = 44")
    );You can get more information here :-
    http://www.oracle.com/technology/products/ias/toplink/doc/1013/MAIN/_html/qrybas004.htm
    Regards,
    Sandeep

  • How to use "%CT" in Query Designer

    Hello everyone,
    i read that to calculate "Percentage Share of Result" in Query Designer we can use "%CT operator".
    But in my Query Designer (Version 7.10, SP10, Patch1) only "%" and "%A" are available to use. There ist no operator named "%CT".
    Can someone tell me how to use this operator?
    Thanks a lot and best regards,
    Susanne

    Hi,
    In the % Functions in a Formula you can find %, %A, %CT, %GT, %RT all 5 of them .
    My BW system is at Following Upgrade level:
    Software Component    Release    Level    Highest Support
    SAP_BW                701       0007            SAPKW70107
    If at a lower upgrade level, you need to upgrade till Specified BW Release to view these Fxn.
    You can check yours at System (Top of the window) --> Status . Click the Icon of magnifying glass named Componenet Info to view yours.
    Regards
    Raj Rai

  • How to use variant in Query broadcasting?

    Hi,gurus here,we need to distribute report based on query daily to users.
    We hope the required-entry variable of query can be filled according logic such as curren day,curren month,etc. automatically.
    In General Precaculation tab of Setting new setting we can see 2 methods of Variable Assignment:
    Determine here
    Determine from variants
    Apparently Determine here can just distribute query report based on fix value, it does not serve our purpose.
    But in Determine from Variants,we can see nothing from Variant list(Just the first select value which is No Selection Possible). We also tried to define a variants in analyzer,but we can not see the variant here.
    So how to use it to serve our purpose of distribute query report to users daily with automatic required-entry value filled?

    Hi,
    Please refer the article from the below link, it contains all the steps and will erase all your doubts -
    [http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/9075b11a-6e43-2c10-b7be-cfa0e97ec0cc?QuickLink=index&overridelayout=true]
    Hope this helps.
    Regards,
    RahulM

  • How to use same RESULT SET for two different events

    hello friends,
    I need to use same result set for two different events. How to do it.
    here My code,
    private void jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {
    // TODO add your handling code here:
    try
    String selstate,selitem;
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:tourismdatasource","sa","");
    selstate="select * from tab_places where state=?";
    PreparedStatement ps=con.prepareStatement(selstate);
    ps.setString(1, jComboBox1.getSelectedItem().toString().trim());
    ResultSet rs=ps.executeQuery();
    if(rs.next())
    jTextField1.setText(rs.getString("place_ID"));
    jTextField2.setText(rs.getString("place_name"));
    jTextField3.setText(rs.getString("category"));
    byte[] ba;
    ba=rs.getBytes("image");
    ImageIcon ic = new ImageIcon(ba);
    jLabel6.setIcon(ic);
    in=true;
    catch(ClassNotFoundException cfe){JOptionPane.showMessageDialog(null, cfe.getMessage());}
    catch(SQLException sqe){JOptionPane.showMessageDialog(null,sqe.getMessage());}
    Now i need the same Result Set(rs), in another event(jButton6ActionPerformed),
    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
    }  how do i get dat resultset,
    help me out

    One post wasn't enough?
    {color:0000ff}http://forum.java.sun.com/thread.jspa?threadID=5246634{color}
    db

  • How to use ROWNUM in query

    There are 1000 records in the employee table.I need to display 50 records each time by the order of the employees' names. In order to get the employee records from the 51st to the 100nd in the table, I tried to use ROWNUM.
    However, the following query doesn't do the job:
    select first_name, last_name from employee where rownum < 101 and rownum >49 order by last_name, first_name
    I currently use the following query:
    select * from (
    (select first_name, last_name from employee where rownum < 101 order by last_name, first_name)
    Minus
    (select first_name, last_name from employee where rownum < 50 order by last_name, first_name )
    ) order by 2,1
    The query works but is quite complictated. I would like to know if there a simpler way to do so.
    Thanks in advance.
    Helena

    The generally preferred query is something along the lines of
    SELECT *
      FROM ( SELECT a.*, rownum rn
               FROM (<<your query>>) a
              WHERE rownum <= <<MAX VALUE>>)
    WHERE rn >= <<MIN VALUE>><<your query>> here would be
    SELECT first_name, last_name
      FROM employee
    ORDER BY first_name, last_nameNote that if you wanted to use the MINUS construct, you would generally need to move the rownum clause outside the query that is doing the ORDER BY. The query
    SELECT first_name, last_name
      FROM employee
    WHERE rownum < 101
    ORDER BY first_name, last_namefetches the first 100 rows and then orders them, which is not generally what you want.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to use SAP BEX query Free characteristics in BO Universe?

    Folks,
    I have a BEX query which has lots of objects listed under free characteristics.
    When I create a Universe these objects are not brought in the Universe.
    Is there any way to bring those objects into our Universe?
    Thanks
    Bashir

    Hi,
    take a look here:
    /people/ingo.hilgefort/blog/2008/03/24/businessobjects-and-sap-part-5
    Ingo

  • Querying the data type of objects in an Array?

    I'm able to determine that an argument is an Array using the following query:
    SELECT DATA_TYPE
    FROM all_arguments
    WHERE OBJECT_NAME = 'MY_PROCEDURE' AND ARGUMENT_NAME = 'MY_ARRAY_PARAM'
    DATA_TYPE will be 'PL/SQL TABLE' if the argument/parameter is an array.
    My question is: Is there a way to query what the type of the objects in the array should be? Like NVARCHAR2, VARCHAR2, RAW, DECIMAL, etc.
    Any help is very appreciated!

    I guess the part I'm having trouble with is when the
    Array is defined in a package because the type
    doesn't get listed in "all_coll_types". well, the workaround here would be - the parsing of PACKAGE text - and finding your needed type of array:
    SQL> create or replace package TEST_PACK as
      2          TYPE test_type is table of varchar2(100);
      3   end test_pack;
      4  /
    Package created
    SQL>
    SQL> create or replace package body TEST_PACK as
      2    vc_array test_type;
      3    begin
      4     null;
      5    end;
      6  /
    Package body created
    SQL>
    SQL> select * from user_source t
      2   where name = 'TEST_PACK'
      3  /
    NAME                           TYPE               LINE TEXT
    TEST_PACK                      PACKAGE               1 package TEST_PACK as
    TEST_PACK                      PACKAGE               2         TYPE test_type is table of varchar2(100);
    TEST_PACK                      PACKAGE               3  end test_pack;
    TEST_PACK                      PACKAGE BODY          1 package body TEST_PACK as
    TEST_PACK                      PACKAGE BODY          2   vc_array test_type;
    TEST_PACK                      PACKAGE BODY          3   begin
    TEST_PACK                      PACKAGE BODY          4    null;
    TEST_PACK                      PACKAGE BODY          5   end;
    8 rows selected
    SQL>

  • How to use one Bex Variable for two purposes in one query?

    Hi,
    I want to prompt for a UOM in a query. Then I want to use that one UOM variable to do 2 tasks in the query:
    1. Perform a UOM conversion on one restricted key figure (no filtering)
    2. Filter in a second restricted key figure (no conversion)
    How would I use a variable (or two?) to do this? I do not want to have 2 UOM prompts.
    Thanks!
    Gregg

    Oh, it all seems so easy now!  Hindsight 20-20...
    Solution was to create a new input ready variable for Unit.
    1. Restrict the key figures which need restricting using new variable
    2. For conversions, in BI backend us T-code RSUOM and create new conversion type associated with new variable. Then for each key figure needing conversion, set the conversion parameter to use the new conversion type.
    Between both 1 & 2 above, the same variable is used & thus prompted only once.
    Solution works perfectly.... as it should. Hope this helps someone else!

Maybe you are looking for

  • Purchased movie on iPad cannot be transferred?

    Help! I have an iphone, ipad and imac (I am FRUIT).  Most of my stuff is now in the icloud however I haven't yet synced my ipad because it has purchased movies on there from an old Apple ID (pre-marriage email change).  How can I get these movies fro

  • Error using WS-Addressing during asynchronous callback

    I am using the BPEL PM (10.1.2) to call an asynchronous service, but I am not receiving the callback. This is the SOAP request message: <?xml version="1.0"?> <soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/

  • Is this possible on my MacBook

    Sorry for the cryptic subject line but I wasn't sure how to phrase my problem. I have an old iMac that has a broken CD drive. I would like to do a clean install of OS Panther on it. Can I hook up an external firewire drive to my Macbook, restart usin

  • Why will my apps have to be deleted to change mys ettings?

    every time i try to change the settings on how i manage my music or videos on my ipad2 a message pops up saying all my apps and data will be deleted. will it really delete everything, i dont want to find out the hard way

  • Why does my Macbook Pro use so much power in sleep?

    Hi everyone, forum newbie here My mid 2010 Macbook Pro (13.3" C2D 2.66ghz, 4GB etc) uses a lot of energy during sleep It drains between 2-5% per hour, which believe me is a lot. My battery lasts anything from 3-4 hours to 8 ish if I'm using it very l