SQLIntegrityConstraintViolationException in a "many to many" related tables

Hi, in an 11g adf application I have a “many to many” relationship between two tables A and B and an intermediate table C that relates them.
The database has constraints that check for id existence in master tables before saving rows in C.
When I’m trying to create a new entry in B’s UI form with relations to A I’m getting a:
java.sql.SQLIntegrityConstraintViolationException: ORA-02291:
the framework seems that tries to save the row in C before B. So there doesn’t exist the id in B.
The same operation in A table’s UI form is executed properly. The framework first creates a row in A
and then related it with B creating rows in C and no constraint violation is thrown.
Why is this happening?
Any comment will be helpful.
Thanks

Using BC Tester the save operation is executed properly without errors.
The constraint you are asking is a classic referential constraint in intermediate table C that requires when creating new rows in C the foreign key refer to B to pre-exist in B table.
So the sequence of save operation is important when creating new rows in B and C table.
If I create a new row in B, save it and then create relations as new rows in C everything is fine.
But if I concurrently create a new row in B with rows in C, the framework seems that tries to save firstly the rows in C and then in master table B so the referential integrity is violated.
Is it possible in ADF to influence to order of saves in master detail tables and how is this specified?
For example the same operation with same integrity constraints in UI form of A table is executed properly.

Similar Messages

  • Many-to-Many relation sample in ADF

    I have a requirement to implement a screen
    Three tables 1) Users 2) Access 3) Documents
    The Access table contains both the references DocId and UserId and acts as the intersection table.
    Users table is related to Documents through the Access table which acts as the intersection table and vice versa. I need to create a screen gui which will show all the documents a user has. Secondly also show all the users who has permission to a particular document. Is there any sample adf application which implements a simple many-to-many relation.
    I am planning to create three entity objects - UsersEO, AccessEO, DocumentsEO
    two view objects - UsersVO and DocumentsVO
    one view link -UsersDocumentVL
    Also which GUI components is best suited to address this. How many Entity Objects, View Objects and View Link should I create. Any simple sampe will help.
    Regards
    Thomas

    Thomas,
    There are of course many ways to implement your requirement. Try this exercise... forget about ADF for a moment; put your computer away (well, finish reading this first ;) ). Grab a pencil and paper.. assuming you could do anything, how would you like the screen to work? Draw it out on a piece of paper and describe how it works. You've just created a rudimentary specification. Now, come back to this thread and describe your specification - perhaps then we can help you implement your spec using ADF (or at least tell you "not possible" and describe why).
    Best,
    John

  • Defining Dimensions, Attribute Hierarchies for a Link Table(Many to Many)

    I have 3 Tables in the Database
    Table 1: Transactions (Fact Table) - PK(TransactionId)
    Table 2: Relationship (Dimension1) - PK(Relationship Id), FK_TransactionId, FK_CompanyId, RelationshipType
    Table 3: Companies (Dimension 2) - PK(CompanyId)
    Table 2: Relationship table is a link table between Transactions & Companies to facilitate many to many relationship. 
    I defined Fact and Dimension tables accordingly but having issues defining Dimension & Attributes for Relationship tables
    Relationship Dimension:
    I have 3 hierarchy groups defined
    Hierarchy 1 - Relation -Relationship Type,Relationship Id(PK)
    Hierarchy 2 - Transaction - Transaction, Relationship Id(PK)
    Hiearchy 3 - Company - CompanyId, Relationship Id(PK)
    Defined the attribute relationship in the following way
    RelationshipID(PK) ---> CompanyId , RelationshipID(PK) ---> TransactionId, RelationshipID(PK)
    ---> RelationshipTYpe
    I am getting incorrect results when I deploy the cube. Not all the types are being displayed only 4 types are being displayed out of 27 types though there exists Transactions for all the Types.
    To fix the incorrect results, I tried to break the Relationship Dimension into 2 dimensions seperating Transaction(Relationship Dim) & Company,Type (Companies Dim). I tried to configure a many
    to many Relationship type between my  Companies Dim & Fact Table Transaction. But I get the error that says 
    "Companies Dim many to many dimension in the Tansaction measure group requires that the granularity of the Relationship dimension is lower than that of the Relationship measure group "
    Any help regarding how to difine Dimensions & Attribute Hierarchies on a Many to many link table is appreciated.

    Hi Jaya,
    According to your description, you are experiencing the issue when implement many to many relationship by using a bridge table in your SQL Server Analysis Services project, right?
    Generally, a bridge table will have a surrogate key for the dimension and a surrogate key to the fact table or a degenerate dimension based on the fact table. Here are some blogs which describe how to implement many to many relationship using a bridge
    table.
    http://bifuture.blogspot.com/2011/06/ssaskimball-modeling-nm-relation.html
    http://www.sqlchick.com/entries/2012/1/22/data-modeling-tip-when-using-many-to-many-bridge-tables-in-s.html
    http://social.technet.microsoft.com/wiki/contents/articles/22202.a-practical-example-of-how-to-handle-simple-many-to-many-relationships-in-power-pivotssas-tabular-models.aspx
    Regards,
    Charlie Liao
    TechNet Community Support

  • Problem in mapping a many to many relation to a list

    Hi,
    I have a problem with mapping a many to many relation to a list.
    I have a Many to Many relation in my database between tables baskets and products. This relation is implemented with a join table basket_products, which has two fields which correspond to the foreign keys to tables baskets and products. The join table need to have another one column "order", which defines the order of the products for the specific basket.
    In my mapping I have:
    @Entity
    @Table(name = "baskets", uniqueConstraints = {})
    public class Components implements java.io.Serializable {
    @ManyToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
         @JoinTable( name="baskets_products",
                             joinColumns=@JoinColumn(name="b_id", referencedColumnName="pr_id"),
                             inverseJoinColumns=@JoinColumn(name="pr_id", referencedColumnName="pr_id"))
            //This of course doesn't work!!
           //@OrderBy(value="order")
         public List<Products> getProductses() {
              return this.productses;
         public void setProductses(
                   List<Products> productses) {
              this.productses = productses;
    @Entity
    @Table(name = "products", uniqueConstraints = { })
    public class Products implements java.io.Serializable {
    @ManyToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "productses")
         public Set<Baskets> getBasketses() {
              return this.basketses;
         public void setBasketses(Set<Basket> basketses) {
              this.basketses = basketses;
         }In the EJB spec I read that :
    "The property or field name must correspond to that of a persistent property or field of the associated
    class."
    What to do if I want to use a field from the join table to do the ordering of the list??
    My problem is that the field "order", is not defined to the EJB container as a persistent field, so it cannot be used. But for my needs it is necessary that this field is included in the join table.
    I thought that I could use the secondary table annotation to map the join table to the Baskets class, as well, so that I can define the order field, but this solution seems to me as a really wrong one.
    Can anyone help me??
    Thanks,
    Elenh.

    Hi Martin-
    Can you please help me. Here are the details:
    We have created an AQ in Oracle DB which will have the following message Structure:
    CREATE OR REPLACE TYPE enqueue_payload AS OBJECT
    ( field1 VARCHAR2(100),
    field2 VARCHAR2(100),
    field3 DATE,
    field4 VARCHAR2(100),
    field5 NUMBER,
    payload CLOB,
    In the Payload field we are enqueing an XML message.
    We have to use a OSB proxy service to dequeue the message from the AQ, transform it to another format and send to a SOA Composite.
    We created a AQ Adapter in Jdeveloper 11g and imported the WSDL, XSD and .jca jca binding file into the OSB project. And configured the OSB proxy service using the WSDL imported.
    However in OSB proxy service message flow when I try to create an XQUERY transformation, I see that the Payload field does not expose the structure of the XML message that is being enqueued. I even changed the message structure definition to have the payload field as XMLType. But it didn't help.
    On analyzing the XSD created by AQ Adapter, I see that the payload is being defined as "string" in the XSD.
    Inputs Needed
    =========
    1. How can we parse the payload field defined as CLOB/XMLType in OSB so that I can see the structure of the XML message it holds ?
    2. Is there any in-built function in OSB to convert it to XML ?
    3. Any other inputs in order to transform the XML message coming in the payload field as CLOB/XMLType
    Please provide your inputs and I hope that I have clearly explained my use case.
    Thanks in advance for your time and help!!
    Regards,
    Dibya

  • Many to Many PL/SQL - how to nest a linking table?

    I have two objects that are linked with a many-to-many relations. These two objects have to be nested inside a third object. How should I do ?
    I created the type and the table for A, I did the same for B and I finally created the linking table for A and B. How shall I nest this table inside the object C?
    Thank you very much for your help as I am new to PL SQL.

    I need to create one object called Container. From a modelling perspective, this object has contains all the other objects.
    The other objects are items and composed items. The Container contains the items (it is a one-to-many relationships so I created a nested table) but it also contains composed items, which are items linked to parts and this is a many-to-many relationship. How do I do to include the many-to-many in the object container? I included question marks when I did not know. Thank you
    CREATE OR REPLACE TYPE Item_type (
    Id NUMBER (6),
    Type CHAR (7)) ;
    CREATE OR REPLACE TYPE Part_type (
    Id NUMBER (6),
    Type CHAR (7)) ;
    CREATE TABLE Item OF Item_type
    (Id NOT NULL,
    PRIMARY KEY (Id));
    CREATE TABLE Part OF Part_type
    (Id NOT NULL,
    PRIMARY KEY (Id));
    CREATE TABLE ComposedItems
    (ItemId REF Item_type ,
    PartId REF Part_type);
    CREATE OR REPLACE TYPE ComposedItems_nested as TABLE OF *????????*
    CREATE OR REPLACE TYPE Item_type (
    Id NUMBER (6),
    Type CHAR (7));
    CREATE OR REPLACE TYPE Item_nested as TABLE OF Item_type;
    CREATE OR REPLACE TYPE Container_type (
    Id NUMBER (6),
    Type CHAR (7),
    Item Item_nested,
    /

  • Take2 - Many-to-Many mapping on a single object/table via an external table.

    Plaease ignore the previous entry. Finger trouble on the keyboard
    accidentally posted prior to completion!
    Any takers on this one? If its simple, then great.
    I currently have a problem making the correct meta-data via xdoclet for a
    collection with a many-to-many mapping between an enhanced class and an
    xref table (which does not have an enhanced class associated with it.)
    Although page 184 of the Kodo JDO 3.01 Developers guide does spell out in
    fairly academic terms what has to be done, it still seems fairly
    impenetrable, after much mangling and hacking.
    As far as I can see the significantly questionable attributes are:-
    element-column.<pk column>*
    and
    ref-column.<pk column>*
    The asterisks and the associated texts indicate that these entries can be
    specified more than once.
    Here is my Meta data.
    * @jdo.field collection-type="collection"
    element-type="com.letsys.erespond.business.model.event.Condition"
    * @jdo.field-vendor-extension vendor-name="kodo" key="jdbc-field-map"
    value="many-many"
    * @jdo.field-vendor-extension vendor-name="kodo"
    key="jdbc-field-map/table" value="EventConditionConditionXref"
    * @jdo.field-vendor-extension vendor-name="kodo"
    key="jdbc-field-map/element-column.ID" value="EVENTCONDITIONID"
    * @jdo.field-vendor-extension vendor-name="kodo"
    key="jdbc-field-map/ref-column.EVENTCONDITIONID" value="ID"
    private Collection groupsToConditions;
    Here is the basic table which I wish to use for the xref
    create table EventConditionConditionXref(
    EventConditionId NUMBER(10) NOT NULL primary key,
    EventConditionIdGroupTo NUMBER(10) NOT NULL primary key
    The EventCondition class and table uses a field 'id' as its primary key.
    The intention is the xref table will hold many-many associations between
    multiple EventCondition.id instances in the underlying database.
    Thus the joing condition would be :
    select
    EventConditionIdGroupTo
    from
    EventCondition ec, EventConditionConditionXref ecx
    where
    ec.id = ecx.EventConditionId
    There are numerous variations that I have squeezed through it, but the net
    effect has always been
    BUILD FAILED
    file:C:/dev/projectm/build.xml:303:
    kodo.jdbc.meta.MappingInfoNotFoundException: The mapping for fie
    ld "com.letsys.erespond.business.model.event.Condition.groupsToConditions"
    is missing information on
    how to link the fields table to its owning class table, or the given
    information is invalid.
    I have tried many interpretations as to how
    element-column.<pk column>*
    and
    ref-column.<pk column>*
    should be represented, but always with the same 'not enough info' message.
    Am I missing something obvious, and/or not understanding something?
    Cheers Ed.

    Ed-
    I think what you want is:
    @jdo.field collection-type="collection"
    element-type="com.letsys.erespond.business.model.event.Condition"
    @jdo.field-vendor-extension vendor-name="kodo" key="jdbc-field-map"
    value="many-many"
    @jdo.field-vendor-extension vendor-name="kodo"
    key="jdbc-field-map/table" value="EventConditionConditionXref"
    @jdo.field-vendor-extension vendor-name="kodo"
    key="jdbc-field-map/ref-column.ID" value="EVENTCONDITIONID"
    @jdo.field-vendor-extension vendor-name="kodo"
    key="jdbc-field-map/element-column.ID" value="EVENTCONDITIONIDGROUPTO"
    Basically, the "ref-column.<primary key>" specifies the column in the
    join table that holds the primary key of the source side of the relation
    (the current class), and the "element-column.<primary key>" specifies
    the column in the join table that holds the primary key of the
    destination side of the relation (the content of the Collection field).
    Since it appears that you want the relation to be from Condition to
    Condition (i.e., have a relation it itself), the primary key in both
    cases will be the 'ID' column.
    Let us know if you still have problems with this. You might want to
    check out our graphical mapping workbench in 3.1, which helps greatly
    simplify composing your mappings.
    In article <[email protected]>, Ed Bett wrote:
    Plaease ignore the previous entry. Finger trouble on the keyboard
    accidentally posted prior to completion!
    Any takers on this one? If its simple, then great.
    I currently have a problem making the correct meta-data via xdoclet for a
    collection with a many-to-many mapping between an enhanced class and an
    xref table (which does not have an enhanced class associated with it.)
    Although page 184 of the Kodo JDO 3.01 Developers guide does spell out in
    fairly academic terms what has to be done, it still seems fairly
    impenetrable, after much mangling and hacking.
    As far as I can see the significantly questionable attributes are:-
    element-column.<pk column>*
    and
    ref-column.<pk column>*
    The asterisks and the associated texts indicate that these entries can be
    specified more than once.
    Here is my Meta data.
    * @jdo.field collection-type="collection"
    element-type="com.letsys.erespond.business.model.event.Condition"
    * @jdo.field-vendor-extension vendor-name="kodo" key="jdbc-field-map"
    value="many-many"
    * @jdo.field-vendor-extension vendor-name="kodo"
    key="jdbc-field-map/table" value="EventConditionConditionXref"
    * @jdo.field-vendor-extension vendor-name="kodo"
    key="jdbc-field-map/element-column.ID" value="EVENTCONDITIONID"
    * @jdo.field-vendor-extension vendor-name="kodo"
    key="jdbc-field-map/ref-column.EVENTCONDITIONID" value="ID"
    private Collection groupsToConditions;
    Here is the basic table which I wish to use for the xref
    create table EventConditionConditionXref(
    EventConditionId NUMBER(10) NOT NULL primary key,
    EventConditionIdGroupTo NUMBER(10) NOT NULL primary key
    The EventCondition class and table uses a field 'id' as its primary key.
    The intention is the xref table will hold many-many associations between
    multiple EventCondition.id instances in the underlying database.
    Thus the joing condition would be :
    select
    EventConditionIdGroupTo
    from
    EventCondition ec, EventConditionConditionXref ecx
    where
    ec.id = ecx.EventConditionId
    There are numerous variations that I have squeezed through it, but the net
    effect has always been
    BUILD FAILED
    file:C:/dev/projectm/build.xml:303:
    kodo.jdbc.meta.MappingInfoNotFoundException: The mapping for fie
    ld "com.letsys.erespond.business.model.event.Condition.groupsToConditions"
    is missing information on
    how to link the fields table to its owning class table, or the given
    information is invalid.
    I have tried many interpretations as to how
    element-column.<pk column>*
    and
    ref-column.<pk column>*
    should be represented, but always with the same 'not enough info' message.
    Am I missing something obvious, and/or not understanding something?
    Cheers Ed.
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • Self referencing table many to many relationship

    I am in a bit of a logic pickle, and I was wondering if someone could help me out.
    I have a table in a database I am designing called document, it holds information on surprisingly on documents in our DMS.
    I want to create the notion that a document can have multiple related documents, and those documents can be the related documents for many documents.
    So it is a self referencing table, I have done these before so no big deal, but this time is a many to many relation, it wasnt before.
    Maybe something like:
    document
    docid (pk)
    related_doc
    docid (pk) (fk to document.docid)
    related_docid (pk) fk to document.docid)
    Does anyone have any experience with this or any advise I might find sueful?
    Thanks!

    A junction table can be used to resolve a many-to-many relationship as is in your example. There are two PK/FK relationships between document and related_document table. This will prevent denormalization of data.
    The other option could be to have just one table with two columns (parent_doc_id and child_doc_id) and have a PK constraint on both the columns - just like bill-of-materials.
    But I think the approach you have in your posting will work well.
    Shakti
    http://www.impact-sol.com
    Developers of Guggi Oracle - Tool for DBAs and Developers

  • JOIN for many-to-many linked tables?

    I have two tables, A and C, linked by a many-to-many intersection table B.
    I'd like to do a select from A with a LEFT OUTER JOIN to C for items mapped via B. A row in A may or may not have rows in C linked to it.
    I've tried to do a select using sub-selects but then I don't get the rows from A that don't have related rows in C.
    When I try to use the syntax of a LEFT OUTER JOIN I can't figure out how to link A and C via the B table.
    I would appreciate suggestions for how to approach this.
    Thanks in advance,
    George

    EXAMPLE
    SQL> L
      1  with A as (
      2  select 1 col1, 1 col2 from dual union all
      3  select 2     , 1     from dual union all
      4  select 3     , 2     from dual)
      5  ,
      6  B as (
      7  select 1 col2, 1 col3 from dual union all
      8  select 2     , 3     from dual)
      9  ,
    10  C as  (
    11  select 1 col3 from dual union all
    12  select 2      from dual union all
    13  select 3      from dual
    14  )
    15  select *
    16  from      A
    17  LEFT JOIN B ON (A.COL2=B.COL2)
    18* LEFT JOIN C ON (B.COL3=C.COL3)
    SQL> /
          COL1       COL2       COL2       COL3       COL3
             1          1          1          1          1
             2          1          1          1          1
             3          2          2          3          3

  • Many-to-many relation

    Hi,
    There is a many-to-many relation defined for the following tables:
    Table T_PRICEAFFECTOR
    Name Type
    NAME VARCHAR2(100)
    ISACCUMULATIVE NUMBER(1)
    RATE NUMBER(10,10)
    PRICEAFFECTOR_ID NOT NULL NUMBER(10)
    CATALOG_ID NOT NULL NUMBER(10)
    UNITTYPE NOT NULL NUMBER(1)
    and
    Table T_PRICEAFFECTINGCHAIN
    Name Type
    PRICEAFFECTINGCHAIN_ID NOT NULL NUMBER(10)
    NAME VARCHAR2(100)
    ISDEFAULTFORSTORE NUMBER(1)
    CATALOG_ID NOT NULL NUMBER(10)
    There is also a third table defining the many-to-many relation:
    TABLE T_PRICEAFFECTORTOCHAIN
    Name Type
    PRICEAFFECTOR_ID NOT NULL NUMBER(10)
    PRICEAFFECTINGCHAIN_ID NOT NULL NUMBER(10).
    The classes defined are as follows:
    public class PriceAffectorsChain
         private Catalog catalog;
         private long priceAffectorsChainId;
         private String name;
         private boolean isDefaultForStore;
         private Collection priceAffectors = new HashSet ();
         private Collection products = new HashSet ();
    public class PriceAffector
         private long priceAffectorId;
         private long isAccumulative;
         private String name;
         private double rate;
         private Catalog catalog;
         private int unitType;
         private Collection priceAffectorsChains = new HashSet ();
    and these are defined in the jdo descriptor in the following way:
    <class name="PriceAffector" identity-type="application"
    objectid-class="jp.telewave.platpark.eis.dao.pk.PriceAffectorPK">
         <extension vendor-name="kodo" key="lock-column" value="none"/>
         <extension vendor-name="kodo" key="class-column" value="none"/>
         <extension vendor-name="kodo" key="table" value="T_PRICEAFFECTOR"/>
         <field name="priceAffectorId" primary-key="true">
              <extension vendor-name="kodo" key="data-column"
    value="PRICEAFFECTOR_ID"/>
         </field>
         <field name="isAccumulative">
              <extension vendor-name="kodo" key="data-column" value="ISACCUMULATIVE"/>
         </field>
         <field name="name">
              <extension vendor-name="kodo" key="data-column" value="NAME"/>
         </field>
         <field name="rate">
              <extension vendor-name="kodo" key="data-column" value="RATE"/>
         </field>
         <field name="unitType">
              <extension vendor-name="kodo" key="data-column" value="UNITTYPE"/>
         </field>
         <field name="catalog">
              <extension vendor-name="kodo" key="catalogId-data-column"
    value="CATALOG_ID"/>
         </field>
         <field name="priceAffectorsChains">
              <collection element-type="PriceAffectorsChain"/>
              <extension vendor-name="kodo" key="read-only" value="true"/>
              <extension vendor-name="kodo" key="inverse" value="priceAffectors"/>
              <extension vendor-name="kodo" key="table"
    value="T_PRICEAFFECTORTOCHAIN"/>
              <extension vendor-name="kodo" key="priceAffectorId-ref-column"
    value="PRICEAFFECTOR_ID"/>
              <extension vendor-name="kodo" key="priceAffectorsChainId-data-column"
    value="PRICEAFFECTINGCHAIN_ID"/>
         </field>
    </class>
    <class name="PriceAffectorsChain" identity-type="application"
    objectid-class="jp.telewave.platpark.eis.dao.pk.PriceAffectorsChainPK">
         <extension vendor-name="kodo" key="lock-column" value="none"/>
         <extension vendor-name="kodo" key="class-column" value="none"/>
         <extension vendor-name="kodo" key="table" value="T_PRICEAFFECTINGCHAIN"/>
         <field name="priceAffectorsChainId" primary-key="true">
              <extension vendor-name="kodo" key="data-column"
    value="PRICEAFFECTINGCHAIN_ID"/>
         </field>
    <field name="catalog">
              <extension vendor-name="kodo" key="catalogId-data-column"
    value="CATALOG_ID"/>
         </field>
         <field name="name">
              <extension vendor-name="kodo" key="data-column" value="NAME"/>
         </field>
         <field name="isDefaultForStore">
         <extension vendor-name="kodo" key="data-column"
    value="ISDEFAULTFORSTORE"/>
         </field>
         <field name="priceAffectors">
              <collection element-type="PriceAffector"/>
              <extension vendor-name="kodo" key="read-only" value="false"/>
              <extension vendor-name="kodo" key="inverse"
    value="priceAffectorsChains"/>
              <extension vendor-name="kodo" key="table"
    value="T_PRICEAFFECTORTOCHAIN"/>
              <extension vendor-name="kodo" key="priceAffectorsChainId-ref-column"
    value="PRICEAFFECTINGCHAIN_ID"/>
              <extension vendor-name="kodo" key="priceAffectorId-data-column"
    value="PRICEAFFECTOR_ID"/>
         </field>
         <field name="products">
         <collection element-type="Product"/>
         <extension vendor-name="kodo" key="inverse" value="priceAffectorsChain"/>
         </field>
    </class>
    =============================================================
    Ok. The problem with the mapping is that it works only one way. What I
    mean is that when I try to add new PriceAffectorsChain with many
    PriceAffector objects only the PriceAffectorsChain object is being
    persisted, and none of the PriceAffectors are persisted in the
    many-to-many table (T_PRICEAFFECTORTOCHAIN), even when the read-only
    extensions are set.
    That was not the case when I tried to add new PriceAffector with many
    PriceAfffectorsChain - everything worked.
    Any Ideas?
    -Ivan

    Abe White wrote:
    When you have a two-sided relation, you need to be maintaining both sides
    of the relation at all times. Whenever an A is added to a B, the B must
    be added to the A as well. Keep your in-memory Java objects consistent
    (just as if they were not persistent), and JDO will take care of the rest.Abe White wrote:
    When you have a two-sided relation, you need to be maintaining both sides
    of the relation at all times.
    Whenever an A is added to a B, the B must
    be added to the A as well. Keep your in-memory Java objects consistent
    (just as if they were not persistent), and JDO will take care of the rest.Ok. I agree.
    I think that I'm doing this or maybe I'm wrong. Below is the code that
    adds new price affectors chain with collection of price affectors (all of
    them already persistent). Each of the price affectors is being looked up
    and is consistent (this is what getObjectById is doing, isn't it?) and
    then the price affector chain is being persisted.
    =================================================================
    PersistenceManager pm = null;
    PriceAffectingChain newPriceAffectorsChain = null;
    HashSet priceAffectors = null;
    try {
    pm = persistenceManagerFactory.getPersistenceManager();
    // getting the catalog object
    long catalogId = priceAffectorsChain.getCatalog().getCatalogId();
    CatalogPK catalogPK = new CatalogPK(catalogId);
    Catalog newPriceAffectorsChainCatalog =
    (Catalog)pm.getObjectById(catalogPK, true);
    // making new price affecting chain
    newPriceAffectorsChain = new PriceAffectingChain(
    BeanHelper.getNextSequence(DBObjects.SEQ_PRICEAFFECTINGCHAIN),
    priceAffectorsChain.getName(),
         priceAffectorsChain.getIsDefaultForStore(),
         newPriceAffectorsChainCatalog);
    // retrieval of price affector objects for this chain
    System.out.println("the size of the price affectors is: " +
    priceAffectorPKs.length);
    if (priceAffectorPKs != null && priceAffectorPKs.length > 0) {
         priceAffectors = new HashSet(priceAffectorPKs.length);
    for (int i = 0; i < priceAffectorPKs.length; i++) {
              PriceAffectorPK currentPAPK = priceAffectorPKs;
              PriceAffector currentPA = (PriceAffector)pm.getObjectById(currentPAPK,
    true);
              priceAffectors.add(currentPA);
              System.out.println("The " + currentPA.getName() + " price affector was
    added");
    if (priceAffectors == null) {
         priceAffectors = new HashSet();
    System.out.println("size of priceAffectors: " +
    priceAffectors.size());
    newPriceAffectorsChain.setPriceAffectors(priceAffectors);
    pm.makePersistent(newPriceAffectorsChain);
    } catch {
    ===========================================================
    The problem is that the presistence works only for the table of
    PriceAffectingChain obejct and not for the relation table. I tried on
    purpose to add new price affectors with collection of price affecting
    chains and it worked for both tables (the one for PriceAffector object and
    the relation table.
    I have no idea what I can try next. Any advice or help are welcomed.
    Thanks.
    -Ivan

  • Many to Many Relationship using junction table..

    Hello im testing a many to many relation ship on j2ee and found this issue.
    Creating a relation ship table until now without succes to update the relationship table:
    code fragment as is:
    On application flow my session bean call the following method according with the specification i have no reason to call persist in my writer just on parent Object: Any clue on what is wrong ?
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void saveWriter (Book book , Writer writer){
    try {
    Book atBook = entityManager.merge(book);
    Writer atWriter = entityManager.merge(writer);
    book.getWriters().add(atWriter);
    entityManager.persist(atBook);
    entityManager.flush();
    }catch (Exception ex)
    ex.printStackTrace();
    <entity class="com.octech.biblio.domain.Book" name="book">
    <description></description>
    <table name="books" />
    <attributes>
    <id name="id">
    <generated-value strategy="IDENTITY"/>
    </id>
    <basic fetch="EAGER" name="bookName">
    <column insertable="true" length="128" name="bookname" table="" updatable="true"/>
    </basic>
    <many-to-one name="Library" fetch="LAZY" target-entity="com.octech.biblio.domain.Library">
    <join-table name="library_books">
    <join-column name="books_id"/>
    <inverse-join-column name="library_id"/>
    </join-table>
    <cascade/>
    </many-to-one>
    <many-to-many name="Writers" fetch="LAZY" target-entity="com.octech.biblio.domain.Writer">
    <join-table name="writers_books">
    <join-column name="books_id"/>
    <inverse-join-column name="writer_id"/>
    </join-table>
    <cascade/>
    </many-to-many>
    </attributes>
    </entity>
    <entity class="com.octech.biblio.domain.Writer" name="writer">
    <description></description>
    <table name="writers" />
    <attributes>
    <id name="id">
    <generated-value strategy="IDENTITY"/>
    </id>
    <basic fetch="EAGER" name="writerName">
    <column insertable="true" length="128" name="writer_name" table="" updatable="true"/>
    </basic>
    <many-to-many name="Books" fetch="LAZY" target-entity="com.octech.biblio.domain.Book">
    <join-table name="writers_books">
    <join-column name="writer_id"/>
    <inverse-join-column name="books_id"/>
    </join-table>
    <cascade/>
    </many-to-many>
    </attributes>
    </entity>

    sybrand_b wrote:
    The way you write it yes, but there is one minor detail.
    You can have a 0,1 or many relationship: one employee has zero, one or many phone numbers
    but you can not have the opposite, as it doesn't make sense.
    0, 1 or many phone numbers belong to 1 employee.
    It is customary to use 0,1 or m when the relationship is optional.
    Sybrand Bakker
    Senior Oracle DBAIs this correct now ?
    one to many : one employee has 0,1 or multiple phone numbers
    many to one : 1 or multiple phone numbers to one employee

  • Two tables that have both "many-to-many" and "one-to-many" relationship

    i have the following two tables one represents the users and the other represents articles where each article can have one author(user) and of course the users can author many articles, so the relationship is one-to-many:-
    1. Users:-
    User_id (primary_key)
    User_name
    User_sex
    user_address
    2.Articiles:-
    Article_id
    Text
    Author_id (foreign key to the users.user_id)
    but the problem that i have faced is that on another requirement each articles can have multiple approval (users) before being published, so in this way the relation have became many-to-many, so i have created a third table named "approvals":-
    3.Approval:-
    approval_id (foreign key to the users.user_id)
    article_id (foreign key to the articles.article_id)
    level.
    so is this a good approach to flow , or there are another way that i can better build these tables.

    sb92075 wrote:
    approval_id (foreign key to the users.user_id) I am not clear on data element above.
    I thought USERS were really AUTHORS. yes the authors are users , and the author id is exactly the same as user id.
    and any user can be author if a flag in the users table is set to yes and he is involved in a workflow.
    so do authors approve their own articles? no
    do non-authors approve articles?
    What is "level" in APPROVAL table?
    What is PK for APPROVAL table? level indicates the workflow steps if there are multiple steps in the workflow ,for example the first approval is on level one, and the second approval is on level two,etc
    the primary key for the approval will be article_id and the user_id

  • Many to Many relation problem

    Hi,
    JDeveloper 11.1.1.6
    3 tables, let's name them A, B and RelAB
    By default, there is a [1 to *] from A to RelAB and a [1 to *] from B to RelAB.
    Since I wanted to use a master-detail view on my web page, I didn't have the choice to modify these Associations and Links to a [* to *] from A to B, and as well from B to A.
    Now you test the whole thing by running the AppModule. Everything works like a charm.
    The problem is if I go into my A view object and then I change the SQL Mode from Normal to Expert inside the Query tab, the minute I run my AppModule, one of my many to many relationship breaks. Notice that I did not change anything else, just switch from Normal to Expert. Let's say that the A to B relation is working but not the B to A.
    If I put it back to Normal, it works again. You might want to ask, why bother with Expert Mode? It is just that I want to modify this query, I was just trying to identify the source of the problem.
    Anybody experience a similar problem with many-to-many relationships?

    I assume your question is on JAXB, correct?
    I think you need to make on side of the relationship transient, or remove it.
    James : http://www.eclipselink.org

  • SSAS 2008 snowflake - dimensions with one-to-many relationship (NOT fact table) and hierarchy?

    Hi, below is my data model for SSAS 2008 on snowflake schema.
    Below is SQL Server DW tables:
    DimStudent - StudentID [primarykey], StudentName, DateOfBirth, AddressID
    DimStudentAddresses - AddressID [primarykey], StudentID [foreignkey], ddressLine1, AddressLine2, AddressType
    FactEnrolment - StudentID, EnrolWeek, EnrolFees
    So here FactEnrolement.StudentID is joined to DimStudent.StudentID column,
    and relationship between DimStudent & DimeStudentAddresses is one to many I.e. one student can have multiple addresses like primary or secondry address.
    To design snowflake schema in SSAS 2008 BIDS project :
     [Question-1] how to join one-to-many dimensions (NOT fact table) Like DimStudent & DimAddresses?
     [Question-2] At the end I want to have a single dimension only I.e. Student which should have both DimStudent & DimStudentAddresses tables attributes init. So I can create hierarchy from these two table into a single dimension? How
    to do this?
    Please reply with feedback particular to my above scenario as I refereed other MSDN forums but nothing solid I found.
    Any STEP-BY-STEP guideline please. Many thanks.

    Hello KM,
    Have you solved this issue after refer to Bill's suggestion? Please let us know how things go.
    If you have any feedback on our support, please click
    here.
    Best Regards,
    Elvis Long
    TechNet Community Support

  • Additional properties on Many-to-Many relation

    Hi,
    I've trawled through the archive and can't see if this is answered (nor can I find it in the documentation) so apologies if I've missed something obvious.
    I have a logical model with several many-to-many relationships. Clearly I can (and probably should) resolve them, but for a number of reasons I'd prefer, for now, to leave them as m:n.
    On at least one of the m:n I want to add additional (non-FK attributes) to the relationship. There is even a section of the Relation Properties dialog that looks like it should allow me to do so (Attributes) but this is only populated in a 1:m relationship.
    Is there any way of directly adding the non-FK attributes to the relationship? Or do I have to resolve the m:n and add the attributes to the new entity? Or is there some way in the transformation of adding the attributes?
    Thanks
    Ian

    Hi Ian,
    I want to add additional (non-FK attributes) to the relationshipIt's not possible in current release.
    It's better to resolve the relationship to entity and to add attributes there.
    Philip

  • Many-to-many association: inserting in the detail table fails

    I'm using jdeveloper 11g and configured the many-to-many association as described in the documentation, so I have accessors in both directions, with composition association and a many-to-many link view. Using the business component browser, the link view works for viewing the data in both directions, as one would expect, however inserting in the detail table fails as follows: the key of the master table is the new value of the detail table's key column instead of the intersection table's foreign key column. Is this a known problem, or is there something I have done wrong?

    If your m-m join table has additional fields there best solution is normally to define a class for the join table.
    i.e.
    beforeProgram
    -m-m-> Assumption
    Assumption
    -m-m-> Program (optional/read-only)
    -> after
    Program
    -1-m-> ProgramAssumptionAssociation (private-owned)
    ProgramAssumptionAssociation
    -1-1-> Program (pk)
    -1-1-> Assumption (pk)
    - createByUser
    - etc.
    Program
    -1-m-> ProgramAssumptionAssociation (independent/optional)
    You could also enable batch-reading or joining on the 1-1 relationship to read the target objects efficiently.

Maybe you are looking for

  • 2012 RMBP HDMI to tv not working

    Bought in august. I connected it to my tv via HDMI cable to test it and it worked fine. I recently tried to plug it in and it goes to a black screen. it will occasionally show glitchey pieces of the desktop but most of the time i just get a black scr

  • Unable to buildserver with ORACLE_XA

    hello all, environment:tuxedo 7.1 on REDHAT Linux7.x, oracle 8 client for linux, database oracle on HPux. 1) I modified the bankapp application to run one database and one set of servers only which will be in oracle. 2)I want to use ORacle's XA.i use

  • AlwaysOn: primary sync or async?

    Hi, I succesfully setup an AlwaysOn between two sql2014 servers for development purposes. I configured both the primary and the secondary as synchronous. Now developers say that it is slower than one single server, and they are right because this con

  • Odd character sizing issue

    I'm having an issue with some odd character sizing (ID cs6). The font I'm using is Avenir Next Condensed Demi Bold (although this issue is happening with other font weights within the same family). The image below shows the problem, the u is slighly

  • How do i uninstall digidesign mbox 2 driver

    how do i uninstall digidesign mbox 2 driver that didn't work on my mac book pro os 10.7.3 lion