Association Wizard; DB Constraints, Composition, & Cascades

A couple of clarifications please:
1. When would I want (ie 'be better off) with a composite association (fk) that is NOT in the database and only at he bc4j level.
2. If I do want the fk in the database, how can I specify (page 3 of 3 of the wizard) the cascade rules -for the database- per deletes, per updates. (Assuming that I don't set the composition checkbox on.)
2b. If I can't specify, but manually set that in the database, will the synch 'leave it alone'?
3. If I do check the Composition box, are these setting forward generated?
4. What does the 'top level container' setting do for a)bc4j and b) the database.
Thanks again
-Nat

A couple of clarifications please:
1. When would I want (ie 'be better off) with a composite association (fk) that is NOT in the database and only at he bc4j level.Composition association implies a lock, validation and post ordering amongst BC4J entities. Now you may have database constraints or not(legacy databases) to use this feature. The only feature that you may not be able to use is Cascade-delete as that assumes there's a cascade delete constraint on the FK.
2. If I do want the fk in the database, how can I specify (page 3 of 3 of the wizard) the cascade rules -for the database- per deletes, per updates. (Assuming that I don't set the composition checkbox on.) Cascade delete is only allowed during composition. Cascade update ...? is not implemented by BC4J.
2b. If I can't specify, but manually set that in the database, will the synch 'leave it alone'?I do believe so but have not tried. From what I remember (from my usages), sync feature does not update the composition flag.
3. If I do check the Composition box, are these setting forward generated?Yes if you select the cascade-delete option which generates a cascade delete constraint on the FK.
4. What does the 'top level container' setting do for a)bc4j and b) the database.This is a BC4J only option where you can selectively choose not to lock the parent when editing a child. This allows for a hierarchy of composed entities to work simultaneously on different entities on separate branches. Like say a project contains packages contains classes. Now one can work on classes in different packages and choose not to lock the whole project down, but would want to lock the pacakge.
Thanks again
-Nat

Similar Messages

  • Bug in New Association Wizard [jdev903/bc4j]

    Hi,
    in the wizard for creating a new Association between two entities, the multiplicity lacks the option '1 : 0..1'.
    As a workaround you can create the association the other way round, because '0..1 : 1' is present, but then you can't use the 'Composition Association' checkbox (the composition would end up on the wrong side).

    I've filed Bug#2657816 to track this issue. Thanks.

  • Composition Association in a region

    I have read Steve Muench blog:
    [http://one-size-doesnt-fit-all.blogspot.com/2008/05/jbo-25030-failed-to-find-or-invalidate.html|http://one-size-doesnt-fit-all.blogspot.com/2008/05/jbo-25030-failed-to-find-or-invalidate.html]
    I have a simple master-detail relation (ex: Departments and Employees). I marked the association between entities as Composition Association.
    In my AM, I have only: Employees view as a detail of Departments view.
    In my page: Departments (master one) is a form and Employees (detail one) is a table.
    If I click "New Department" button, create(AttributeList attributeList) is fired from DepartmentsEntityImpl.
    Than, when I click "New Employees" button, create(AttributeList attributeList) is fired from EmployeesEntityImpl.
    If I click Commit, 2 new records are created and everything works like a charm.
    But my problem is when Employees view is in a region (sepatrate task flow with "Share data controls with calling task flow" behavior, and no input parameters).
    I am still using the Employees view which is a child of Departments.
    The navigation works fine. Navigating different departments, always refreshes the Employees table in the region, (So master-detail relation works fine.)
    The update works fine. Change something in a Department form, than change employees records and than click Commit button - updates everything.
    BUT now, cascading insert does not work.
    If I click "New Department" button, create(AttributeList attributeList) is fired from DepartmentsEntityImpl.
    Than, when I click "New Employees" button, create(AttributeList attributeList) is fired from EmployeesEntityImpl ::
    protected void create(AttributeList attributeList) {
    super.create(attributeList);
    this.setActiveFlag("Y");
    but I never rich: this.setActiveFlag("Y") - line. The pop up error is:
    Detail entity EmployeesEntity with row key oracle.jbo.Key[-21 ] cannot find or invalidate its owning entity.
    So, when the detail-view is on the page together with a master-view, everything is OK.
    When the detail-view is in a region, insert doesn not work.
    Can the detail-view BE in a region?
    Am I doing something wrong?

    When a new row is created through the ADF data binding layer, its new row status will be "STATUS_INITIALIZED" (and it will contain the create-time defaulted values).
    In order to transition from STATUS_INITIALIZED to STATUS_NEW, some additional attribute must be set on the model.
    This will occur when you submit your changes, or when individual field values are sent to the server due to their UI component's being marked AutoSubmit=true.
    When the master row is STATUS_NEW, then a newly-created, composted child row will be able to find its parent in the cache and no error will result.
    In contrast, if at the moment of creating the detail, the master row is still STATUS_INITIALIZED, then it will not be found in the cache and you'll get the InvalidOwnerException.
    In the case of separate regions, you might experiment with setting the skipValidation property on the pageDefinition to "skipDataControls" to avoid causing model-layer validation to occur on items that are not part of that region's page definition.

  • Populate PK(DBSequence) in three related tables with master detail association

    Hi
    I use jdeveloper 11.1.1.6.0.
    My English isn't very good.
    I have 3 tables with master detail association between them and primary key from table A should populate to tables B and finally C .The primary key is a sequence from data base and I set PK attribute in table A as a DBSequence. (table C is the child of table B  and table B is the child of table A)
    My association is like this: A->B(BAFk1Assoc) and B ->C(CBFk1Assoc)  and also I select Composition Association for these two association. And I select ‘Cascade Update Key Attribute’
    When I insert row in these three related tables, a negative number create but when I COMMIT the PK populate only to table B not to table C and the exception below raises:
    Constraint "C_B_FK1" is violated during post operation "Insert"
    ORA-02291: integrity constraint (HR.C_B_FK1) violated - parent key not found.
    If I only work with tables A and B, there isn't any problem but if I add table C as the child of B, this exception raises.
    Habib

    The question is how you create the row for table C. Do you create it as child from table b (using the VO for B and using the link to C)?
    In this case the framework should populate the PK of the master row B as FK in table C.
    You may need to control the order in which the rows are posted to the DB to avoid this problem. Read Advanced Entity Object Techniques - 11g Release 1 (11.1.1.6.0) to get more info about this.
    However, sometimes it's easier to control the generation and setting if the PK attributes in the model layer, not relating on db triggers where you get the real values only after the commit operation is done in the db. For this you can use a Groovy expression so you have access to the PK of each new created row right after creation. Read Using Groovy Expression to set a Primary Key with a Sequence Number | JDev & ADF Goodies to find out how to do this.
    Timo

  • Insert master and detail rows with Composition assoc generating JBO-26048

    I have the Master and Detail Entity Objects and made an Association linking them as Composition related.
    I have 2 ViewObjects. the MasterViewObject is composed of the Master entity object and 1 other udpateable object. the DetailViewObejct only contains the Detail entity Object.
    I tried to create a row on the masterviewobject and then immeidately create a detail row, and then commit, ADF issues a JBO-26048 error. Constraint "MY_FK" violated during post operation.... ".
    I don't know wahts wrong, but this should not be error should nit be appearing, as ViewObjects and the Links with Composition Association take care of populating the Foreign Keys of the detail. Or am I missing something here?

    The ADF Guide covers this problem, and I have a method that works as well on jdevguru.com. Take a look at the manual first, they have an indepth view on it and how to get it all to work together.
    Kelly

  • Delete entity that participate in many to many association

    Hi all,
    I have two tables related by a many to many relationship (for ex department and employee).
    So I have three tables:
    Department: table of departments
    Employee: table employees
    deptEmp: the association table relating the employees to the departments.
    When a department is deleted, all the corresponding rows in deptEmp table should also be deleted (and same for employee).
    On the entity level, I have created the many to many association (between department and employee) and a one to many association for each of department and employee entities to deptEmp entity (deptEmptAssoc from department to deptEmp and empDeptAssoc employee  to deptEmp).
    I configured the deptEmptAssoc association to be a composition and implement the cascading delete, and it is working fine. When I delete a department, the corresponding rows in deptEmp are deleted.
    The problem is that when I try to do the same for empDeptAssoc, JDev gives me a warning and doesn’t apply the composition neither the cascading delete.
    I tried to override the remove method of employee entity to also remove the corresponding deptEmp but it also didn’t work.
    So any hint or pointer how to achieve this? How to have a many to many association and be able to delete both sides of the association?
    Thank you.

    Hi,
    This behavior can be done by overriding the postChanges method as follow:
      public void postChanges(TransactionEvent transactionEvent) {
            if(getPostState() == STATUS_DELETED){
                RowIterator mmIterator = getMM();
                while (mmIterator.hasNext()){
                    EntityImpl row = (EntityImpl)mmIterator.next();
                    row.remove();
    row.postChanges(transactionEvent);
            super.postChanges(transactionEvent);
    N.B.1  In the xml file of the viewLink, the composition association (and implement cascade delete) should not be checked.
    N.B.2  with these flags unchecked, ADF will not control the posting of entities in case the department and the deptEmp entities were both newly created. To fix the issue, the deptEmp entity should also override the postChanges method as follow:
                        public void postChanges(TransactionEvent transactionEvent) {
            if (getPostState() == STATUS_NEW ||
                  getPostState() == STATUS_MODIFIED) {
                EntityImpl dept = getDept();
                if (dept != null) {
                  if (dept.getPostState() == STATUS_NEW) {
    dept.postChanges(transactionEvent);
                                                    // do the same for the Employee entity if needed
            super.postChanges(transactionEvent);
    Regards.

  • BC4J: Implementing cascade-delete

    Hi,
    I'm using BC4J (JDev 9.0.3.4) and I'd like my composite associations with cascade delete to realy behave like one would usualy expect... that is, when the master entity is deleted, the details are not only deleted from the database but from the view object and entity caches as well. Is there a way to accomplish that?
    I was thinking about extending EntityImpl and overiding the remove or doDML method to remove the detail entities from the vo and eo caches. Is this the correct approach? Any other options?
    Thanks,
    Leonardo

    If you use the JDev 9.0.3.5 or later, you could
    select "Implement cascade delete" option in the
    Association properties for your composition
    association. This flag enables the framework to
    remove all details for a master when the master is
    deleted.Hi, Thanks for your reply.
    We're using 9.0.3.4 and unfortunately upgrading is not an option for us at this time. What would be the correct way to implement it using 9.0.3.4?
    Thanks,
    Leonardo Bueno

  • Can you make a key with delete cascade when there is no primary key?

    I have a table with a primary key, and also a field called 'tpid', which is sometimes null, and sometimes has an integer value in it. This integer value corresponds a primary key in another table, and that key is also called tpid.
    I would like the following to happen.
    If a row in table 1 is deleted, and it has a tpid that is not null, then I want the corresponding row in the second table to be deleted too.
    I think a trigger could be written to do this, but it would be better if a foreign key constraint with cascade delete could be used.
    One reason that is better is that whenever I script out my database, triggers seem to be left out by default, unless I specifically ask that they not be..
    So can this be done - where column in table 1 has some nulls, and is not a primary key, but when its deleted, you want to delete a matching row in a table where it IS a primary key.
    Thanks,
    Gideon

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
    use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. 
    >> I have a table with a PRIMARY KEY, <<
    That is redundant. Table has a key by definition, but the fact that you said it this way tells us you have a high level of ignorance. 
    >> .. and also a field [sic] called “tp_id”, which is sometimes NULL, and sometimes has an integer value in it. <<
    Yep! Wrong again! A column is not anything like a field. The only place “field” is use in SQL is for {year, month, day, hour, minute, second} in temporal values. 
    >> This integer value corresponds a PRIMARY KEY in another table, and that key is also called tp_id. <<
    NO, NO, NO! A key is never NULL by definition. It cannot be NULL in your un-named second table. Where is the DDL? Why do you have manners of a pig? 
    I will guess, since we have no clear specs from you, that you want to replace the NULL with a dummy value that can be used with DRI actions. 
    Would you like to give us enough information to help you? 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Using commit and delete in cascade implementation.

    Good morning.
    I want to do the next task:
    I have two entities, province and city, which includes an association between them, which implements cascade delete.
    I want to delete a province, and after that, do the commit operation en the same operation.
    The province and cities are erased correctly in memory, but during the commit operation, it shows an integrity exception, showings that there are secundary registries in DDBB.
    Any solution?
    Thanks in advance,
    Jaime.

    Exactly Frank.
    The secuence is thw following:
    We have the next tables:
    Province City
    Id province Des province Id City Des City Id Province
    1 A 1 AA 1
    2 BB 1
    When I Delete the Province '1', in memory it also deletes the citys '1' and '2'.
    The problem is when the commit operation, because the DDBB detects that there is secundary registries asocciates to province '1'.
    I want to delete the Province '1', and also, the citys '1' and '2' in DDBB also.
    Thanks in advance,
    Jaime.

  • Disabling constraints on a schema

    Guys and Gurus
    In Oracle 10g, is it possible to temporarily disable all constraints on a particular schema with the view of reenabling them at a later date?
    This would save time in a particularly massive schema.
    Many Thanks
    Message was edited by:
    The Flaz

    I use this script to disable constraints in a schema, might be an easier way not sure tbh.
    PROMPT Please wait while constraints are disabled...
    DECLARE
    l_SQLstatement VARCHAR2(32000);
    CURSOR c_DisableConstraints IS
    SELECT 'alter table '||table_name||' disable constraint '||constraint_name||' cascade' sqlstatement
    FROM USER_CONSTRAINTS;
    BEGIN
    FOR r_DisableConstraints IN c_DisableConstraints LOOP
    l_SQLstatement := r_DisableConstraints.sqlstatement;
    EXECUTE IMMEDIATE (l_SQLstatement);
    END LOOP;
    END;
    /

  • Additional association problems in jdev 9033

    Hi,
    besides the already described problem that associations almost always need to have both accessors enabled to prevent weird nullpointer exceptions, there's an additional problem in that it takes ages to open the association wizard.
    This makes hunting missing accessors especially annoying. It sometimes takes up to 2 minutes (on a 2.4Ghz, 2Gb mem machine) to open up the association wizard.
    All other wizards pop up immediately. It's just the association wizard that misbehaves.
    Greetings,
    Ivo

    Hi Ivo,
    I took some time to try to reproduce your problems with the performance of invoking the association editor. I tried to reproduce a performance problem in both 9.0.3.2 and 9.0.3.3 using several sizes of applications and different associations and was unable to reproduce any performance problem. In researching any history of problems with the editor, I found bug 2596870 about performance problems with launching association editor on extended associations, which I filed in Sept. 2002 and verified the fix in Oct. 2002 and I have not see a regression since. I retested extended associations in jdev9033 and everything looked great. Here are my results testing performance with bc4j associations:
    Association Editor - Jdev9032 - invoked at 2:53:30 launched at 2:53:32 - 2 seconds to launch
    Association Wizard - Jdev9032 - invoked at 2:54:30 launched at 2:54:31 - less than 1 second
    Association Editor - Jdev9033 - invoked at 2:57:30 launched at 2:57:32 - less than 2 seconds to launch
    Association Wizard - Jdev9033 - invoked at 2:58:30 launched at 2:58:31 - less than 1 second
    I know that I will need a project from you and/or complete steps to reproduce the associations they are building. I have a feeling that the only way to find the errors is to try to create or use the associations you are building and cause the exceptions to throw that you reported and then invoke editors once the exceptions have altered the state of jdev. Please let me know if you'd like me to attempt to reproduce with your application.
    Thanks,
    Amy

  • REPEATED POST: Using commit and delete in cascade implementation.

    Good morning.
    I want to do the next task:
    I have two entities, province and city, which includes an association between them, which implements cascade delete.
    I want to delete a province, and after that, do the commit operation en the same operation.
    The province and cities are erased correctly in memory, but during the commit operation, it shows an integrity exception, showings that there are secundary registries in DDBB.
    Any solution?
    Thanks in advance,
    Jaime.

    Exactly Frank.
    The secuence is thw following:
    We have the next tables:
    Province City
    Id province Des province Id City Des City Id Province
    1 A 1 AA 1
    2 BB 1
    When I Delete the Province '1', in memory it also deletes the citys '1' and '2'.
    The problem is when the commit operation, because the DDBB detects that there is secundary registries asocciates to province '1'.
    I want to delete the Province '1', and also, the citys '1' and '2' in DDBB also.
    Thanks in advance,
    Jaime.

  • Commit both parts of a "references" association together

    I'm running JDev 11.1.2.3.0.
    I have an Entity Association between TABLE_A and TABLE_B Entities in a 0..1 -> * references relationship. I will either be creating just a record in TABLE_B or records in both TABLE_B and TABLE_B.
    When creating records in both Entities I want both records to form an atomic transaction; either commit both or rollback. The problem is that if I try to commit both at the same time, the child record won't insert because the parent PK has changed from the temporary negative number. If I set the Association to be a Composite Association, committing both records together works, but I am then unable to commit a single record in TABLE_B on it's own.
    What is the recommended solution for this situation?
    Many thanks

    The referencing field in the "child" table isn't mandatory. This is why I really want to use a references association, I just couldn't get it working so I tried the composition association.
    The relationship is TABLE_A 0..1 -> * TABLE_B. The two are independent; I'm either going to insert into both tables or just TABLE_B.
    What I'm trying to do is the equivalent of:
    INSERT INTO TABLE_A()
    VALUES()
    RETURNING ID INTO TABLE_A_ID_VAR;
    INSERT INTO TABLE_B(TABLE_A_ID)
    VALUES(TABLE_A_ID_VAR);
    COMMIT;
    or just
    INSERT INTO TABLE_B()
    VALUES;
    COMMIT;
    I don't understand how one does the two table insert with TABLE_B referencing TABLE_A in ADF. If I try to do that with just a "references" association, I see TABLE_B FK is initially populated with the temporary negative ID of TABLE_A, but isn't updated on COMMIT with the actual ID.

  • Creating master detail rows

    using adf/bc with jsf. I have defined a master detail relationship between two entities. This relationship is a composition relationship. The entities are related by a view link which link the master and detail view objects. i have a need to create/insert a master row and a detail row programmatically "on the fly" so that when the jsp renders, the user will see blank inputs for both the master and detail view objects. The problem is that the primary key of the master record is not known at creation time ( it will be entered by the user) and therefore the detail record cannot be created by the framework because of the unknown value of the parent's primary key. I was hoping the following section in the adf guide would eliminate my problem, but it doesn't appear to:
    This is from section 26.7.3.2 of the adf developer's guide
    Note: An alternative to the programmatic technique discussed
    above, which solves the problem at the J2EE application layer, is the
    use of deferrable constraints at the database layer. If you have control
    over your database schema, consider defining (or altering) your
    foreign key constraints to be DEFERRABLE INITIALLY DEFERRED.
    This causes the database to defer checking the constraint until
    transaction commit time. This allows the application to perform DML
    operations in any order provided that by COMMIT time all appropriate
    related rows have been saved and would alleviate the parent/child
    ordering described above. However, you would still need to write the
    code described in the following sections to cascade-update the foreign
    key values if the parent’s primary key is assigned from a sequence.
    This approach did not help in allowing me to create the detail record without first knowing the value of the parent's primary key record in a composition relationship. The only thing i've found to work is define the relationship as just an association, and not a composition. However, this is a true one to many (composition) relationship and i would like to take advantage of some of the features of the framework that are there when a relationship is defined as a composition relationship. Is there any way to do what i need to do with a composition relationship defined between these two entities? Thanks.

    Hi,
    I guess you need a "Cascading LOVs".
    1) Create viewObject for country values list. Named VO1.
    2) Create viewObject for state values list. Named VO2.
    3) Create view criteria for (bind variable) VO2 which can restrict the result by country.
    4) Create view accessor to get VO1.
    5) Create view accessor to get VO2. Define the bind variable value which can provide country info dynamically. I guess it should be a Groovy expression.
    6) Create country LOV on step 4) view accessor.
    7) Create state LOV on step 5) view accessor.
    Done
    On the view layer, you may enable PPR between country and state attributes.
    Todd

  • JBO-25030 Failed to find or Invalidate owning Entity

    I've an association between 2 entities.
    In the database I've a delete cascade option set.
    In BC4J the wizard checked the Composition Association option as well as the delete cascade option.
    However executing I get a JBO-25030 error.
    Removing the composition in seems to work.
    Could You explain me what's the problem ?
    TIA
    Tullio

    May be , this is like : parent key not found.
    => you have an new EO instance (which is a child in a master-detail association)
    with a non-existing master key value.
    regards,
    Harm

Maybe you are looking for