Inheritance and One-To-Many Mapping Issue

Are there any known issues with TopLink 4.6 mapping a one-to-many relationship where the classes in the list span more than 2 levels deep in the inheritance chain? We seem to notice that TopLink creates the class that is 2 levels deep before the owning class.

Sorry for the delayed response to your post. I'm not sure I follow what you mean by "owning class". You have a 1-M mapping where the M has inheritance. Are you mapping to the root of the inhertance hierarchy, or to a leaf class? I.e., do you have a 1-M "Company - Employee" or a 1-M "Company - SalariedEmployee". In this example, what would you call the "owning class"?
- Don

Similar Messages

  • One to one mapping and one to many mapping in a single table

    Hi All,
    I am asked to design a banking application, I have CUSTOMER table where the information regarding the customer is stored. I have have an ACCOUNT table where account information is stored.
    Now A customer can start all the 3 types of accounts. (Checking account, Saving account and FD(Fixed Deposits))
    One customer can have - >Only one checking account only one Saving account, but can have many FD account. How do we implement this using integrity constraints?
    CUSTOMER Table -> Cust_id(PK), Cust_name, Cust_phone, Cust_address
    ACCOUNT Table -> AccountNo, Acc_type,Cust_id
    Your answer is greatly appreciated.
    Thanks
    Sophy

    You may need to create a UNIQUE function based index. That would work for you.
    create table customer_1 (Cust_id integer primary key, Cust_name varchar2(100), Cust_phone number, Cust_address varchar2(100))
    create table account_1 (AccountNo integer primary key, Acc_type varchar2(100),Cust_id integer references customer_1(cust_id))
    create unique index account_idx on account_1 (cust_id, decode(acc_type,'CA',acc_type, 'SA', acc_type, 'FD', 'FD' || accountno))
    insert into customer_1 (cust_id, cust_name, cust_phone, cust_address) values (1, 'karthick', 0, 'x')
    insert into account_1 (accountno, acc_type, cust_id) values(1, 'CA', 1)
    insert into account_1 (accountno, acc_type, cust_id) values(2, 'SA', 1)
    insert into account_1 (accountno, acc_type, cust_id) values(3, 'FD', 1)
    insert into account_1 (accountno, acc_type, cust_id) values(4, 'FD', 1)
    insert into account_1 (accountno, acc_type, cust_id) values(5, 'FD', 1)
    /

  • One to many mapping

    Having trouble with the following poblem.. specially how to code getChildren??????? Help urgent
    Create a class called Families which creates a one-to-many mapping of parent name (String) to Child objects. Create any needed member variables and write the two specified methods. (You do not need to write the Child class.)
    class Families {
    public void addToFamily( String parent, Child child) {
    public List getChildren( String parent) {
    I have done the following..
    import java.util.ArrayList;
    import java.util.List;
    class Families {
    private String parentName;
    List <child> children = new ArrayList();
    public Families(String name){
    this.parentName = name;
    public void addToFamily( String parent, child kid) {
    Families f = new Families(parent);
         f.children.add(kid);      
    public List<child> getChildren( String parent) {
         return this.children;
    }

    Having trouble with the following poblem.. specially
    how to code getChildren??????? Help urgent
    Create a class called Families which creates a
    one-to-many mapping of parent name (String) to Child
    objects. Create any needed member variables and write
    the two specified methods. This key:
    (You do not need to write the Child class.)How can the following line possibly work?
    List <child> children = new ArrayList();It's not syntactically correct, AND you're not writing the Child class.
    %

  • One to Many Mapping with different SQL types

    We have an interesting one to many relationship in our system in which the source and target field SQL types do not match, but the values do. The relationship is actually between multiple entries in the same database table. So, imagine we have some table that looks sort of like this:
    KEY ObjectID OwnerNo
    100 1234     0
    101 ABCD     1234
    102 EFGH     1234ObjectID is defined as a varchar type, but Parent entries are guaranteed to have integer value ObjectIDs. Child entries point to the parent through the OwnerNo field, which defined in the database as a numeric.
    A simple one-to-many mapping will give you the following SQL error on execution: [SQL0401] Comparison operator = operands not compatible.
    I tried modifying my descriptor after load as follows:
       public static void modifyOneToMany(Descriptor descriptor)
           ExpressionBuilder builder = new ExpressionBuilder();
           Expression exp = builder.getField("OwnerNo").
              equal(builder.getField("ObjectID").toNumber());
           descriptor.getMappingForAttributeName("children")
              .setSelectionCriteria(exp);
       }But this introduces two problems in the generated SQL ( ... WHERE ((t0.OwnerNo = TO_NUMBER(t0.ObjectID) ... ). First, this generates a where clause using the function TO_NUMBER, which is not supported by DB2 on AS400, our database platform. Second, the table reference is off in the generated SQL--I couldn't find a way to specify that the right hand side of the = operator should be from the parent of the one to many mapping--both sides are referenced from the child context (t0).

    I found the getFunction() method on Expression, so I can solve half of this problem with the following code:
       public static void modifyOneToMany(Descriptor descriptor)
         if (descriptor.getMappingForAttributeName("children").isOneToManyMapping())
           OneToManyMapping map = (OneToManyMapping) descriptor.
                                  getMappingForAttributeName("children");
           DatabaseField objectID= (DatabaseField) map.getSourceKeyFields().get(0);
           DatabaseField ownerNo = (DatabaseField) map.getTargetForeignKeyFields().get(0);
           ExpressionBuilder builder = new ExpressionBuilder();
           Expression exp = builder.getField(ownerNo).getFunction("CHAR").
                            equal(builder.getField(objectID));
           map.setSelectionCriteria(exp);
       }This generates the following where clause:
    ... WHERE ((CHAR(t0.OwnerNo) = t0.ObjectID) ...
    But, I still have two questions:
    1. How do we get the right hand side of this comparison to reference the Parent part of the 1-M mapping?
    2. Since character and numeric conversions are pretty standard SQL functions, is there something wrong with the DB2 database platform I'm using?

  • Key Method in one to many mapping

    I have problem in one to many mapping. I use a composite key and use get method of that key as Key Method, toplink seems not to realize this change, and can't acommodate that.
    any one had same problem?

    Could you explain in more detail what it is you are tyring to do? By 'Key Method' do you mean you are using a Map as the collection type of a OneToMany mapping? What do you mean by change? Are you changing the composit key?
    --Gordon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Setting criteria on one-to-many mapping

    Hello,
    A quick question. Let's say you have two tables, TABLE A and TABLE B. TABLE A- which has a one to many relationship with TABLE B.
    When I do a query to get an object from TABLE A, I also get back a collection of TABLE B objects. I'd like to be able to alway be able to restrict the TABLE B objects I get back by adding an additional criteria like "where TABLE_B.DRAFT = 'N'" so that I always only get back TABLE B objects that are not drafts. Is there anyway to add this to the DirectToField Mapping or anywhere else in the Toplink Project so that I don't have to specifically setup the query in my DAO code?
    Thanks in advance for any help,
    Mark

    This is a follow-on to the previous question. I've been asked to create a domain object, Member, that would have two relationships with the child table Rec (Recommendations), a one-to-one mapping with the only record in the Rec table that has is "approved", and a one-to-many mapping with all the records for the Member. I realize from the answer received above that putting criteria in a mapping isn't recommended, but did want to see if it was even doable in case it was needed. Unfortunately, I get this error below:
    "A non-read-only mapping must be defined for the sequence number field."
    Below are my relevant mappings. Any thoughts on this?
    Thanks,
    Mark
    OneToOneMapping approvedRecInfoMapping = new OneToOneMapping();
         approvedRecInfoMapping.setAttributeName("approvedRecInfo");
         approvedRecInfoMapping.setGetMethodName("getApprovedRecInfoHolder");
         approvedRecInfoMapping.setSetMethodName("setApprovedRecInfoHolder");
         approvedRecInfoMapping.setReferenceClass(domain.Rec.class);
         approvedRecInfoMapping.useBasicIndirection();
         approvedRecInfoMapping.readOnly();
         approvedRecInfoMapping.addForeignKeyFieldName("PROM_REC.PRM_ID", "PROM_REC_MEMBER.ID");
         approvedRecInfoMapping.setSelectionCriteria(new ExpressionBuilder().get("approved").equal("true"));
         descriptor.addMapping(approvedRecInfoMapping);
         OneToManyMapping publicRecsMapping = new OneToManyMapping();
         publicRecsMapping.setAttributeName("publicRecs");
         publicRecsMapping.setGetMethodName("getPublicRecs");
         publicRecsMapping.setSetMethodName("setPublicRecs");
         publicRecsMapping.setReferenceClass(domain.Rec.class);
         publicRecsMapping.useTransparentCollection();
         publicRecsMapping.readOnly();
         publicRecsMapping.useCollectionClass(oracle.toplink.indirection.IndirectList.class);
         publicRecsMapping.addTargetForeignKeyFieldName("REC.PRM_ID", "MEMBER.ID");
         descriptor.addMapping(publicRecsMapping);

  • I tried to publish my project of 2 html pages, 3 photo pages and one widget page (map) to ipage hosting site. the two html pages published and that's all. Help.

    I tried to publish my project of 2 html pages, 3 photo pages and one widget page (map) to ipage hosting site. the two html pages published and that's all. Help.

    What's the URL of your site so we can examine it first hand?   Also try publishing the site to a folder on your hard drive and use the free FTP client  Cyberduck to upload your site.  It's been known to work when iWeb's ftp client has failed.
    OT

  • Partial Attribute search on a one to many mapping

    Is it possible to include an attribute that is a one to many mapping as a partial attribute in a Read All Query?

    Is it possible to include an attribute that is a one to many mapping as a partial attribute in a Read All Query?

  • One-to-many mapping and update the many part

    Hello !
    Here's my problem,
    I've got an object A having a vector of object B.
    The mapping in toplink is one-to-many with the back-references set in B.
    Insertion : no problem.
    Now i would like to change the Vector of B (inserting new B, updating existing B) in a function with the Vector vC (modified vector of B).
    What is the best way to do this ?
    I tried many thing but either I have toplink 6004 error, or doing it by removing all elements of the Vector (deleting all B in database), and then setting A with C (recreating all object in the modified Vector).
    Another way to explain my case:
    how to do this in UnitOfWork ?
    function modifyAVectorOfB(A, vectorOfC)
    AClone = uow.registerObject(A);
    Aclone.setVectorOfB(vectorOfC);
    uow.commit;
    (and in database all existing object in C are updated, new object in C are created, removed object in C are deleted)

    Have found a solution, read all object in the modified Vector, read the modified object in the Unit Of Work with readObject(B) (So i get the database or cache version) and then comparing it with the modified to change what is needed to be change.

  • One-Sided One-to-Many Mapping

    Hi,
    the manual says: "You can, however, have one-sided one-to-many mappings in
    which the back-reference only exists in the database, and is not
    represented by any Java field. The mapping tool never creates a one-sided
    one-to-many relation like this; you can only create it by writing the
    mapping data yourself, and then only on an existing schema that supports
    it."
    I don't understand the meaning of the phrase "only on an existing schema
    that supports it". Does that mean it's not supported for all databases
    (which are supported)? And what does it mean "on an existing schema"?
    thanks
    Reto

    Whoops. Got it backwards.
    Should be
    q.declareParameters ("Article article");
    q.setFilter ("articles.contains (article)");
    Collection results = (Collection) q.execute (article);
    Stephen Kim wrote:
    If this is a one to many, Article can just return its owning magazine
    field.
    Otherwise you can issue a query usch as:
    Query q = pm.newQuery (Magazine.class);
    q.declareParameters ("magazine");
    q.setFilter ("articles.contains (magazine)");
    Collection results = (Collection) q.execute (magazine);
    bamboo wrote:
    Following is the example, the question is how can I get the magazine
    instance if I have an Article instance? Thanks.
    Java class:
    public class Magazine
    private Set articles;
    ... class content ...
    Schema:
    <table name="MAGAZINE">
    <column name="JDOID" type="bigint"/>
    <pk column="JDOID"/>
    ... columns for magazine fields ...
    </table>
    <table name="ARTICLE">
    ... primary key columns ...
    <column name="MAG_ID" type="bigint"/>
    <fk to-table="MAGAZINE">
    <join column="MAG_ID" to-column="JDOID"/>
    </fk>
    ... columns for article fields ...
    </table>
    JDO metadata:
    <class name="Magazine">
    <field name="articles">
    <collection element-type="Article"/>
    </field>
    ... rest of field metadata ...
    </class>
    Mapping information using the mapping XML format:
    <class name="Magazine">
    ... class mapping ...
    ... indicator mappings ...
    <field name="articles">
    <jdbc-field-map type="one-many" table="ARTICLE"
    ref-column.JDOID="MAG_ID"/>
    </field>
    ... rest of field mappings ...
    </class>
    Steve Kim
    [email protected]
    SolarMetric Inc.
    http://www.solarmetric.com

  • Toplink - Many-to-Many Mapping issue

    Hi
    I have the following tables
    User
    Place
    Team
    User : uid , name (where uid is primay key)
    Place : uid , pid( where uid and pid are composite primary keys)
    Team : tid , name , pid( where tid is primary key)
    Here the following mappings :
    one user is belongs to many places
    one user have many teams( by place)
    user have many teams
    i have created many to many mapping between place(or user) and team tables using intermediate table user_team( uid ,tid). But when i try to retrieve the teams for user id then i m getting all the teams. Here i need to filter the teams by only place id instead getting all the teams.
    For example:
    if user id is belongs to place id 101 then i need to get only teams belongs to place id 101. But i m getting all the places(101,102) teams for same user id which belongs to place id 101.
    Please help me out how i can create valide mapping between all the tables to retrieve valid data. i m using toplink workbench(10g - 9.0.4).

    Your model seems confused, you may wish to re-think you model. It seems odd that a place would have a user id, seems more like it is a m-m join table between user and team, but then it should have a team id not a place id.
    You can use a selectionCriteria() on a ManyToManyMapping to define complicated m-m joins, but you would probably be better re-thinking your model. What object model are you trying to do exactly? Go from there, then define your data-model.
    -- James : http://www.eclipselink.org

  • 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.

  • JPA - One to Many persistence issue

    Hi All,
    We are facing an issue with one to many relationship persistence using JPA.
    We have a one to many relationship between Company and Personnel. When A personnel is created, the company(the parent in the relationship) is selected and that needs to be persisted along with the new Personnel Entity
    Find below the Entity Definitions and the code snippet to persist the Entity into the database.
    Entity - Company:
    @OneToMany(mappedBy = "company", cascade=CascadeType.ALL, fetch = javax.persistence.FetchType.EAGER)
    private Collection<Personnel> personnelCollection;
    Entity Personnel:
    @ManyToOne(optional = true)
    private Company company;
    public ErrorCode createAndAssignPersonnel(String personnelName, String company, String email, String title, String user)
    PersonnelPK personnelPK = new PersonnelPK(personnelName, this.appInfoEJB.getSiteId());
    Personnel personnel = new Personnel(personnelPK);
    personnel.setEmail(email);
    personnel.setTitle(title);
    CompanyPK companyPK = new CompanyPK(company, this.appInfoEJB.getSiteId());
    Company companyObj = this.companyEJB.find(companyPK);
    //Double Wiring the personnel and company records
    companyObj.getPersonnelCollection().add(personnel);
    personnel.setCompany(companyObj);
    //Running merge on the parent entity
    em.merge(companyObj);
    return ErrorCode.OK;
    The personnel entity is being persisted into the database but the company is not getting associated with it. (The company value remains blank)
    We are using the Toplink JPA Implementation with Glassfish application server. Any pointers would be greatly appreciated.
    Thanks and Regards,
    GK
    Edited by: user12055063 on Oct 13, 2009 10:05 AM
    Edited by: user12055063 on Oct 13, 2009 10:05 AM

    Hi All,
    Since PERSONNEL and COMPANY both had the SITEID column, we renamed the column in both tables to check if that solves the issue. However, a null company value is still being persisted into the database.
    Find below the altered schema:
    CREATE TABLE COMPANY
    COMPANYNAME VARCHAR(255) NOT NULL,
    COMPANYSITEID VARCHAR (255) NOT NULL,
    PARENTNAME VARCHAR(255),
    PARENTSITEID VARCHAR(255),
    ADDRESS VARCHAR(255),
    PRIMARY KEY (COMPANYNAME, COMPANYSITEID),
    FOREIGN KEY (PARENTNAME, PARENTSITEID) REFERENCES COMPANY (COMPANYNAME, COMPANYSITEID)
    CREATE TABLE PERSONNEL
    PERSONNELNAME VARCHAR(255) NOT NULL,
    PERSONNELSITEID VARCHAR(255) NOT NULL,
    COMPANY VARCHAR(255),
    EMAIL VARCHAR(255),
    TITLE VARCHAR(255),
    PRIMARY KEY (PERSONNELNAME, PERSONNELSITEID)
    ALTER TABLE PERSONNEL
    ADD CONSTRAINT PERCOMPANYCONS FOREIGN KEY (COMPANY, PERSONNELSITEID) REFERENCES COMPANY (COMPANYNAME, COMPANYSITEID);
    The corresponding entity classes are as follows:
    Personnel:
    public class Personnel implements Serializable {
        private static final long serialVersionUID = 1L;
        @EmbeddedId
        protected PersonnelPK personnelPK;
        @Column(name = "EMAIL")
        private String email;
        @Column(name = "TITLE")
        private String title;
        @OneToMany(cascade = CascadeType.ALL, mappedBy = "personnel", fetch = FetchType.EAGER)
        private Collection<Deliverynote> deliverynoteCollection;
        @OneToMany(cascade = CascadeType.ALL, mappedBy = "personnel", fetch = FetchType.EAGER)
        private Collection<Microreader> microreaderCollection;
        @JoinColumns({@JoinColumn(name = "COMPANY", referencedColumnName = "COMPANYNAME"), @JoinColumn(name = "PERSONNELSITEID", referencedColumnName = "COMPANYSITEID", insertable = false, updatable = false)})
        @ManyToOne
        private Company company;
        public Personnel() {
    Company:
    public class Company implements Serializable {
        private static final long serialVersionUID = 1L;
        @EmbeddedId
        protected CompanyPK companyPK;
        @Column(name = "ADDRESS")
        private String address;
        @OneToMany(mappedBy = "company", fetch = FetchType.EAGER)
        private Collection<Company> companyCollection;
        @JoinColumns({@JoinColumn(name = "PARENTNAME", referencedColumnName = "COMPANYNAME"), @JoinColumn(name = "PARENTSITEID", referencedColumnName = "COMPANYSITEID")})
        @ManyToOne(fetch = FetchType.EAGER)
        private Company company;
        @OneToMany(cascade = CascadeType.ALL, mappedBy = "company", fetch = FetchType.EAGER)
        private Collection<Credential> credentialCollection;
        @OneToMany(cascade = CascadeType.ALL, mappedBy = "company", fetch = FetchType.EAGER)
        private Collection<Personnel> personnelCollection;
        @OneToMany(cascade = CascadeType.ALL, mappedBy = "company", fetch = FetchType.EAGER)
        private Collection<Entityobject> entityobjectCollection;
        public Company() {
        }...The code for persisting the personnel record is as follows:
      public ErrorCode createAndAssignPersonnel(String personnelName, String company, String email, String title, String user)
            Personnel personnel = new Personnel(new PersonnelPK(personnelName, this.appInfoEJB.getSiteId()));
            personnel.setEmail(email);
            personnel.setTitle(title);
            Company companyObj = this.companyEJB.find(new CompanyPK(company, this.appInfoEJB.getSiteId()));
            personnel.setCompany(companyObj);
            companyObj.getPersonnelCollection().add(personnel);
            //em.merge(companyObj);
            em.persist(personnel);
            em.flush();
            return ErrorCode.OK;
        }The SQL queries internally generated as as follows:
    INSERT INTO PERSONNEL (TITLE, EMAIL, PERSONNELSITEID, PERSONNELNAME) VALUES (?, ?, ?, ?)
    bind => [, , JackOnSite, Tester]
    In this case, the company field is not even added in the query.
    On deleting the updatable, insertable attributes from the JoinColumns annotation as follows:
    @JoinColumns({@JoinColumn(name = "COMPANY", referencedColumnName = "COMPANYNAME"), @JoinColumn(name = "PERSONNELSITEID", referencedColumnName = "COMPANYSITEID" )})
    @ManyToOne
    private Company company;The following query is generated:
    Local Exception Stack:
    Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.DatabaseException
    Internal Exception: java.sql.SQLSyntaxErrorException: Column name 'PERSONNELSITEID' appears more than once times in the column list of an INSERT statement.
    Error Code: -1
    Call: INSERT INTO PERSONNEL (TITLE, EMAIL, COMPANY, PERSONNELSITEID, PERSONNELSITEID, PERSONNELNAME) VALUES (?, ?, ?, ?, ?, ?)
    bind => [, , Test New, JackOnSite, JackOnSite, Sesi]
    Note that in this case, the company is being inserted into the query. However, the PERSONNELSITEID appears twice.
    The company table has a foreign key reference to itself and we have tried testing this use case by dropping that constraint without any success.
    We would greatly appreciate any pointers/suggestions.
    Thanks and Regards,
    GK

  • One to Many mapping question

    Hi all,
    I have a question regarding a one to many field mapping I'm using in a
    class.
    I have a class AImpl which implements A, and BImpl which implements B.
    class AImpl implements A
    Collection bs;
    class BImpl implements B
    A a;
    I've created an inverse mapping in the package.jdo file as such:
    <class name="AImpl">
    <field name="bs">
    <collection element-type="BImpl"/>
    <extension vendor-name="kodo" key="inverse-owner" value="a"/>
    </field>
    </class>
    I get an error when the mapping tool is run saying;
    Field "AImpl.bs" names field "a" as its inverse-owner, but a is not a
    field of the related type.
    When I change the BImpl class to have AImpl a, it works fine.
    I'm wondering is there a way to leave the interface in the BImpl class and
    somehow declaritively tell the mappingtool that the field is an AImpl, as
    this allows me to separate interface from implementation in a much more
    efficient way when I build my modules.
    Thanks,
    Brendan

    Thanks Stephen for your quick response.
    I added
    <field name="a">
    <extension vendor-name="kodo" key="type" value="AImpl"/>
    </field>
    and it worked.
    Brendan
    Stephen Kim wrote:
    You can explicitly declare field/element types to be of a certain type:>
    http://solarmetric.com/Software/Documentation/3.0.3/docs/ref_guide_meta_ext.html#type
    Brendan Brothers wrote:
    Hi all,
    I have a question regarding a one to many field mapping I'm using in a
    class.
    I have a class AImpl which implements A, and BImpl which implements B.
    class AImpl implements A
    Collection bs;
    class BImpl implements B
    A a;
    I've created an inverse mapping in the package.jdo file as such:
    <class name="AImpl">
    <field name="bs">
    <collection element-type="BImpl"/>
    <extension vendor-name="kodo" key="inverse-owner" value="a"/>
    </field>
    </class>
    I get an error when the mapping tool is run saying;
    Field "AImpl.bs" names field "a" as its inverse-owner, but a is not a
    field of the related type.
    When I change the BImpl class to have AImpl a, it works fine.
    I'm wondering is there a way to leave the interface in the BImpl class and
    somehow declaritively tell the mappingtool that the field is an AImpl, as
    this allows me to separate interface from implementation in a much more
    efficient way when I build my modules.
    Thanks,
    Brendan
    Steve Kim
    [email protected]
    SolarMetric Inc.
    http://www.solarmetric.com

  • Data services and one to many foreign keys?

    Hi,
    I am playing with the data features in Flash4.  I can get a flex app to work that will query and update a J2EE entity that has no foreign keys, but when I try the same with an entity that has many to one foreign keys I get a null pointer error coming from the server.  I created a servlet to do the same update and that worked.
    I'm wondering if the issue is a casting issue.  I know I have to do the configure data types thing to some of the generated service calls to let it know what action script class is appropriate (instead of a generic object ) e.g. findAll().  Do I have to do a similar thing for one to many foreign key situations?  i.e. lets say i have a department - employees model.  On the java side the department entity has a variable that is a set of employees.  In the department.as class I'd have a employees field thats an ArrayCollection.  Do I have to let it know somewhere that this is an ArrayCollection of employee.as objects?
    FYI, I've already changed to eager fetching of the fk values.
    Does anyone have this working?
    Thanks,
    Bill

    Hi,
    Thanks for your feedback!
    This looks like an issue.
    Can you please log a bug in http://bugs.adobe.com/flex with your sample.
    Thanks,
    Balaji
    http://balajisridhar.wordpress.com

Maybe you are looking for

  • Scratched on the back of my MacBook Pro, can I get this fixed with Apple Care?

    Hello community, today I found out there are some scatches in the back my aluminum MacBook Pro. There is one fairly deep scratch. This has probably happened in my backpack since I use it for school. My question is: is this something Apple Care will h

  • Oracle Ole DB 8.1.7.3.0

    Hello, I suspect that one of our applications is having a memory leak when connecting to oracle database. The application is developed in VB6 and using OraOleDB 8.1.7.3.0 I´ve seen a very old post Re: COM+ and OLEDB - memory leak in OCI dlls where so

  • How far back does Spotlight look in the Calendar ?

    When I search my calendar with Spotlight it looks as if it goes only 1 year back. Is that correct ? Cheers, Antonio.

  • Structure for batch input

    is there any quicker way to find appropriate sap structure regarding batch input? line batch input for vendor creation, how to find the sap structure so that the format file can be defined later on.

  • Backup Incremental - What's it doing?

    Hi, I'm doing an incremental back up to an iDisk using the Backup utility. As it's over the internet, this takes a while - but even when I change very little between backups, the incremental is still very large. Does anyone know - is there a way of f