BC4J: Adding a row to a ViewObject with two underlying entities?

In the database we have two tables (Table_1 and Table_2), both with primary key IDs that are a DBSequence. The table_2 has a foreign key to table_1, with a one-to-one relationship. Here is an illustration:
Table_1 Table_2
table_1_id pk table_2_id pk
col_1 table_1_id fk
col_2 col_1
col_3 col_2
etc etc
We created an entity for each of these tables (Entity_1, and Entity_2). With an association between them.
We want the user to think they are doing add/view/edit/delete a single logical record (composed of these two entities) so we created a view object that contains these two entities using the association.
With the view object, we have no trouble doing view/edit/delete since BC4J manages the primary key of both entities.
The problem is the add on the view object. BC4J handles the primary keys not problem, it is the foreign key from table_2 back to table_1. BC4J does not set the foreign key for me, and I get a SQL exception that the foreign key is null.
How would you suggest solving this?
Thanks in advance.

We want the user to think they are doing add/view/edit/delete a single logical record (composed of these two entities) so we created a view object that contains these two entities using the association.
With the view object, we have no trouble doing view/edit/delete since BC4J manages the primary key of both entities.
The problem is the add on the view object. BC4J handles the primary keys not problem, it is the foreign key from table_2 back to table_1. BC4J does not set the foreign key for me, and I get a SQL exception that the foreign key is null.Override create() method in the ViewRowImpl subclass for that ViewObject and after super.create(), set the FK from the master entity into the detail. Here's the pesudo code :
create method()
super.create...
MasterEntityImpl master = this.getMasterEntity();
DetailEntityImpl detail = this.getDetailEntity();
//if you have multi-attr (composite) PK/FK you need to fill in all the parts.
detail.setFKAttr(master.getPKAttr());
Note this is not done automatically for a 1-1 case where both entities are joined in a VO as is your case. Automatic FK population is done via ViewLinks and you cannot use that as your case uses a single VO.

Similar Messages

  • Add another Employee row on a  ViewObject with Dept/Employee Entites

    I have a ViewObject with Dept and Employee Entities, both updateable.
    Is it possible to create a new Employee but the same department using that Viewobject?

    I tried doing this:
    I got the viewRow of the ViewObject and then get the department's rowiterator that contains the employees; When I get the rowIterator, i inserted a blank row and then I re-executed the query. See the following code below:
    DemptEmployeeVieObjectRowImpl viewRow =  (DeptEmployeeViewObjectRowImpl)getCurrentRow();
    DepartmentEntity department = viewRow.getDepartmentEntity();
    EmployeeEntity employees = viewRow.getEmployee();
    //getEmployees() returns the employees that are included in the department
    RowIterator rowIterator = department.getEmployees();
    Row newRow = rowIterator.createAndInitRow(employees);
    rowIterator.insertRow(newRow);
    getViewObject().setQueryMode(ViewObject.QUERY_MODE_SCAN_ENTITY_ROWS);
    getViewObject().executeQuery();But the problem is when I set the query mode to SCAN_ENTITY_ROWS, and the re-execute the query, it creates a new record of the ViewObject including the Department row, which I dont want to do.
    Why is it creating a department row when i just created a row in the rowIterator?
    In the first place, Is it possible to create a new employee only, assign it to an existing department using a DeptEmployeeViewObject?

  • Viewobject with two criteria and two af:query

    hi every body
    jdeveloper 1.1.6
    i have a viewobject with two criteria , and in view controller i have af:query for each viewobject criteria , what i want when i click on Search button on one of any af:query ,is to Execute the query of another af:query beside the clicked af:query.
    thanks in advance
    maher

    maher,
    I don't understand your use case. If you oly use one VO which has two VC where each VC is mapped to an af:query on the page, it doesn't make sense to execute both of them together. If you do this the resutl set from the first query would be overwritten by the second query.
    Or do you just want to 'and' the two VC into one query and get the result as select ! from table where (vc1) and (vc2)?
    Timo

  • Adding/deleting rows from a treeTable with a read-only view object

    Hello --
    I'm getting a JBO-25016 error when I go to delete a row from a treeTable. I want to create the hierarchy from a stored procedure, have the user add and remove nodes without calling back to the database. I will iterate through the tree and see what has changed and made the necessary updates on the database manually.
    What is the correct method for adding/removing rows form the UI component?
    Thanks!
    Tom

    Thank you, Amit! That did the trick.
    Edited by: Tom on Apr 28, 2011 11:51 AM

  • Adding a row to a table with a button

    Good day all;
    I think I have now lost it... ;>))
    LifeCycle Designer 8.05
    Anyway, If the user of the form requires additional rows to enter infoamtion, I want them to be able to add a row using a button. I have tried using the following
    Table"N".Row2.instanceManager.addInstance(1); ="N" is the table name.
    I have done this on a couple of other forms but I must be missing something as I am geting the following error in the java Consol
    "GeneralError: Operation failed.
    XFAObject.addInstance:1:XFA:form1[0]:#subform[0]:#subform[1]:Button1[0]:click
    The element [max] has violated its allowable number of occurrences."
    The form is saves as a Arcobat 8 Dynamic XML form
    I
    Page 1 is flowed
    Subform is flowed
    Would someone be so kind as to point me in the right direction.
    Thanks all
    Chomp

    Thanks Radzmar;
    You were correct.... It appears I was only looking at the bindings for the damn table not the row.......
    Thanks again

  • Problem using ViewObject with bc4j:table

    Hello !!
    This is the query of my ViewObject:
    select * from speiseplan order by jahr desc, kw desc;
    and everything works fine in the BC4J tester:
    jahr kw
    2003 52
    2003 7
    2003 3
    2002 51
    But in my uix page the rows are not correctly sorted:
    jahr kw
    2003 3
    2003 7
    2003 52
    2002 51
    What's going wrong here?
    Thanks for your help.
    Regards,
    Mareike

    Duplicate post.
    Original problem using ViewObject with <bc4j:table>

  • ViewObject with rows not based on a query

    Hello,
    I have an ViewObject with rows not based on a query. For example, if in activate method from my application module I insert a row, that row will not show when I test my app module. Please do not answer with a link for SRDemo ADF+BC as i've read it and didn't find any answers there.

    Yes,thanks, I found that, but I don't know how to do a ViewLink that have as destination a viewobject like that. I get all rows from destination for any row from source. There is a way to do that?

  • How to get current row of Advanced table with no submit

    I have an advanced table with an 'Add another button'. When an empty row is created by clicking this button, LOV is used on the first column to populate other fields of the row. The rows of the table carry a button called "Add dependencies" whose functionality is to take the user to a different table to add rows to a different VO. This button is just a button and not a submitButton. I am passing the row's primary key as part of the URI as Vo attribute FdTaskId={@FdTaskId}
    The button works perfectly fine for database fetched rows (rows already present in the database), but, for the rows created using 'Add Another button', though LOV populates all fields including the primary key, the URI parameter passes null to the next page. That means, the VO attribute is not set. This works fine only when a 'submit' happens in the first page. For example, if I click Add another row again, then the previously inserted row passes the primary key fine as part of {@FdTaskId}.
    Could you please help me how I can resolve this issue?
    Thanks,
    Datta

    I am doing exactly that. My issues is that, VO attribute is passed correct for the table rows which are fetched from the database. For the table rows which got created through 'Add Another button', the VO attribute passed through URI as {@FdTaskId} is returning null. The VO attribute sets only when a form submit happens. For example, after adding a row through 'Add another row' button, click the same button again to add one more row and now go back to previously added row and now you can see that its VO attribute is set ({@FdTaskId} carries value )

  • Can Shuttles be based non-base  table ViewObjects with transient attributes

    Hello,
    Users have to select records from a data collection and a Shuttle looks most appropriate/nice for this purpose. We can introduce technical intersection tables in order to generate the Shuttles with JHeadstart 10g R3 if necessary, but there is no “functional” need to update any data in the database and therefore it would be practical if the ‘right’ side from a Shuttle can be based non-base table ViewObjects with transient attributes only. So, our interested is to know which records have been selected, i.e. moved to the right side from the Shuttle.
    Hope that my question is clear enough.
    Greetings,
    Michael

    Michael,
    This cannot be generated out-of-the-box.
    It is easiest to add the shuttle post-generation to your page, and then create a custom template to generate your custom shuttle into the page. I suggest you take a look at an example of a generated shuttle in a page, and the JHeadstart IntersectionShuttleBean class. You will see that the value property of <af:selectManyShuttle> points to the selectedKeys method in the JHeadstart Shuttle bean. In your case, you can create your own managed bean and bind the value property to your own method which will provide you access to the selected rows. The value property of the selectItem within the af:selectManyShuttle determines the property that is used to identify the selected row (which is the row key in case of Jhs-generated shuttles).
    Steven Davelaar,
    JHeadstart Team.

  • Adding/removing rows in TABLEVIEW

    Hi. I've got a TABLEVIEW in one of my subscreens. But when load itab into that tableview with 'LOOP AT...'  tableview appears but I can't add rows to it. I can't delete existing rows too. What should I add to my programm to have possibility of adding/removing rows from my tablewiev? Greetings. P.

    Hi Friend,
    To add/delete rows in your table view.
    You have to add/delete rows from internal table fro where you are displaying values.
    You have to write code in PAI..
    In LOOP ... ENDLOOP check the OK_CODE if it is ADD (for eg.) you have to add a blank row to internal table by just passing a blank work area.
    And if it is DELETE (for eg.) delete the row of that index (TABLEVIEW-CURRENT_LINE)...
    for these two excersies you have to readjust lines of tableview...after taking number of lines from internal table (DESCRIBE TABLE INT_EX LINES WS_LINES
    TABLEVIEW-LINES = WS_LINES) write this piece of code in Intialization.
    Hope it will solve the problem.
    Regards
    Krishnendu

  • Adding a Row to Table, ComboBox as a  TableCellRenderer Problem !!

    Hell All:
    I have a JTable with one of the Cell as ComboBox. Initially I draw the JTable with Three Rows and the
    the ComboBox in the Second Column works fine. I see each comboBox has different Items. The ComboBox also has a Renderer (as I am customizing the Item's Text )
    Here is the snippet from my Code.
    ==========================
    // UIEditSubAllocation.ALT_ACCOUNT = 2;
    // Get the Viewindex.... to get the correct column
    int viewIndex = this.m_suballocTable.convertColumnIndexToView(UIEditSubAllocation.ALT_ACCOUNT);
    // get the Table Column...
    TableColumn altActColumn = this.m_suballocTable.getColumnModel().getColumn(UIEditSubAllocation.ALT_ACCOUNT);
    // Create Three ComboBox..
    JComboBox[] altActCell = new JComboBox[3];
    for (int i =0;i< 3;++i) // adding Three Rows of Table Data...
    String [] alternateAccounts = new String[4];
    for(int j = 0; j < alternateAccounts.length; j++) // Each Alternate Accounts i.e combobox has 4 items..
    alternateAccounts[0] = "Tom";
    alternateAccounts[0] = "Vic";
    alternateAccounts[0] = "Tracy";
    alternateAccounts[0] = "Andy";
    altActCell[i] = new AltAccountComboBox(alternateAccounts,this.m_suballocTable);
    } // End of adding Three Rows
    altActColumn.setCellRenderer(new AltAccountTableCellRenderer());
    if (viewIndex >= 0)
    ComboBoxEditor altActCellEditor = new ComboBoxEditor(altActCell);
    altActColumn.setCellEditor(altActCellEditor);
    The CombBoxEditor code is...
    ublic class ComboBoxEditor extends DefaultCellEditor
    * Constructs a ComboBoxEditor that uses an array of items of type object.
    * @param items - an array of items of type object
    public JComboBox[] m_comboBox;
    public ComboBoxEditor(JComboBox[] box)
    super(box[0]);
    m_comboBox = box;
    for(int i = 0; i < box.length; i++)
    m_comboBox.setEditable(false);
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
    if(row >= this.m_comboBox.length)
    return super.getTableCellEditorComponent(table, value, isSelected, row, column);
    return m_comboBox[row];
    But when I click a Button (in a Panel) which adds a Row (with No values for the ComboBox ).. to the Jtable .. The Row Gets added fine.. but the JComboBox comes with Values from the First Row's ComboBox. I Don't want any Values in the JComboBox for the new added Row. Can someone tell me
    how do I remove the Items from the ComboBox.
    I will really appreciate for any help...
    Thanks
    -Pankaj

    Hi ,
    as per my opinion one approach would be that ,
    you create a custom table region same as standard one using Jdeveloper and create other required fields also using jeveloper ,and then put this region in extend property of existing standard table region .
    thanks
    Pratap

  • Can iOS Numbers copy formulas when adding new rows?

    iOS Numbers table add row is not copying previous cell formulas. Is this supported or not?
    I have a table with lots of columns and all of them have formulas. When I click at the lower left of the table to add a row, none of the new cells have the formulas. I have to manually go through every column and copy the formulas to the new row.
    This is not very practical if you're planning to use Numbers on the go with an iPad. In my case, I have to quickly get a new row ready as needed. I was hoping there is a preference setting somewhere like "copy formulas when adding new row".

    I had the same issue with the added twist that I wanted to reference the created cells in formulas in other sheets. This is what works for me:
    I use a form to enter data. The referenced sheet is set up like this:
    1     Name     Date     ServPayment    SalesPayment     Total
    2     Week1                                                                 =sum (ServPayment,SalesPayment)
    3                                                                                =sum (ServPayment,SalesPayment)
    4     TotWeek1                                                            =sum (Total2,Total3)
    "Total" sums the 2 Payments, TotWeek1 sums the totals.
    In the entry form I never add data to the empty line. In this example, I would start at "Week1" and tap the "+" to add a new form. This creates the line in the referenced sheet with my formulas. As I continue, I always start at the last entry I have made and tap "+".
    When I create a line that does not have the formula on either side, I do not get the formula.
    Hope this helps.

  • Null Pointer Exception When Adding New Row on Table

    Hello JheadStart Team
    I have used detail group with table layout , when I am clicking on AddRow button on detail table , I encounter NulllPointer Exception . I have traced the code and fount that in JhsCollectionModel when adding new row following
    condition occurs :
    DCIteratorBinding ib = getRangeBinding().getIteratorBinding();
    int rangeSize = ib.getRangeSize();
    int rowsInRange = ib.getAllRowsInRange().length;
    because getAllRowsInRange is Null then the error raise.
    My JheadStart ver is 10.1.3.3.85 .
    Detail Group with table layout setting is :
    Use Table range=true
    Show New Row at top=true
    New Rows:empty
    Show Add New Row Button :true
    Regards

    Given the build you are using, I assume you are an Oracle employee.
    Is this correct? if so, please post your question to the [email protected] mailing list.
    Steven Davelaar,
    JHeadstart team.

  • How to refresh the grid so that default  values come on adding new row.

    Hi Experts,
    In alv grid while adding new row, i want some 2-3 column values to come by default from already existing row in grid.
    i am getting new row in internal table with 2-3 default values and rest columns blank on adding new row in alv grid
    but the entire row is coming blank, not able to get the default values in new row
    how can i refresh the grid so that default  values come on adding new row.
    thanks

    Hi Surabhi,
    Use this in Interactive section even if you are doing simple ALV.
    DATA:
    lv_ref_grid TYPE REF TO cl_gui_alv_grid.
    CLEAR : gv_tcode.
    *-- to ensure that only new processed data is displayed
    IF lv_ref_grid IS INITIAL.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
    e_grid = lv_ref_grid.
    ENDIF.
    IF NOT lv_ref_grid IS INITIAL.
    CALL METHOD lv_ref_grid->check_changed_data.
    ENDIF.
    THis will solve your problem.
    Regards,
    Vijay

  • Generating Indiex for dynamically added table rows  in HRFORMS

    Hi ,
    We are developing Payslip  in HRFORMS by copying standard form.
    We have got one business scenario which requires a table rows needs to generated dynamically to populate the retro values in the form.
    We could able to generate the table rows dynamically by below command in HRFORMs scripts.
    Table1.Row.InstanceManager.addInstance(1) but it is not generating with correct index.
    Please help in adding table rows dynamically at specified index.
    Regards,
    akula

    You can do that with 2 differents ways :
    by creating a colomn key which is the concatenation of the key for each lin
    by using field groups
    I think you have to use the second one.
    [sample by help|http://help.sap.com/saphelp_nw70/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm]
    In this case you can put dynamiquely what are you wanted in your keys.
    Regards,
    Christophe.

Maybe you are looking for

  • HP Smart Web Printing Select Button does not appear

    Just started to use Smart Web Printing. The Select Button as shown in the help file does not appear on the screen. Instead, a small box "x Select area to remove" shows within the area to print. Printer: HP Photosmart C6380 System: Windows Vista SP2 H

  • Wireless fails after 1 minute

    MSI Wind with rtl8187se (name of module and wireless hardware) and using wpa-psk.  New installation of arch.  Wireless works fine for 1-2 minutes then fails (can't get any response pinging google or pointing elinks to google, etc). What I'm doing: ba

  • Trying to restore my macbook air but got no recovery hard drive.

    Trying to restore my macbook air to factory setting, but got no recovery hard drive ?

  • E71 hanging - Menu function does not work

    I bought an E71 from the Nokia store 4 weeks ago and have had it replaced thrice already. The phone suddenly hangs and the Menu key stops working. At the same time it also stops automatic retrieval of email. Other dedicated keys work. The Nokia store

  • Wish list redeaux

    This has been mentioned before, very early after the conversion, but I thought I'd toss it out again, just so Sonya and her team might take note of it. In the old software, the thread listing (the "Contents" tab of a "space", in this version) include