One-to-many graph problem

Hi,
I am haviing a crystal report problem. The problem relates to a one-to-many relationship involving two tables.
I have a similar setup to the following:
I have 2 database tables: table1 & table2
table1 consists of 3 fields:
{id#}, {yes/no},{up/down}
table2 consists of 2 fields:
{id#},
the field can contain any of the following values: 'open', 'closed', 'final', 'complete'.
The problem is that there exist many states to one id#.
I have a bar graph in my report that displays a bar for the count of the{yes/no} field and a bar for the count of the {up/down} field. I want also a bar for the count of when the field = 'final'.
What happens when I write a formula for the field in the second table and place it in the 'show values' section of the chart expert, is the count displayed in each bar on the graph increases significantly. I am assuming this is because there are multiple records in table 2 for each record in table 1.
What I want to happen is that the graph displays bar 1 and bar 2 correctly and then when I put in the formula for the third bar, it simply displays that bar with the count for when the field = 'final'. I dont want it to affect the whole garph.
Has anyone got any suggestions on how I can do this?
I have tried messing around with the distinct records setting in crystal and also by writing an sql query specifying DISTINCT keyword instead of using the select expert, but to no avail.
Please please can someone help me with this issue.
Thank you.
J

You can add a 1-1 query key through the code API in a descriptor amendment method. You could also define a selection criteria on the 1-m mapping to filter the type=2.
Example: (see Foundation Library manual 8-17)
OneToOneQueryKey queryKey = new OneToOneQueryKey();
queryKey.setName("organization");
queryKey.setReferenceClass(Organization.class);
ExpressionBuilder builder = new ExpressionBuilder();
queryKey.setJoinCriteria(builder.getField("ORGANIZATION.ORG_ID").equal(builder.getParameter("RELATIONSHIP.PARENT_ID").and(builder.getParamater("RELATIONSHIP.RELATIONSHIP_TYPE").equal(2)));
relationDescriptor.addQueryKey(queryKey);
Example: (of 1-m mapping with selection criteria)
OneToManyMapping mapping = new OneToManyMapping();
mapping.setReferenceClass(Relation.class);
mapping.setTargetForeignKey("RELATION.PARENT_ID");
ExpressionBuilder builder = new ExpressionBuilder();
mapping.setSelectionCriteria(builder.getField("RELATIONSHIP.PARENT_ID").equal(builder.getParameter("ORGANIZATION.ORG_ID").and(builder.getField("RELATIONSHIP.RELATIONSHIP_TYPE").equal(2)));
orgDescriptor.addMapping(mapping);

Similar Messages

  • Aggregate one-to-many relationship problem

    Hello,
    After migrating from Toplink 9i I've stumbled across a problem with our aggregate objects.
    Toplink Workbench reports no errors and generates a nice XML but in runtime I get this error whenever a aggregate function is used.
    [TopLink fin]: 2008.02.13 03:18:11.552--ServerSession(12626425)--Connection(29948747)--Thread(Thread[main,5,main])--SELECT DISTINCT t0.NPL_PACK_ID, t0.NPL_ID FROM NPL_MEDPROD t3, FASS_MEDPROD t2, NPL_MEDPROD t1, NPL_PACKAGE t0 WHERE (((t0.NPL_ID = t1._Presentation->NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test) AND ((t1.NPL_ID = t2.NPL_ID) AND (t3.NPL_ID LIKE '19750613000031%'))) AND (t3.NPL_ID = t2.NPL_ID))
    Caused by: Undantag [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.1.0) (Build 061004)): oracle.toplink.exceptions.DatabaseException
    Internt undantag: java.sql.SQLException: ORA-00911: invalid character
    Felkod: 911
    I belive that problem resides in this clause :
    t1._Presentation->NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test
    I've created a small test project with just a couple of classes but the same aggregate problem occurs which has let me to believe the problem does not come from the migrating process which was my first guess. If anyone could help me discover what I am doing wrong it would be very appreciated. Below is my test project output.
    <?xml version="1.0" encoding="UTF-8"?>
    <toplink:object-persistence version="Oracle TopLink - 10g Release 3 (10.1.3.1.0) (Build 061004)" xmlns:opm="http://xmlns.oracle.com/ias/xsds/opm" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:toplink="http://xmlns.oracle.com/ias/xsds/toplink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <opm:name>test</opm:name>
    <opm:class-mapping-descriptors>
    <opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
    <opm:class>se.lif.fass.fassdata.impl.FASSMedProdImpl</opm:class>
    <opm:alias>FASSMedProdImpl</opm:alias>
    <opm:primary-key>
    <opm:field table="FASS_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </opm:primary-key>
    <opm:events xsi:type="toplink:event-policy"/>
    <opm:querying xsi:type="toplink:query-policy"/>
    <opm:attribute-mappings>
    <opm:attribute-mapping xsi:type="toplink:one-to-one-mapping">
    <opm:attribute-name>_Medprod</opm:attribute-name>
    <opm:reference-class>schemas_npl.instance.impl.MedprodTypeImpl</opm:reference-class>
    <opm:private-owned>true</opm:private-owned>
    <opm:foreign-key>
    <opm:field-reference>
    <opm:source-field table="FASS_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    <opm:target-field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </opm:field-reference>
    </opm:foreign-key>
    <opm:foreign-key-fields>
    <opm:field table="FASS_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </opm:foreign-key-fields>
    <toplink:batch-reading>true</toplink:batch-reading>
    <toplink:selection-query xsi:type="toplink:read-object-query"/>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>id</opm:attribute-name>
    <opm:read-only>true</opm:read-only>
    <opm:field table="FASS_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </opm:attribute-mapping>
    </opm:attribute-mappings>
    <toplink:descriptor-type>independent</toplink:descriptor-type>
    <toplink:instantiation/>
    <toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
    <toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
    <toplink:tables>
    <toplink:table name="FASS_MEDPROD"/>
    </toplink:tables>
    </opm:class-mapping-descriptor>
    <opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
    <opm:class>schemas_npl.instance.impl.MedprodTypeImpl</opm:class>
    <opm:alias>MedprodTypeImpl</opm:alias>
    <opm:primary-key>
    <opm:field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </opm:primary-key>
    <opm:events xsi:type="toplink:event-policy"/>
    <opm:querying xsi:type="toplink:query-policy"/>
    <opm:attribute-mappings>
    <opm:attribute-mapping xsi:type="toplink:aggregate-object-mapping">
    <opm:attribute-name>_Medprodpack</opm:attribute-name>
    <toplink:reference-class>schemas_npl.instance.impl.MedprodTypeImpl$MedprodpackTypeImpl</toplink:reference-class>
    <toplink:allow-null>false</toplink:allow-null>
    <toplink:field-translations>
    <toplink:field-translation>
    <toplink:source-field name="_Presentation->NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test" xsi:type="opm:column"/>
    <toplink:target-field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </toplink:field-translation>
    </toplink:field-translations>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>_Nplid</opm:attribute-name>
    <opm:field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>id</opm:attribute-name>
    <opm:read-only>true</opm:read-only>
    <opm:field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </opm:attribute-mapping>
    </opm:attribute-mappings>
    <toplink:descriptor-type>independent</toplink:descriptor-type>
    <toplink:instantiation/>
    <toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
    <toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
    <toplink:tables>
    <toplink:table name="NPL_MEDPROD"/>
    </toplink:tables>
    </opm:class-mapping-descriptor>
    <opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
    <opm:class>schemas_npl.instance.impl.MedprodTypeImpl$MedprodpackTypeImpl</opm:class>
    <opm:alias>MedprodTypeImpl$MedprodpackTypeImpl</opm:alias>
    <opm:events xsi:type="toplink:event-policy"/>
    <opm:querying xsi:type="toplink:query-policy"/>
    <opm:attribute-mappings>
    <opm:attribute-mapping xsi:type="toplink:one-to-many-mapping">
    <opm:attribute-name>_Presentation</opm:attribute-name>
    <opm:reference-class>schemas_npl.instance.impl.MedprodTypeImpl$MedprodpackTypeImpl$PresentationTypeImpl</opm:reference-class>
    <opm:private-owned>true</opm:private-owned>
    <opm:target-foreign-key>
    <opm:field-reference>
    <opm:source-field table="NPL_PACKAGE" name="NPL_ID" xsi:type="opm:column"/>
    <opm:target-field name="_Presentation->NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test" xsi:type="opm:column"/>
    </opm:field-reference>
    </opm:target-foreign-key>
    <toplink:batch-reading>true</toplink:batch-reading>
    <toplink:container xsi:type="toplink:list-container-policy">
    <toplink:collection-type>com.sun.xml.bind.util.ListImpl</toplink:collection-type>
    </toplink:container>
    <toplink:selection-query xsi:type="toplink:read-all-query">
    <toplink:container xsi:type="toplink:list-container-policy">
    <toplink:collection-type>com.sun.xml.bind.util.ListImpl</toplink:collection-type>
    </toplink:container>
    </toplink:selection-query>
    </opm:attribute-mapping>
    </opm:attribute-mappings>
    <toplink:descriptor-type>aggregate</toplink:descriptor-type>
    <toplink:instantiation/>
    <toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
    <toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
    </opm:class-mapping-descriptor>
    <opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
    <opm:class>schemas_npl.instance.impl.MedprodTypeImpl$MedprodpackTypeImpl$PresentationTypeImpl</opm:class>
    <opm:alias>MedprodTypeImpl$MedprodpackTypeImpl$PresentationTypeImpl</opm:alias>
    <opm:primary-key>
    <opm:field table="NPL_PACKAGE" name="NPL_PACK_ID" xsi:type="opm:column"/>
    </opm:primary-key>
    <opm:events xsi:type="toplink:event-policy"/>
    <opm:querying xsi:type="toplink:query-policy"/>
    <opm:attribute-mappings>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>_Nplpackid</opm:attribute-name>
    <opm:field table="NPL_PACKAGE" name="NPL_PACK_ID" xsi:type="opm:column"/>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:one-to-one-mapping">
    <opm:attribute-name>backref</opm:attribute-name>
    <opm:reference-class>schemas_npl.instance.impl.MedprodTypeImpl</opm:reference-class>
    <opm:foreign-key>
    <opm:field-reference>
    <opm:source-field table="NPL_PACKAGE" name="NPL_ID" xsi:type="opm:column"/>
    <opm:target-field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </opm:field-reference>
    </opm:foreign-key>
    <opm:foreign-key-fields>
    <opm:field table="NPL_PACKAGE" name="NPL_ID" xsi:type="opm:column"/>
    </opm:foreign-key-fields>
    <toplink:indirection xsi:type="toplink:value-holder-indirection-policy"/>
    <toplink:selection-query xsi:type="toplink:read-object-query"/>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>id</opm:attribute-name>
    <opm:read-only>true</opm:read-only>
    <opm:field table="NPL_PACKAGE" name="NPL_ID" xsi:type="opm:column"/>
    </opm:attribute-mapping>
    </opm:attribute-mappings>
    <toplink:descriptor-type>independent</toplink:descriptor-type>
    <toplink:instantiation/>
    <toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
    <toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
    <toplink:tables>
    <toplink:table name="NPL_PACKAGE"/>
    </toplink:tables>
    </opm:class-mapping-descriptor>
    </opm:class-mapping-descriptors>
    <toplink:login xsi:type="toplink:database-login">
    <toplink:platform-class>oracle.toplink.platform.database.oracle.Oracle8Platform</toplink:platform-class>
    <toplink:user-name>fassadmin</toplink:user-name>
    <toplink:password>3CC3773C96563CA0C89634305615359CD62D1A19DF561D1E</toplink:password>
    <toplink:driver-class>oracle.jdbc.driver.OracleDriver</toplink:driver-class>
    <toplink:connection-url>jdbc:oracle:oci8:@DB2</toplink:connection-url>
    </toplink:login>
    </toplink:object-persistence>
    Regards
    /Jonas

    The issue is in the one-to-many mapping in the aggregate,
    <br>
    <opm:attribute-mapping xsi:type="toplink:one-to-many-mapping">
      <opm:attribute-name>_Presentation</opm:attribute-name>
      <opm:reference-class>schemas_npl.instance.impl.MedprodTypeImpl$MedprodpackTypeImpl$PresentationTypeImpl</opm:reference-class>
      <opm:private-owned>true</opm:private-owned>
      <opm:target-foreign-key>
        <opm:field-reference>
          <opm:source-field table="NPL_PACKAGE" name="NPL_ID" xsi:type="opm:column"/>
          <opm:target-field name="_Presentation->NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test" xsi:type="opm:column"/>
        </opm:field-reference>
      </opm:target-foreign-key>There is an issue with the Mapping Workbench and shared aggregates with one-to-many mappings and translating the foreign key fields. Did this work before, I would be surprized if it did, unless the 2.5 Builder was used?
    Anyway the easiest workaround is to either edit the XML and change the NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test column name to what it should be, or define a descriptor amendment method to define the one-to-many mapping with the correct field names.
    -- James : EclipseLink

  • One to many mapping problem

    In my JPA project I'm using these three classes:
    Cart.java:
    package com.spinnaker.pedja;
    import java.sql.Date;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.HashSet;
    import java.util.Set;
    import javax.persistence.*;
    @Entity(name = "Cart")
    @Table(schema = "shop")
    public class Cart {
         @Id
         @Column(name = "cart_id")
         private int Cart_id;
         @Column(name = "cart_date")
         private Date date;
          @OneToMany(mappedBy = "cartItemPK", targetEntity = CartItemPK.class)
          private Set cartitemCollection = new HashSet(0);
         @ManyToOne
         @JoinColumn(name = "customer_id")
         private Customer customer;
         public Customer getCustomer() {
              return customer;
         public void setCustomer(Customer customer) {
              this.customer = customer;
         public Cart() {
          public Set getCartitemCollection() {
          return cartitemCollection;
          public void setCartitemCollection(Set cartitemCollection) {
          this.cartitemCollection = cartitemCollection;
         public int getCart_id() {
              return Cart_id;
         public void setCart_id(int cart_id) {
              this.Cart_id = cart_id;
         public Date getDate() {
              return date;
         public void setDate(Date date) {
              this.date = date;
    }, CartItem.java:
    package com.spinnaker.pedja;
    import java.io.Serializable;
    import javax.persistence.*;
    @Entity
    @Table(schema = "shop")
    public class CartItem implements Serializable {
         @EmbeddedId
         @ManyToOne
    //     @JoinColumn(name = "cart_id")
         CartItemPK cartItemPK;
         @Column(name = "quantity")
         private int quantity;
         @Column(name = "unit_price")
         private double unit_price;
    //     @JoinColumn(name = "cart_id")
    //     private Cart cart;
    //      public Cart getCart() {
    //      return cart;
    //      public void setCart(Cart cart) {
    //      this.cart = cart;
         public CartItem() {
         public CartItemPK getCartItemPK() {
              return cartItemPK;
         public void setCartItemPK(CartItemPK cartItemPK) {
              this.cartItemPK = cartItemPK;
         public int getQuantity() {
              return quantity;
         public void setQuantity(int quantity) {
              this.quantity = quantity;
         public double getUnit_price() {
              return unit_price;
         public void setUnit_price(double unit_price) {
              this.unit_price = unit_price;
    }and CartItemPK.java:
    package com.spinnaker.pedja;
    import java.io.Serializable;
    import javax.persistence.*;
    @Table(schema="shop")
    @Embeddable
    public class CartItemPK implements Serializable{
         @Column(name="item_id",nullable=false)
         private int itemId;
    //     @ManyToOne
    //     @JoinColumn(name = "cart_id")
    //     private Cart cart;
         @Column(name="cart_id",nullable=false)
         private int cartId;
         public int getItemId() {
              return itemId;
         public void setItemId(int itemId) {
              this.itemId = itemId;
         public int getCartId() {
              return cartId;
         public void setCartId(int cartId) {
              this.cartId = cartId;
    I'm having problem with mapping one to many relationship between Cart and CartItem.I had to introduce CartItemPK class because CartItem has composite primary key.Help please!!!

    In my test class I'm using this code:
    Cart cart=em.find(Cart.class, 33);
              Set cartItems=cart.getCartitemCollection();
              for (Iterator iterator = cartItems.iterator(); iterator.hasNext();) {
                   CartItem cart_item = (CartItem) iterator.next();
                   System.out.println(cart_item.getCartItemPK().getCartId());
              }and this error happens:
    Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: com.spinnaker.pedja.Cart.cartitemCollection[com.spinnaker.pedja.CartItemPK]
         at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:247)
         at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
         at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:159)
         at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:95)
         at com.spinnaker.pedja.test.Test.main(Test.java:30)
    Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: com.spinnaker.pedja.Cart.cartitemCollection[com.spinnaker.pedja.CartItemPK]
         at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:979)
         at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:530)
         at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:471)
         at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
         at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1136)
         at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
         at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1121)
         at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1211)
         at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
         at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:847)
         at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:178)
         at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:235)
         ... 4 more
    I didn't find any example on the internet about my particular case.In the database,Cart and CartItem are conected via cart_id field.But in my JPA project,cart_id field is a part of a composite key CarItemPK.

  • One-to-many relationship: problem with several tables on the one side...

    Hello
    I'm having problems developing a database for a content management system. Apart from details, I've got one main table, that holds the tree structure of the content ("resources") and several other tables that contain data of a particular datatype ("documents", "images", etc.). Now, there's one-to-many relationship between "resources" table and all the datatype tables - that is, in the "resources" table there's "resource_id" column, being a foreign key referenced to the "id" columns in the datatype tables.
    The problem is that this design is deficient. I can't tell form the "resource_id" column from which datatype table to get the data. It seems to me that one-to-many relationship only works with two tables. If the data on the one side of the relationship is contained in several tables, problems arise.
    Anybody knows a solution? I would be obliged.
    Regards
    Havocado

    Hi;
    A simple way may be create a view on referenced tables:
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL>
    SQL> drop table resources;
    Table dropped
    SQL> create table resources(id number, name varchar2(12));
    Table created
    SQL> insert into resources values(1,'Doc....');
    1 row inserted
    SQL> insert into resources values(2,'Img....');
    1 row inserted
    SQL> drop table documents;
    Table dropped
    SQL> create table documents(id number, resource_id number,type varchar2(12));
    Table created
    SQL> insert into documents values(1,1,'txt');
    1 row inserted
    SQL> drop table images;
    Table dropped
    SQL> create table images(id number, resource_id number,path varchar2(24));
    Table created
    SQL> insert into images values(1,2,'/data01/images/img01.jpg');
    1 row inserted
    SQL> create or replace view vw_resource_ref as
      2    select id, resource_id, type, null as path from documents
      3      union
      4     select id, resource_id, null as type, path from images;
    View created
    SQL> select * from resources r inner join vw_resource_ref rv on r.id = rv.resource_id;
            ID NAME                 ID RESOURCE_ID TYPE         PATH
             1 Doc....               1           1 txt         
             2 Img....               1           2              /data01/images/img01.jpg
    SQL> Regards....

  • One-to-many relationships problem

    Hi,
    I'm having some problems with one-to-many relationships.
    I've a two way relationship beetwen Person and Document.
    Person has a collection of Documents (1-n).
    Document has an instance for Person.
    In my database schema Document has a FK for person.
    The problem occurs when I'm trying to save the Person object
    with a collection of Documents.
    Oracle gives me the following message:
    ORA-00001: unique constraint (SMS.PK_PERSON) violated
    In my kodo.properties file I put:
    kodo.jdbc.ForeignKeyConstraints: true
    It seems that when the collection of Documents is persisted, kodo tries to
    save a new Person object for each Document.
    When I have just one instance of Document in my collection kodo persists
    it ok, but when I have move instances I get
    that problem.
    Can somebody help me?
    Thanks in advance,
    Joan Caffee

    You need to make sure each Document references the same Person object in
    the JVM. JDO persists your object model as-is. Each distinct JVM
    object becomes a distinct database record. You can't have multiple JVM
    objects in the same PersistenceManager representing the same database
    record.

  • One-to-Many CMR problem

    I am trying to get Container Managed Relationships working with Oracle Application Server. I am sure that the problem it quite obvious to anyone who has got this working before, but after carefully following numerous examples, I still cant get them to work. I have various issues including the application server blocking when it calls the getB() method in "A" to populate the items from table "B", even though the generated SQL looks okay e.g., "select B_PK from B where (b_fk = 1)".
    I would be extremely grateful if you could point out my (hopefully obvious) mistake as I wrestled with it for the past couple of weeks.
    Any ideas?
    Cheers,
    Jonathan
    I have two tables A and B; A has a one-to-many relationship with B:
    Table A:
         A_PK          (primary key)
         A_NAME
    Table B:
         B_PK          (primary key)
         B_NAME
         B_FK          (foreign key to table A)
    My ejb-jar.xml file is:
    <ejb-jar>
    <enterprise-beans>
    <entity>
    <description>Entity Bean ( CMP )</description>
    <display-name>A</display-name>
    <ejb-name>A</ejb-name>
    <home>mypackage1.AHome</home>
    <remote>mypackage1.A</remote>
    <local-home>mypackage1.ALocalHome</local-home>
    <local>mypackage1.ALocal</local>
    <ejb-class>mypackage1.impl.ABean</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>java.lang.Long</prim-key-class>
    <reentrant>False</reentrant>
    <cmp-version>2.x</cmp-version>
    <abstract-schema-name>A</abstract-schema-name>
    <cmp-field><field-name>a_pk</field-name></cmp-field>
    <cmp-field><field-name>a_name</field-name></cmp-field>
    <primkey-field>a_pk</primkey-field>
    </entity>
    <entity>
    <description>Entity Bean ( CMP )</description>
    <display-name>B</display-name>
    <ejb-name>B</ejb-name>
    <home>mypackage1.BHome</home>
    <remote>mypackage1.B</remote>
    <local-home>mypackage1.BLocalHome</local-home>
    <local>mypackage1.BLocal</local>
    <ejb-class>mypackage1.impl.BBean</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>java.lang.Long</prim-key-class>
    <reentrant>False</reentrant>
    <cmp-version>2.x</cmp-version>
    <abstract-schema-name>B</abstract-schema-name>
    <cmp-field><field-name>b_pk</field-name></cmp-field>
    <cmp-field><field-name>b_name</field-name></cmp-field>
    <cmp-field><field-name>b_fk</field-name></cmp-field>
    <primkey-field>b_pk</primkey-field>
    </entity>
    </enterprise-beans>
    <relationships>
    <ejb-relation>
    <ejb-relation-name>A-B</ejb-relation-name>
    <ejb-relationship-role>
    <multiplicity>One</multiplicity>
    <cascade-delete/>
    <relationship-role-source>
    <ejb-name>A</ejb-name>
    </relationship-role-source>
    <cmr-field>
    <cmr-field-name>b</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    <ejb-relationship-role>
    <multiplicity>Many</multiplicity>
    <relationship-role-source>
    <ejb-name>B</ejb-name>
    </relationship-role-source>
    </ejb-relationship-role>
    </ejb-relation>
    </relationships>
    </ejb-jar>
    And my orion-ejb-jar.xml file is:
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <!DOCTYPE orion-ejb-jar PUBLIC "-//Evermind//DTD Enterprise JavaBeans 1.1 runtime//EN" "http://xmlns.oracle.com/ias/dtds/orion-ejb-jar.dtd">
    <orion-ejb-jar>
    <enterprise-beans>
    <entity-deployment name="A" copy-by-value="false" data-source="jdbc/Connection1DS" exclusive-write-access="false" table="a">
    <primkey-mapping>
    <cmp-field-mapping name="a_pk" persistence-name="a_pk"
    persistence-type="int(11)"/>
    </primkey-mapping>
    <cmp-field-mapping name="a_pk" persistence-name="a_pk"
    persistence-type="int(11)"/>
    <cmp-field-mapping name="a_name" persistence-name="a_name"
    persistence-type="varchar(100)"/>
    <cmp-field-mapping name="b">
    <collection-mapping table="B">
    <primkey-mapping>
    <cmp-field-mapping name="b_fk" persistence-name="B_FK"/>
    </primkey-mapping>
    <value-mapping type="mypackage1.BLocal">
    <cmp-field-mapping>
    <entity-ref home="B">
    <cmp-field-mapping name="b_pk" persistence-name="B_PK"/>
    </entity-ref>
    </cmp-field-mapping>
    </value-mapping>
    </collection-mapping>
    </cmp-field-mapping>
    </entity-deployment>
    <entity-deployment name="B" copy-by-value="false" data-source="jdbc/Connection1DS" exclusive-write-access="false" table="b">
    <primkey-mapping>
    <cmp-field-mapping name="b_pk" persistence-name="b_pk"
    persistence-type="int(11)"/>
    </primkey-mapping>
    <cmp-field-mapping name="b_pk"
    persistence-name="b_pk" persistence-type="int(11)"/>
    <cmp-field-mapping name="b_fk" persistence-name="b_fk"
    persistence-type="int(11)"/>
    </entity-deployment>
    </enterprise-beans>
    <assembly-descriptor>
    <default-method-access>
    <security-role-mapping impliesAll="true" name="&lt;default-ejb-caller-role>"/>
    </default-method-access>
    </assembly-descriptor>
    </orion-ejb-jar>

    Ok, I found out something strange. If I do the addPet operation twice in the client the new relationship is created, too.
    p = home.create("Violetta");
    p.addNewPet("Jenny");
    p = home.create("Frank");
    p.addPet("Jenny");
    p.addPet("Jenny");
    May this be a timing problem? Or is there a command I could execute to ensure all data manipulation is populated to the DB. (Like close() in JDBC)
    TIA
    Frank

  • Persistence and transactions: One-to-many consistency problem

    Hi,
    we have the following problem: We have two persistent classes A and B that are connected via a one-to-many (1:n) relationship. Now we
    1. get an object "a" of class A and a number of related objects of class B from the persistence manager. Then we
    3. delete the relationship between "a" and one object of class B. Then (without commit)
    4. the GUI requests to show all related Bs for our given "a" and:
    5. the query returns also the "deleted" object.
    All these steps are performed within the same (object oriented) top level transaction.
    The reason for this seems clear to us: The removal of the B has not been persisted in the DB. However, we don't really know how to deal with it...
    Any suggestion is welcome.
    Christoph

    Hi Chris,
    it is unclear to me if you are re-reading the database after you delete the 'b' item.
    Anyway, the way persistent objects work is that changes are not written to the database until the SAP LUW ends with a COMMIT WORK.
    Cheers
    Graham Robbo

  • One to many? problems

    Hi.
    I,m trying to combine two tables into one. Table 1 is persons. Table two is movies. Table to insert in is, lets say per_mov_table
    I'm building a form that will get values from both tables 1 and 2 and insert into a new one.
    In that form I can select a person from a dropdown list. And select movies from a select list. Its
    possible to select multiple movies per person.
    I,m trying with the ADDT behaviors. but I get some strange results.
    Lets say I select person nr 2 and movies 2,3 and 4 in the form. Then I would expect results in new table to be something like: (id_fk_pers id_fk_mov are the foregin keys)
    id_per_mov_table    id_fk_pers    id_fk_mov
    1                                   2                       2
    2                                   2                       3
    3                                   2                       4
    instead the output is:
    id_per_mov_table    id_fk_pers    id_fk_mov
    1                                   2                       1
    2                                   77                      2
    3                                   77                      3
    4                                   77                      4
    First it inserts a new row with som bogus value that I dont know where it comes from
    Then it seemes that the id_fk_pers have som sort of autoincrement because if I do the same insert again I get
    id_per_mov_table    id_fk_pers    id_fk_mov
    1                                   2                       1
    2                                   80                      2
    3                                   80                      3
    4                                   80                      4
    So id_fk_pers is not getting the person id from the persons table. it is linked together with pers_id and id_fk_pers.
    So what am I to do? I'm desperate to get this working.
    I dont care how to do it but the goal is to show a detail page with one person and many movies with a ?pers_id link from another page.
    Regards
    Olle
    ps. sorry for the long post

    Hi.
    I,m trying to combine two tables into one. Table 1 is persons. Table two is movies. Table to insert in is, lets say per_mov_table
    I'm building a form that will get values from both tables 1 and 2 and insert into a new one.
    In that form I can select a person from a dropdown list. And select movies from a select list. Its
    possible to select multiple movies per person.
    I,m trying with the ADDT behaviors. but I get some strange results.
    Lets say I select person nr 2 and movies 2,3 and 4 in the form. Then I would expect results in new table to be something like: (id_fk_pers id_fk_mov are the foregin keys)
    id_per_mov_table    id_fk_pers    id_fk_mov
    1                                   2                       2
    2                                   2                       3
    3                                   2                       4
    instead the output is:
    id_per_mov_table    id_fk_pers    id_fk_mov
    1                                   2                       1
    2                                   77                      2
    3                                   77                      3
    4                                   77                      4
    First it inserts a new row with som bogus value that I dont know where it comes from
    Then it seemes that the id_fk_pers have som sort of autoincrement because if I do the same insert again I get
    id_per_mov_table    id_fk_pers    id_fk_mov
    1                                   2                       1
    2                                   80                      2
    3                                   80                      3
    4                                   80                      4
    So id_fk_pers is not getting the person id from the persons table. it is linked together with pers_id and id_fk_pers.
    So what am I to do? I'm desperate to get this working.
    I dont care how to do it but the goal is to show a detail page with one person and many movies with a ?pers_id link from another page.
    Regards
    Olle
    ps. sorry for the long post

  • One to Many Report Problem

    I have an Item table and an Orders table linked for which I want to select certain Items and related Orders. The tables are linked via an Item No field.  I want to select all items for which the total of (QOH + QOO - Reqmts) is negative.  There can be multiple Orders for each item, or there can be no Orders for an item.  The Items I want listed are those in the negative as stated above.
    I have a formula which calculates Availability (QOH + open orders - requirements).  QOH and requirements are straightforward and in the Items table.  The open orders are a Running Total field for orders that are open and for which there is still a balance due. 
    My problem is that my report only lists those Items that have Orders associated with them.  I also need Items that have no orders associated with them.  When I tinker with the join type and the enforcement I get way too much data returned.
    Are there any suggestions on how I can get the desired result?
    Thanks.

    OK, I think I understand.
    The problem you're facing here is that as soon as you use a field from the MOS table, you'll lose all the IM records which have no orders, because the MOS fields are all null for those records. Unless you 'protect' them, which is what I'm trying to explain.
    The best place for you to start is with a simple query which doesn't include any fields from the MOS table, like {IM.IM_PROD_CODE} in "020" to "073". Try this without any MOS fields displayed in the report initially, and then add a couple. I don't think this will knock out your nulls, but it might. No formulas, just fields.
    Now add the second line
    and {MOS.MOS_STATUS} <= 1.00
    This will knock out the nulls because you're accessing the MOS table in an unprotected way. The reason is that as soon as you use a null value in a formula, the record is automatically rejected.
    But if you change your formula to something like this:
    {IM.IM_PROD_CODE} in "020" to "073"
    and ( isnull({MOS-IM-KEY})
        or ( not  isnull({MOS-IM-KEY} and {MOS.MOS_STATUS} <= 1.00 ) )
    you should find that the null records stay.
    Now if you've got another formula which accesses the MOS table, you need to cater for the nulls there too. For example, if you need to access the quantity of the item (lets say it's called Qty), you might need to do the following:
    local numbervar Qty := if isnull({MOS.QTY} then 0 else {MOS.QTY};
    and so on.
    But because you're new to this you need to build it up slowly, watching that your null records don't disappear.
    Andrew

  • One to Many Conversion Problem

    Hi Guys,
    I have a source table and conataining different attributes. i want to do this thing
    Source_Name=Targ_first name + Targ_Last name
    Exp: Source name= Tanvir Mughal
    I want to store in target table
    targ_first_name=Tanvir
    targ_last_name=Mughal
    similer problem with address i want to break it into multiple fields
    How i can do this. Should i write a query in expression operator if it is then please write that query. I am a student and working on a semester project.
    Please help me i shall be thankful to you for this kind.

    This will work if you have 2 names only. If the guys name is 'AAAA BBBB CCCC', It won't work. Then, you'll have to use a LOOP to control it.
    SQL> CREATE OR REPLACE PROCEDURE ONE_TO_MANY(V_FULL_NAME VARCHAR2) AS
    2 V_FIRST_NAME VARCHAR2(50);
    3 V_LAST_NAME VARCHAR2(50);
    4 V_INI NUMBER;
    5 V_END NUMBER;
    6 V_LENGTH NUMBER;
    7 BEGIN
    8
    9 V_LENGTH := LENGTH(V_FULL_NAME);
    10 V_END := INSTR(V_FULL_NAME, ' ');
    11 V_FIRST_NAME := SUBSTR(V_FULL_NAME, 1, (V_END-1));
    12 V_LAST_NAME := SUBSTR(V_FULL_NAME, (V_END + 1), V_LENGTH);
    13
    14 DBMS_OUTPUT.PUT_LINE('FIRST NAME '||V_FIRST_NAME);
    15 DBMS_OUTPUT.PUT_LINE('LAST NAME '||V_LAST_NAME);
    16
    17 END;
    18
    19 /
    Procedure created.
    SQL> set serveroutput on
    SQL> EXEC ONE_TO_MANY('MARCOS FRANCO');
    FIRST NAME MARCOS
    LAST NAME FRANCO
    PL/SQL procedure successfully completed.

  • JPA One-To-Many Parent-Child Mapping Problem

    I am trying to map an existing legacy Oracle schema that involves a base class table and two subclass tables that are related by a one-to-many relationship which is of a parent-child nature.
    The following exception is generated. Can anybody provide a suggestion to fix the problem?
    Exception [EclipseLink-45] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DescriptorException
    Exception Description: Missing mapping for field [BASE_OBJECT.SAMPLE_ID].
    Descriptor: RelationalDescriptor(domain.example.entity.Sample --> [DatabaseTable(BASE_OBJECT), DatabaseTable(SAMPLE)])
    The schema is as follows:
    CREATE TABLE BASE_OBJECT(
    "BASE_OBJECT_ID" INTEGER PRIMARY KEY NOT NULL,
    "NAME" VARCHAR2(128) NOT NULL,
    "DESCRIPTION" CLOB NOT NULL,
    "BASE_OBJECT_KIND" NUMBER(5,0) NOT NULL );
    CREATE TABLE SAMPLE(
    "SAMPLE_ID" INTEGER PRIMARY KEY NOT NULL,
    "SAMPLE_TEXT" VARCHAR2(128) NOT NULL )
    CREATE TABLE SAMPLE_ITEM(
    "SAMPLE_ITEM_ID" INTEGER PRIMARY KEY NOT NULL,
    "SAMPLE_ID" INTEGER NOT NULL,
    "QUANTITY" INTEGER NOT NULL )
    The entities are related as follows:
    SAMPLE.SAMPLE_ID -> BASE_OBJECT.BASE_OBJECT_ID - The PKs that are used to join the sample to the base class
    SAMPLE_ITEM.SAMPLE_ITEM_ID -> BASE_OBJECT.BASE_OBJECT_ID - The PKs that are used to join the sample item to the base class
    SAMPLE_ITEM.SAMPLE_ID -> SAMPLE.SAMPLE_ID - The FK that is used to join the sample item to the sample class as a child of the parent.
    SAMPLE is one to many SAMPLE_ITEM
    The entity classes are as follows:
    @Entity
    @Table( name = "BASE_OBJECT" )
    @Inheritance( strategy = InheritanceType.JOINED )
    @DiscriminatorColumn( name = "BASE_KIND", discriminatorType = DiscriminatorType.INTEGER )
    @DiscriminatorValue( "1" )
    public class BaseObject
    extends SoaEntity
    @Id
    @GeneratedValue( strategy = GenerationType.SEQUENCE, generator = "BaseObjectIdSeqGen" )
    @SequenceGenerator( name = "BaseObjectIdSeqGen", sequenceName = "BASE_OBJECT_PK_SEQ", allocationSize = 1 )
    @Column( name = "BASE_ID" )
    private long baseObjectId = 0;
    @Entity
    @Table( name = "SAMPLE" )
    @PrimaryKeyJoinColumn( name = "SAMPLE_ID" )
    @AttributeOverride(name="baseObjectId", column=@Column(name="SAMPLE_ID"))
    @DiscriminatorValue( "2" )
    public class Sample
    extends BaseObject
    @OneToMany( cascade = CascadeType.ALL )
    @JoinColumn(name="SAMPLE_ID",referencedColumnName="SAMPLE_ID")
    private List<SampleItem> sampleItem = new LinkedList<SampleItem>();
    @Entity
    @Table( name = "SAMPLE_ITEM" )
    @PrimaryKeyJoinColumn( name = "SAMPLE_ITEM_ID" )
    @AttributeOverride(name="baseObjectId", column=@Column(name="SAMPLE_ITEM_ID"))
    @DiscriminatorValue( "3" )
    public class SampleItem
    extends BaseObject
    @Basic( optional = false )
    @Column( name = "SAMPLE_ID" )
    private long sampleId = 0;
    Edited by: Chris-R on Mar 2, 2010 4:45 PM

    Thanks for the thoroughness. There was a mistake in moving the code over for the forum. The field names are correct throughout the original source code.
    BASE_OBJECT_ID is used throughout.
    I suspect the problem lies in the one-to-many sampleItem(s) relationship that is based upon the subclassed item class. (The relationship is actually "sampleItems" in the real code and somehow got changed in the move over.)
    The problem may lie in the mapping of the attribute override in the child class to the referencing of the item class from the parent side of the relationship in the Sample class.
    I further suspect this may be specific to Eclipselink based upon other postings I've seen on the web that have similar problems...
    Any thoughts?
    Edited by: Chris-R on Mar 3, 2010 9:56 AM

  • One to many mappings delete problem

    in using Toplink 9.0.3, I have modeled a simple one to many relationships and have ran into errors on deletion.
    The following is an object model that fails to delete
    diagram has one to many companies ( privately held )
    companies have one to many ownerships ( privately held )
    ownerships have a one to one to an owner company and an owned company ( not privately held ).
    In the simplest scenario, Toplink knows how to delete a diagram. It will delete an ownership, then delete the companies and then delete the diagram.
    However in a diagram where a company owns two companies, Toplink fails. It attempts to delete an owned company before deleting the parent Ownership.
    Note that if toplink deleted the owner company then, it would know to delete the many ownerships first.
    How do we tell toplink that on deleting a company,
    1. delete all the ownerships in its one to many
    2. and delete all the ownerships in which the company
    plays the role as an owned company.
    Note that deleting an ownership should not trigger a deletion of either the owner company or the owned company.
    please contact at [email protected]

    Hello,
    You appear to be missing a mapping in your object model.
    TopLink decides its commit order, for both insertions and deletions based on the ONE TO ONE mappings in a project.
    It appears that your company has no ONE TO ONE mapping to the diagram, which means that TopLink MAY decide to delete diagrams before it deletes companies.
    I would suggest that you try adding a one to one mapping from company to diagram, correctly populated, and see if the problem recurs.
    I hope this is of some help,
    Christian

  • One to many problem onan existing shema

    I'm trying to do an insert in a database using one-to-many mapping.
    I have two tables on an existing schema.
    The two tables are:
    ANAG
    | ID_ANAG     | RAG_SOC |
    |-------------------------|
    |     1     | a name |
    |-------------------------|
    | ...     | .....     |
    |-------------------------|
    INDI
    | ID_INDI     | ID_ENTITA     | INDIRIZZO|
    |-------------------------------------------
    | 101          | 1          | address 1|
    |------------------------------------------|
    | 102          | 1          | address 2|
    |------------------------------------------|
    | 103          | ....          | ....     |
    |------------------------------------------|
    One ANAG can have m INDI. Given an ANAG I can find the related INDI(s)
    with the relation
    ANAG.ID_ANAG=INDI.ID_ENTITA
    My two java classes are:
    package domain;
    import java.util.*;
    public class Anagrafica
    private int idAnag; //ID_ANAG
    private String ragSoc;
    private HashSet indis;
    // default constructor
    //get and set methods
    package domain;
    public class Indi
    private int idIndi; //ID_INDI
    private long idAnag; //ID_ENTITA
    private String indirizzo; //INDIRIZZO
    private Anagrafica anagrafica;
    // default constructor
    //get and set methods
    Anagrafica.jdo:
    <?xml version="1.0"?>
    <!-- This JDO Metadata file was auto-generated on 08/10/02 17.44.
    See http://www.solarmetric.com for Kodo JDO Documentation and examples. -->
    <jdo>
    <package name="domain">
    <class name="Anagrafica"
    identity-type="application"
    objectid-class="domain.AnagraficaPK">
    <extension key="table" value="ANAG" vendor-name="kodo"/>
    <extension key="class-column" value="none" vendor-name="kodo"/>
    <extension key="lock-column" value="none" vendor-name="kodo"/>
    <field name="idAnag" primary-key="true">
    <extension key="data-column" value="ID_ANAG"
    vendor-name="kodo"/>
    </field>
    <field name="ragSoc">
    <extension key="data-column" value="RAG_SOC"
    vendor-name="kodo"/>
    </field>
    <field name="indis">
    <collection element-type="domain.Indi"/>
    <extension vendor-name="kodo" key="inverse"
    value="anagrafica"/>
         </field>
    </class>
    </package>
    </jdo>
    Indi.jdo
    <?xml version="1.0"?>
    <!-- This JDO Metadata file was auto-generated on 08/10/02 17.21.
    See http://www.solarmetric.com for Kodo JDO Documentation and examples. -->
    <jdo>
    <package name="domain">
    <class name="Indi"
    identity-type="application" objectid-class="domain.IndiPK">
    <extension key="table" value="INDI" vendor-name="kodo"/>
    <extension key="class-column" value="none" vendor-name="kodo"/>
    <extension key="lock-column" value="none" vendor-name="kodo"/>
    <field name="idIndi" primary-key="true">
    <extension key="data-column" value="ID_INDI"
    vendor-name="kodo"/>
    </field>
    <field name="idAnag">
    <extension key="data-column" value="ID_ENTITA"
    vendor-name="kodo"/>
    </field>
    <field name="indirizzo">
    <extension key="data-column" value="INDIRIZZO"
    vendor-name="kodo"/>
    </field>
    <field name="anagrafica"/>
    </class>
    </package>
    </jdo>
    When I run the test program and I try to insert a new Anagrafica object I
    get the exception:
    [ C:3974641; S:1673361; T:3317565; D:09/10/02 16.03 ] INSERT INTO
    ANAG(ID_ANAG, RAG_SOC) VALUES
    (-914917554, 'A NEW RAGSOC')[ C:3974641; S:7389395; T:3317565; D:09/10/02
    16.03 ] INSERT INTO
    INDI(INDIRIZZO, IDANAG_ANAGRAFICAX, ID_INDI, ID_ENTITA) VALUES ('via 25
    dicembre', NULL,
    -914917554,0)javax.jdo.JDOFatalDataStoreException:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper: [SQL=INSERT INTO
    INDI(INDIRIZZO,
    IDANAG_ANAGRAFICAX, ID_INDI, ID_ENTITA) VALUES ('via 25 dicembre', NULL,
    -914917554,0)] ORA-00904:
    invalid column name
    [code=904;state=42000]
    NestedThrowables:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper: [SQL=INSERT INTO
    INDI(INDIRIZZO,
    IDANAG_ANAGRAFICAX, ID_INDI, ID_ENTITA) VALUES ('via 25 dicembre', NULL,
    -914917554, 0)] ORA-00904:
    invalid column name
    [ C:3974641; T:3317565; D:09/10/02 16.03 ] roll back data store
    transaction     at
    com.solarmetric.kodo.impl.jdbc.runtime.SQLExceptions.throwFatal(SQLExceptions.java:17)     at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.insert(JDBCStoreManager.java:421)     at
    com.solarmetric.kodo.runtime.StateManagerImpl.insert(StateManagerImpl.java:1783)     at
    com.solarmetric.kodo.runtime.PNewState.flush(PNewState.java:31)     at
    com.solarmetric.kodo.runtime.StateManagerImpl.flush(StateManagerImpl.java:372)     at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:426)     at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:295)     at
    test.AnagraficaJdo.main(AnagraficaJdo.java:49)NestedThrowablesStackTrace:java.sql.SQLException:
    ORA-00904: invalid column name
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)     at
    oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)     at
    oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)     at
    oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)     at
    oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822)     at
    oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1446)     at
    oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1371)     at
    oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1900)     at
    oracle.jdbc.driver.OracleStatement.doScrollStmtExecuteQuery(OracleStatement.java:5290)     at
    oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:697)     at
    com.solarmetric.kodo.impl.jdbc.datasource.StatementImpl.executeUpdate(StatementImpl.java:78)     at
    com.solarmetric.kodo.impl.jdbc.sql.NonSelectingSQL.execute(NonSelectingSQL.java:40)     at
    com.solarmetric.kodo.impl.jdbc.ormapping.ClassMapping.insert(ClassMapping.java:391)     at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.insert(JDBCStoreManager.java:416)     at
    com.solarmetric.kodo.runtime.StateManagerImpl.insert(StateManagerImpl.java:1783)     at
    com.solarmetric.kodo.runtime.PNewState.flush(PNewState.java:31)     at
    com.solarmetric.kodo.runtime.StateManagerImpl.flush(StateManagerImpl.java:372)     at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:426)     at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:295)     at
    test.AnagraficaJdo.main(AnagraficaJdo.java:49)
    How can I resolve the problem of the presence of IDANAG_ANAGRAFICAX and
    have the 1-m relation?
    Thank you in advance.
    Mirko

    I've changed the Indi class and the metadata but I still get an exception:
    javax.jdo.JDOFatalDataStoreException:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper:
    [SQL=INSERT INTO INDI
    (INDIRIZZO, IDANAG_ANAGRAFICAX, ID_INDI, IDANAGX) VALUES
    ('via 25 dicembre', NULL, -847766554, 0)]
    ORA-00904: invalid column name
    I know I'm missing something but I don't know what.
    I can't find any simple example of a one-to-many mapping of two tables on
    an existing schema.
    The final SQL should be: INSERT INTO INDI(INDIRIZZO, ID_ENTITA, ID_INDI)
    VALUES ('via 25 dicembre', -847766554, -847766554)
    thank you in advance for help
    Fred Lucas wrote:
    You should not have both primitive fields for the data in the tables and
    relations to other persistence-capable objects. So, your Indi class and
    metadata should probably look something like this:
    package domain;
    public class Indi
    private int idIndi; //ID_INDI
    private String indirizzo; //INDIRIZZO
    private Anagrafica anagrafica;
    // default constructor
    //get and set methods
    Indi.jdo
    <?xml version="1.0"?>
    <!-- This JDO Metadata file was auto-generated on 08/10/02 17.21.
    See http://www.solarmetric.com for Kodo JDO Documentation and examples. -->
    <jdo>
    <package name="domain">
    <class name="Indi"
    identity-type="application" objectid-class="domain.IndiPK">
    <extension key="table" value="INDI" vendor-name="kodo"/>
    <extension key="class-column" value="none" vendor-name="kodo"/>
    <extension key="lock-column" value="none" vendor-name="kodo"/>
    <field name="idIndi" primary-key="true">
    <extension key="data-column" value="ID_INDI"
    vendor-name="kodo"/>
    </field>
    <field name="indirizzo">
    <extension key="data-column" value="INDIRIZZO"
    vendor-name="kodo"/>
    </field>
    <field name="anagrafica">
    <extension key="data-column" value="ID_ENTITA"
    vendor-name="kodo"/>
    </field>
    </class>
    </package>
    </jdo>
    -Fred
    In article <[email protected]>, Mirko wrote:
    I'm trying to do an insert in a database using one-to-many mapping.
    I have two tables on an existing schema.
    The two tables are:
    ANAG
    | ID_ANAG     | RAG_SOC |
    |-------------------------|
    |     1     | a name |
    |-------------------------|
    | ...     | .....     |
    |-------------------------|
    INDI
    | ID_INDI     | ID_ENTITA     | INDIRIZZO|
    |-------------------------------------------
    | 101          | 1          | address 1|
    |------------------------------------------|
    | 102          | 1          | address 2|
    |------------------------------------------|
    | 103          | ....          | ....     |
    |------------------------------------------|
    One ANAG can have m INDI. Given an ANAG I can find the related INDI(s)
    with the relation
    ANAG.ID_ANAG=INDI.ID_ENTITA
    My two java classes are:
    package domain;
    import java.util.*;
    public class Anagrafica
    private int idAnag; //ID_ANAG
    private String ragSoc;
    private HashSet indis;
    // default constructor
    //get and set methods
    package domain;
    public class Indi
    private int idIndi; //ID_INDI
    private long idAnag; //ID_ENTITA
    private String indirizzo; //INDIRIZZO
    private Anagrafica anagrafica;
    // default constructor
    //get and set methods
    Anagrafica.jdo:
    <?xml version="1.0"?>
    <!-- This JDO Metadata file was auto-generated on 08/10/02 17.44.
    See http://www.solarmetric.com for Kodo JDO Documentation and examples. -->
    <jdo>
    <package name="domain">
    <class name="Anagrafica"
    identity-type="application"
    objectid-class="domain.AnagraficaPK">
    <extension key="table" value="ANAG" vendor-name="kodo"/>
    <extension key="class-column" value="none" vendor-name="kodo"/>
    <extension key="lock-column" value="none" vendor-name="kodo"/>
    <field name="idAnag" primary-key="true">
    <extension key="data-column" value="ID_ANAG"
    vendor-name="kodo"/>
    </field>
    <field name="ragSoc">
    <extension key="data-column" value="RAG_SOC"
    vendor-name="kodo"/>
    </field>
    <field name="indis">
    <collection element-type="domain.Indi"/>
    <extension vendor-name="kodo" key="inverse"
    value="anagrafica"/>
         </field>
    </class>
    </package>
    </jdo>
    Indi.jdo
    <?xml version="1.0"?>
    <!-- This JDO Metadata file was auto-generated on 08/10/02 17.21.
    See http://www.solarmetric.com for Kodo JDO Documentation and examples. -->
    <jdo>
    <package name="domain">
    <class name="Indi"
    identity-type="application" objectid-class="domain.IndiPK">
    <extension key="table" value="INDI" vendor-name="kodo"/>
    <extension key="class-column" value="none" vendor-name="kodo"/>
    <extension key="lock-column" value="none" vendor-name="kodo"/>
    <field name="idIndi" primary-key="true">
    <extension key="data-column" value="ID_INDI"
    vendor-name="kodo"/>
    </field>
    <field name="idAnag">
    <extension key="data-column" value="ID_ENTITA"
    vendor-name="kodo"/>
    </field>
    <field name="indirizzo">
    <extension key="data-column" value="INDIRIZZO"
    vendor-name="kodo"/>
    </field>
    <field name="anagrafica"/>
    </class>
    </package>
    </jdo>
    When I run the test program and I try to insert a new Anagrafica object I
    get the exception:
    [ C:3974641; S:1673361; T:3317565; D:09/10/02 16.03 ] INSERT INTO
    ANAG(ID_ANAG, RAG_SOC) VALUES
    (-914917554, 'A NEW RAGSOC')[ C:3974641; S:7389395; T:3317565; D:09/10/02
    16.03 ] INSERT INTO
    INDI(INDIRIZZO, IDANAG_ANAGRAFICAX, ID_INDI, ID_ENTITA) VALUES ('via 25
    dicembre', NULL,
    -914917554,0)javax.jdo.JDOFatalDataStoreException:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper: [SQL=INSERT INTO
    INDI(INDIRIZZO,
    IDANAG_ANAGRAFICAX, ID_INDI, ID_ENTITA) VALUES ('via 25 dicembre', NULL,
    -914917554,0)] ORA-00904:
    invalid column name
    [code=904;state=42000]
    NestedThrowables:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper: [SQL=INSERT INTO
    INDI(INDIRIZZO,
    IDANAG_ANAGRAFICAX, ID_INDI, ID_ENTITA) VALUES ('via 25 dicembre', NULL,
    -914917554, 0)] ORA-00904:
    invalid column name
    [ C:3974641; T:3317565; D:09/10/02 16.03 ] roll back data store
    transaction     at
    com.solarmetric.kodo.impl.jdbc.runtime.SQLExceptions.throwFatal(SQLExceptions.java:17)     at
    >>
    >>
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.insert(JDBCStoreManager.java:421)     at
    >>
    >>
    com.solarmetric.kodo.runtime.StateManagerImpl.insert(StateManagerImpl.java:1783)     at
    >>
    com.solarmetric.kodo.runtime.PNewState.flush(PNewState.java:31)     at
    com.solarmetric.kodo.runtime.StateManagerImpl.flush(StateManagerImpl.java:372)     at
    >>
    >>
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:426)     at
    >>
    >>
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:295)     at
    >>
    >>
    test.AnagraficaJdo.main(AnagraficaJdo.java:49)NestedThrowablesStackTrace:java.sql.SQLException:
    >>
    ORA-00904: invalid column name
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)     at
    oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)     at
    oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)     at
    oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)     at
    oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822)     at
    oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1446)     at
    >>
    >>
    oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1371)     at
    >>
    >>
    oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1900)     at
    >>
    >>
    oracle.jdbc.driver.OracleStatement.doScrollStmtExecuteQuery(OracleStatement.java:5290)     at
    >>
    >>
    oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:697)     at
    >>
    >>
    com.solarmetric.kodo.impl.jdbc.datasource.StatementImpl.executeUpdate(StatementImpl.java:78)     at
    >>
    >>
    com.solarmetric.kodo.impl.jdbc.sql.NonSelectingSQL.execute(NonSelectingSQL.java:40)     at
    >>
    >>
    com.solarmetric.kodo.impl.jdbc.ormapping.ClassMapping.insert(ClassMapping.java:391)     at
    >>
    >>
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.insert(JDBCStoreManager.java:416)     at
    >>
    >>
    com.solarmetric.kodo.runtime.StateManagerImpl.insert(StateManagerImpl.java:1783)     at
    >>
    com.solarmetric.kodo.runtime.PNewState.flush(PNewState.java:31)     at
    com.solarmetric.kodo.runtime.StateManagerImpl.flush(StateManagerImpl.java:372)     at
    >>
    >>
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:426)     at
    >>
    >>
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:295)     at
    >>
    test.AnagraficaJdo.main(AnagraficaJdo.java:49)
    How can I resolve the problem of the presence of IDANAG_ANAGRAFICAX and
    have the 1-m relation?
    Thank you in advance.
    Mirko
    Fred Lucas
    SolarMetric Inc.
    202-595-2064 x1122
    http://www.solarmetric.com

  • I am one of many who were frustrated at the loss of visible keywords in Lion.  Will the new Mountain Lion solve this problem?

    I an one of many who were frustrated at the loss of visible keywords in iPhoto in Lion.  Will the new Mountain Lion solve this problem?

    I'm not sure whether we are quite talking about the same thing? 
    With iPhoto in OSX 10.4.11 all the keywords were visible in the iPhoto library.  When I moved my photos to a computer with Lion I lost this feature, there was a lot of discussion at the time about this being a backward step by Apple.  So I wondered whether the Mountain Lion version of iPhoto has restored this feature?

  • Context Problem when using Use One As Many

    Hi SapGuru's.
    i have got a requirement in an IDOC To File Interface where the segments in the IDOC are like E1LFA1M->E1LFM1M->E1WYT3M
    THE Test data is like below
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:IDOC_Test_Mt xmlns:ns0="urn:sap.shoprite.co.za:ecc.md">
       <ZCREMAS>
          <IDOC>
             <E1LFA1M>
                <LIFNR>0000641065</LIFNR>
                <E1LFM1M>
                   <EKORG>1001</EKORG>
                   <E1WYT3M>
                      <PARVW>BA</PARVW>
                   </E1WYT3M>
                   <E1WYT3M>
                      <PARVW>LF</PARVW>
                   </E1WYT3M>
                   <E1WYT3M>
                      <PARVW>RS</PARVW>
                   </E1WYT3M>
                </E1LFM1M>
             </E1LFA1M>
             <E1LFA1M>
                <LIFNR>0000641065</LIFNR>
                <E1LFM1M>
                   <EKORG>1002</EKORG>
                   <E1WYT3M>
                      <PARVW>BA</PARVW>
                   </E1WYT3M>
                   <E1WYT3M>
                      <PARVW>RS</PARVW>
                   </E1WYT3M>
                </E1LFM1M>
             </E1LFA1M>
             <E1LFA1M>
                <LIFNR>0000641065</LIFNR>
                1002
             </E1LFA1M>
             <E1LFA1M>
                <LIFNR>0000641065</LIFNR>
                <E1LFM1M>
                   <EKORG>1004</EKORG>
                   <E1WYT3M>
                      <PARVW>BA</PARVW>
                   </E1WYT3M>
                   <E1WYT3M>
                      <PARVW>LF</PARVW>
                   </E1WYT3M>
                   <E1WYT3M>
                      <PARVW>RS</PARVW>
                   </E1WYT3M>
                </E1LFM1M>
                <E1LFM1M>
                   <EKORG>1005</EKORG>
                   <E1WYT3M>
                      <PARVW>BA</PARVW>
                   </E1WYT3M>
                   <E1WYT3M>
                      <PARVW>LF</PARVW>
                   </E1WYT3M>
                   <E1WYT3M>
                      <PARVW>RS</PARVW>
                   </E1WYT3M>
                </E1LFM1M>
             </E1LFA1M>
          </IDOC>
       </ZCREMAS>
    </ns0:IDOC_Test_Mt>
    the Target xsd is like below :
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema targetNamespace="urn:sap.shoprite.co.za:demo.trans" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:sap.shoprite.co.za:demo.trans" xmlns:p1="urn:sap.shoprite.co.za:bluecube">
       <xsd:import namespace="urn:sap.shoprite.co.za:bluecube"/>
       <xsd:element name="Vendor_masterTest1" type="p1:Vendor_masterTest"/>
    </xsd:schema>
    the EKORG Field from source is mapping to Purchase Organisation(field) in target file .
    so here when i use one as many and iam mapping EKORG->MAP WITH DEFAULT ->USE ONE AS MANY and as in the above test data if there are multiple E1LFM1M's the first paramter of Use one as many is getting 2 ekorg's in only one context but here i want them to be created on separate context(please have a look at 4th E1LFA1M in the test data to get clear idea.
    can any of you help me in this.
    regards.
    Varma

    Hi,
    Try this.
    Source Code:
    IDOC
    --->E1LFA1M
                    -->E1LFM1M
                          --> EKORG = 1000
                          --> E1WYT3M
                          --> E1WYT3M
                    -->E1LFM1M
                    -->E1LFM1M
                          --> EKORG = 1001
                          --> E1WYT3M
                          --> E1WYT3M
                    -->E1LFM1M
                          --> EKORG = 1006
                          --> E1WYT3M
                          --> E1WYT3M
    Output:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:target xmlns:ns0="http://test">
    <Data>
       <M>1000</M>
    </Data>
    <Data>
       <M>1000</M>
    </Data>
    <Data>
       <M></M>
    </Data>
    <Data>
       <M>1001</M>
    </Data>
    <Data>
       <M>1001</M>
    </Data>
    <Data>
       <M>1006</M>
    </Data>
    <Data>
       <M>1006</M>
    </Data>
    </ns0:target>
    Use below Mapping:
    Use If then Else Function.
    1. If condition: E1WYT3M Exists
    2. Then pass E1WYT3M
    3. Else Pass E1LFM1M with "Map with Default"
    Lets Consider Output of this step as "A".
    Use One As Many.
    First Input: E1LFM1M to exists to Split By Each Value
    Second and Third Input will be Out Put of "A" (Above Step).
    Lets Consider Out put of this Step as "B"
    Use If without Else.
    If "B" is true then pass "A"  to exists.
    Out put  of this to Remove context to Target Vendor Master Node. In my sample it will be Node "Data"
    Now for Mapping of Field Purch Org/In my case field "M"
    Use If without Else.
    If "B" is true then Pass "C". Output of this to Split by each value to target.
    For C:
    Use if then else
    if E1WYT3M exists then pass EKORG else pass constant blank.
    Hope its clear!!
    -Gouri

Maybe you are looking for

  • Acrobat 9 pro trial wont install

    Please help. Acrobat pro 9 trial install problem I have down loaded Acrobat pro trial to my Pc Okay. Running windows Xp pro service pack 3 1829MHz 20g free space . Have installed Photo shop CS4 and light room 2 . The problem starts at installation ma

  • Parent / Child lead management

    Does anyone have experience using parent/child relationships with leads in SalesForce? I am currently looking into setting this up for our organization to answer the need for multiple business units to be able to work/manage their leads while maintai

  • How to turn off the passcode on iphone 3GS,

    Setting>Profile>Remove VPN or ESC>Setting>Passcode Lock>turn passcode OFF>Setting Passcode remove...

  • Tiled vi pane background​s can cause slow slider control updating

    In diagnosing a slow responding slider control I found that the problem was having selected a Pane background image that was set to Brushed Metal and Tiled. It turns out that it was the tiled setting that caused the slowdown (which was very pronounce

  • CM Repository Manager

    Hello, I tried to set up a CM Repository Manager in FSDB mode to connect to a file system. I went through the steps of this blog <a href="https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a0449c90-0201-0010-7590-dd30845754ef">https: