How to update the foreign key in a 1-to-many relation ?

I have Product mapped to Channel as 1-1, and Channel mapped to Product as 1-M. Product has a nullable channel_id_fk as a foreign key to Channel, (so one can optionally specify or change the channel of a specific product).
Starting with a specific product with a null channel_id_fk, I
1) add this product to a channel (with a vector of products via ValueHolderInterface);
2) set the channel of this product; and
3) update the channel in a unit-of-work.
The product.channel_id_fk doesn't get updated in db.
I tried setting each side of the relation as read-only, but still it doesn't work.
What am I missing ?
(I am using toplink 9.0.4)

More info:
1) There is only a single uow involved, so there is no nested transaction.
2) I tried checking the "target foriegn key" in the 1-1 mapping from Product to Channel, but this resulted in a exception thrown during runtime when the channel is accessed from the product:
Local Exception Stack:
Exception [TOPLINK-6094] (OracleAS TopLink - 10g (9.0.4) (Build 031126)): oracle.toplink.exceptions.QueryException
Exception Description: The parameter name [AFFINITY_CHANNEL_ID_FK] in the query's selection criteria does not match any parameter name defined in the query.
Query: ReadObjectQuery(au.com.agl.application.scorecard.AffinityChannel)
     at oracle.toplink.exceptions.QueryException.parameterNameMismatch(QueryException.java:658)
     at oracle.toplink.internal.expressions.ParameterExpression.getValue(ParameterExpression.java:149)
     at oracle.toplink.queryframework.SQLCall.translate(SQLCall.java:334)
     at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(CallQueryMechanism.java:129)
     at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(CallQueryMechanism.java:111)
     at oracle.toplink.internal.queryframework.CallQueryMechanism.selectOneRow(CallQueryMechanism.java:584)
     at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectOneRowFromTable(ExpressionQueryMechanism.java:792)
     at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectOneRow(ExpressionQueryMechanism.java:763)
     at oracle.toplink.queryframework.ReadObjectQuery.execute(ReadObjectQuery.java:340)
     at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:498)
     at oracle.toplink.queryframework.ReadQuery.execute(ReadQuery.java:111)
     at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:1968)
     at oracle.toplink.threetier.ServerSession.internalExecuteQuery(ServerSession.java:629)
     at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1096)
     at oracle.toplink.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:52)
     at oracle.toplink.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:63)
     at au.com.agl.application.scorecard.ProductDetails.getExclusiveAffinityChannel(ProductDetails.java:69)
....

Similar Messages

  • How to retrieve the Foreign key information in Oracle

    I want to know how to retrieve the Foreign Key information in Oracle while using SQL Statement?
    I have use three SQL statement to retrieve such information, but the performance is very bad.
    The three SQL Statements are:
    Select constraint_name, r_constraint_name from all_constraints where constraint_type = 'R' and table_name = table1;
    Select column_name from all_cons_columns where constraint_name = cons1;
    Select table_name, column_name from all_cons_columns where constraint_name = r_ccons1;
    Do anyone know another method to retrieve the Foreign Key information which has better performance?

    These sql-statements don't seem very performance intensive. My guess is something is wrong with your database (unless you have millions of constraints). How many constraints do you have? how many concurrent users? What is your dictionary cach hitratio? (other hitratio?) memory problems? other tasks of the computer? is this query the only one being slow? etc.

  • How to customize the foreign key constraint exception

    Hi All,
    I have two table, A and B.
    B.ref is foreign key references to A.id in database.
    Now I want to delete a row of table A in screen, error messages are :
    "Constraint "xxx.xxxx_S_FK1" is violated during post operation "Delete" using SQL statement "DELETE FROM xxxxxx WHERE xxxxxxxxx" and "ORA-02292: integrity constraint (xxx.xxxx_S_FK1) violated - child record found"
    How do I customize this error message? Is it possible to do it in EO Validation?
    Thank you!

    You can override the DoDML() method in EntityImpl something like follows
    @Override
    protected void doDML(int i, TransactionEvent transactionEvent) {
    try
    super.doDML(i, transactionEvent);
    catch(DMLConstraintException _ex) {
    if(_ex.getErrorCode().equals("26048") ) {
    // handle your exception
    sid

  • Disable all the foreign keys in a database

    Hy, what sql to use to disable all the foreign keys in a database and how to enable all them again. Thanks

    select * from dba_constraints where constraint_type = 'R' and status = 'ENABLED'
    ALTER TABLE table_name
    disable CONSTRAINT constraint_name;
    ALTER TABLE table_name
    enable CONSTRAINT constraint_name;
    select
    'ALTER TABLE ' || OWNER || '.' || table_name || ' enable CONSTRAINT ' || constraint_name || ';'
    from dba_constraints where constraint_type = 'R' and status = 'ENABLED';
    Execute and save result for enable before disable
    select
    'ALTER TABLE ' || OWNER || '.' || table_name || ' disable CONSTRAINT ' || constraint_name || ';'
    from dba_constraints where constraint_type = 'R' and status = 'ENABLED';
    Execute result for disable.

  • SSAS 2008 Linking two cubes on the foreign key between two fact tables

    Hi, all -- 
    I have two cubes:
    Cube 1 has Fact1 (F1, "Events") and 3 dimensions (D1, D2, D3)
    Cube 2 has Fact2 (F2, "Sales") and 3 dimensions (D4, D1, D6)
    As you can see, two cubes reuse D1 as their common dimension.  In addition, F2 foreign keys into F1, e.g. F1 is "Events", and F2 is "Sales".  Every "sale" is an "event", but not every "event" is
    a "sale".
    The question is, how to I link the two cubes and their two respective fact tables on the foreign key?
    Thanks, Austin.

    Hi Austin,
    According to your description, you want to retrieve data from two different cubes, right? In Analysis Services, to query multiple cubes from a single MDX statement you can use the LOOKUPCUBE function (you can't specify multiple cubes in your FROM statement).
    The LOOKUPCUBE function will only work on cubes that utilize the same source database as the cube on which the MDX statement is running. For the detail information about it, please refer to the link below to see the blog.
    Retrieving Data From Multiple Cubes in an MDX Query Using the Lookupcube Function
    If I have anything misunderstood, please point it out.
    Regards,
    Charlie Liao
    TechNet Community Support

  • HOWTO: get JDev to show the foreign keys in Conn Nav & struct window

    Hi,
    I have SQL tables with foreign keys but the JDev connections navigator and table editor dont show them. They just look like primary keys in the "PK" column. The structure window shows a bunch of constraints with names like "SYS_C00143114" which is not very meaningful to me. Surely JDeveloper knows what these magic numbers mean and can trace the foreign keys for me.
    How can I get JDeveloper to show the foreign keys, and which table is referenced by that foreign key? Can I make it navigate from a table's foreign key value to the the correct tuple in the referenced table?
    Maybe this is an ER if JDev doesn't do this already. Navigating a schema, or drawing it showing all the foreign key references would be very handy. Navigating through actual table data would be nice too.
    Cheers,
    Simon.

    I found "new->Database Diagram" that does a lot of what I wanted, at least in mapping out the foreign key references. Now if I can just figure out how to print a .png file...
    It would still be nice for the connection navigator to trace them also.

  • Hibernate: how to null out foreign key references when deleting an entity?

    We use Spring/Hibernate3 in our app, and ran into kind of a bummer of a problem. We have a relationship that is many-to-one (e.g. Student -> School). This is represented by a schoolId on the Student table. When we delete the school through the Hibernate layer, we are immediately receiving foreign key constraints because Hibernate does not null out the Students' schoolId columns where applicable.
    What we'd like to see happen is something like this:
    1. SchoolDAO.delete(id)
    Hibernate: UPDATE Student set schoolId = NULL where schoolId = ?
    Hibernate: DELETE from School where id = ?
    But what we're actually seeing is:
    1. SchoolDAO.delete(id)
    Hibernate: DELETE from School where id = ?
    And hence the foreign key constraints.
    Was wondering if someone else here has run into this. Someone on the Hibernate forums suggested using an Interceptor, but the Hibernate3 interceptors don't give us access to the Session to allow us to do a bulk update to null out these references. Apparently the interceptor javadoc says that the interceptor is basically there to change properties on the object in question and should not involve the session at all.
    We then looked at implementing an Event, and that worked, but was not called for every cascade deleted event. We have a lot of cascade activity in our database, so that was a little disappointing.
    We had briefly considered manually nulling out that FK in the DAO itself, but that would not work with the large amount of Hibernate driven cascade deletion that goes on in our app (Hibernate does not call our DAO every time it cascade deletes an entity).
    Would greatly appreciate any pointers on this subject. We're hoping that others have run into this as well.
    thanks.

    I'm not sure why you'd expect that given that there's
    not really an equivalent object oriented operation -
    if you want to relinquish the object in the OO scheme
    of things you have to null all the references to it;
    you can't just say "make everything that points to
    this object null".I can field that question. We came from EJB 2.x where in the event that you deleted a School entity bean using ejbRemove() you would see the following queries generated:
    UPDATE Student set schoolId = NULL where schoolId = ?
    DELETE from School where id = ?
    Basically, it would manage the relationship for you. I know it's a completely different system but we were a little surprised to learn that Hibernate did not do this on its own as well.

  • Identifying the Foreign Keys

    How can I identify the Foreign Keys in a row ???
    Regards,
    Junior

    How can I identify the Foreign Keys in a row ???Junior:
    Are you referring to FKs of a View Row involved in a View Link? If so, a View Row could have multiple FKs if it is involved in multiple View Links.
    By writing MT (middle-tier) code, you can get the attribute list from the View Link. Note that this logic is only available in MT. If you need this info in the client, you can write this logic in MT and export it as a custom method that can be called from client.
          // Get the list of view links that this VO ('vo')
          // is involved in.
          String[] vls = vo.getViewLinkNames();
          // Get the View Link object.
          ViewLink vl = myAM.findViewLink(vls[0]);
          // Get the View Link definition.
          oracle.jbo.server.AssociationDefBase vlDef = (oracle.jbo.server.AssociationDefBase)
               ((oracle.jbo.server.ViewLinkImpl) vl).getDef();
          AttributeDef[] attrs;
          // Get the source side attribute definitions
          attrs = vlDef.getAttributeDefImpls();
          for (int j = 0; j < attrs.length; j++)
             System.out.println("  Attr: " + attrs[j].getName());
          // Get the destination side attribute definitions
          attrs = vlDef.getOtherAttributeDefImpls();
          for (int j = 0; j < attrs.length; j++)
             System.out.println("  Attr: " + attrs[j].getName());

  • How to update the table value in the valuechange event?

    I have an input field in the datatable with the valueChangeListener
    <rich:dataTable id="cart" value="#{cart.cartList}" var="item">
    <h:inputText value="#{item.cost}" id="qty" valueChangeListener="#{items.updateCost}" onchange="submit()">
    <h:outputText value="#{item.errorMsg}"> </h:outputText>
    in the backing bean
         Item item = (Item) model.getRowData();
    // do some update, if the cost too larger, change to max_cost
         item.setCost(max_cost);
         item.setErrorMsg("Error Msg");
    After calling the valuechange method, the screen output doesn't update the cost.
    How to update the table value in the valuechange event?

    As you're misusing the valueChangeListener to set another input field, you need to skip the update model values phase. Otherwise the value set in the valueChangeListener will be overridden by the submitted value. You can do this by calling the FacesContext#renderResponse() inside the valueChangeListener method. This will shift the current phase immediately to the render response phase, hereby skipping the update model values and invoke application phases.

  • How to update the condition price in the sales order for all the items

    Hi,
    How to update the condition price for all the itmes in the sales order to carry out the new price automatically through a stand alone program, for all the orders in the billing due list table?
    Thanks,
    Balaram

    Hi,
    There is a change in the requirement.
    Scenario:
    I have created a sales order with some 4 condition types, in that 2 condition types are of class A & B and the other two is of class C. Here I need to update the condition price of class A & B only and the remaining condition types should not get update even though there is an updated price is available.
    For the above scenario, I need to write a standalone program. Do we have any function modules to update the price of the single condition in the sales order? Please tell me how we can update the sales order at item condition level.
    Thanks.
    Balaram

  • How to update the condition price in sales order while creating the invoice

    Hi,
    How to update the condition price in the sales order to carry out the new price while creating the invoice?
    While creating the invoice it should update the condition price in sales order.
    Thanks,
    Balaram

    No, pricing is not there in delivery.
    I found an exit for VF01transaction where we can update the price in order.
    Can you please tell me how to update the price if I have the order, material numbers and conditions number?
    Thanks,
    Balaram

  • How to update the inventory after committing order..?

    How to update the Inventory stock level of a commerce item after committing the order.. in ATG 10.0.1..?
    Thanks in Advance,
    Vishnu & Nithin Kayithi

    you can add the pipeline chain after the processOrder in the commerce pipeline , in the runProcess method call InventoryManager.decreaseStockLevel(String pId, long pNumber);

  • How to update the data in sqlserver table using procedure in biztalkserver

    Hi,
    Please can any one answer this below question
    how to update the data in sqlserver table using procedure in biztalkserver
    while am using executescalar,typedprocedure getting some warning
    Warning:The adapter failed to transmit message going to send port "SendtoSql1" with URL "mssql://nal126//MU_Stage2?". It will be retransmitted after the retry interval specified for this Send Port. Details
    Please send me asap....
    Thanks...

    Hi Messip,
    A detailed error would have helped us to answer you more appropriately but
    You can follow the post which has step by step instructions, to understand how to use Stored Procedure:
    http://tech-findings.blogspot.in/2013/07/insert-records-in-sql-server-using-wcf.html
    Maheshkumar
    S Tiwari|User
    Page|Blog|BizTalk
    2013: Inserting RawXML (Whole Incoming XML Message) in SQL database

  • How to create a Foreign key relationship between 2 user defined tables...

    Hi Folks,
    I have created two user defined tables... Where in i want to create foriegn key relationship between the 2 tables.... Can anyone guide the step by step procedure to do this scenario...
    Any help would be highly appreciated...
    Thanks

    Hi
    1.  In the 2nd table call the field of the 1st table which is a primary key.
    2.  Give the same field and dataelement name.
    3.  Select that field and then click on the foreign key field icon which is beside Search Help button.
    4. Then give short text, and the 1st table name.
    5. Then in the below box give the 2nd table name and 2nd table field name which you have called from 1st table.
    6. Then click on copy, then u will be able to see Check table name and check table field name beside foreign key table name.
    7. Then again click on copy.
    Regards
    Haritha.

  • How to update the BOX version of the Logic Pro 9 in Mountain Lion??

    Hi!
    How to update the BOX version of the Logic Pro 9 in Mountain Lion?
    For example,  if tomorrow will be new updates for Logic Pro for exapmle 9.1.8. (now I have 9.1.7) Will I not able to get it?? Now should I buy the second Logic pro??
    Recently I have got answer from App Store support:
    "Max, since you have not purchased the app in the App Store, you can't get updates directly in App Store. In this case, you will need to purchase the updated version in the App Store so you can get further updates."
    It's... I bought Logic Pro 9 + MainStage +  + +++ .... in the Apple Retail Store and what now?? Updates works perfect in Snow Leopard.
    I can't understand...
    Can you help me please? =)

    Max,
    Rest assurred, you will get updates via the App store. What will happen is when you install the box version, the Mac App Store will ping when there is an update to download(for free), much like any other Apple app(Garageband, iWork, etc) regardless of where you bought it from. If it's installed, it will check for updates.
    If the Mac App store doesn't show an update that you know is out, simply down it directly from support.apple.com and apply it.
    Hope this helps. If so, LIKE the post.
    Glenn

Maybe you are looking for

  • Ipod serverely messed up

    my ipod nano isn't recognized by windows OR itunes, so it wont charge, even with the power outlet thing. Windows says an error has occured with an unknown device (iPod). i've tried resarting, restoring, reinstalling, updating(that doesnt work at all)

  • Object_id's differs in table partions in oracle 10g.

    Can you please see the below and suggest me if this is acceptable result set.. how come object ids differs in data dictionary table from actual object ids. How do I ensure that the following query returns rows after moving partitions one table space

  • Problem with print preview in alv grid

    Hello all, I have to display base unit of measure(meins) in alv grid output. i am using a conversion routine to convert it from ST TO PC before display.After executing the report i am getting the correct data. the problem is when i select the print p

  • How to download SAP Project Templates

    Hi , where are the SAP predefined Project Templates are available. Can anybody give me the path. regards, sri

  • How can  i do exception aggregation  please give scrreenshots steps in bi-7

    how can  i do exception aggregation  please give scrreenshots steps in bi-7