To-many relationship returns no objects

Hi,
I've created two Entities which have a many-to-many relationship between each other. I generated the classes automatically from the model. After that I added records in the sqlite database for both entity tables and also in the relationship table with the IDs of the entity records. But now, when I access the relationship by using [[myManagedObject valueForKey:@"relationship-name"] count] it always return 0, but each object has some of the other object in relation by the sqlite database.
Is there anything what I could have done wrong?

now, I tried it with a to-one relationship and that works.
Does the table of the many-to-many relation just has the PKs of both entity tables as values or is there saved any other value of the record?

Similar Messages

  • JPA, how to write a service to persist objects in a 1-to-many relationship

    i am using JPA for data persistence. i have two objects that are involved in a one-to-many relationship. for example, i have an object, Company, and Company can have one or more, Employee. i then define a service called, CompanyDao, which has the usual create-read-update-delete (CRUD) operations. my problem is that when i instantiate a new Company with new Employees and call CompanyDao.create(Company), i keep getting an exception.
    Cannot add or update a child row: a foreign key constraint fails (`demo`.`employee`, CONSTRAINT `employee_ibfk_1` FOREIGN KEY (`companyId`) REFERENCES `company` (`id`))
    i have an intuition on why this is happening. when i call CompanyDao.create(Company), the newly instantiated Company doesn't yet have an id (its unique identifier). that is why when it tries to insert the Employees of Company, i get this problem. but, my question is, shouldn't JPA take care of all of this for me? shouldn't it know that it is creating a new Company, will have to insert it, will have to retrieve the unique id (generated) and then populate the employee table with this id?
    i was thinking about this problem, and i thought maybe i could insert the company first and then the employees later. however, the problem is, once i insert the company, how do i get its unique id? i cannot query for it any other way (i.e. by name) that will return a unique result.
    if anyone knows of a good, comprehensive tutorial on how to write a service demonstration CRUD operations on objects with one-to-many relationship, please let me know.

    Hi,
    Could you please send CompanyDao.create(Company) code so that we can dig in to problem.
    Regards
    Murali N

  • Problem with 1-to-many relationship between entity beans

    Hi All!
    I have two tables TMP_GROUP and TMP_EMPLOYEE with following fields:
    TMP_GROUP: ID, CAPTION, COMMENT, STATUS.
    TMP_EMPLOYEE: ID, LOGIN, GROUP_ID.
    For this tables i create two entity beans GROUP and EMPLOYEE respectively.
    The relationship looks like this
    descriptor ejb.xml:
    <ejb-relation>
                <description>description</description>
                <ejb-relation-name>employeesOfGroup</ejb-relation-name>
                <ejb-relationship-role>
                    <ejb-relationship-role-name>com.mypackage.GroupBean</ejb-relationship-role-name>
                    <multiplicity>One</multiplicity>
                    <relationship-role-source>
                        <ejb-name>GroupBean</ejb-name>
                    </relationship-role-source>
                    <cmr-field>
                        <cmr-field-name>employees</cmr-field-name>
                        <cmr-field-type>java.util.Collection</cmr-field-type>
                    </cmr-field>
                </ejb-relationship-role>
                <ejb-relationship-role>
                    <ejb-relationship-role-name>com.mypackage.EmployeeBean</ejb-relationship-role-name>
                    <multiplicity>Many</multiplicity>
                    <relationship-role-source>
                        <ejb-name>EmployeeBean</ejb-name>
                    </relationship-role-source>
                </ejb-relationship-role>
            </ejb-relation>
    descriptor persistent.xml:
    <table-relation>
                   <table-relationship-role
                        key-type="PrimaryKey">
                        <ejb-name>GroupBean</ejb-name>
                        <cmr-field>employees</cmr-field>
                   </table-relationship-role>
                   <table-relationship-role
                        key-type="NoKey">
                        <ejb-name>EmployeeBean</ejb-name>
                        <fk-column>
                             <column-name>GROUP_ID</column-name>
                             <pk-field-name>ejb_pk</pk-field-name>
                        </fk-column>
                   </table-relationship-role>
              </table-relation>
    Now i implement business method:
    public Long addEmployee(String login, long groupId) {
              Long result;
              try {
                   EmployeeLocal employee = employeeHome.create(login);
                   GroupLocal group =
                        groupHome.findByPrimaryKey(new Long(groupId));
                   Collection employees = group.getEmployees();
                   employees.add(employee);
                   result = (Long) employee.getPrimaryKey();
              } catch (CreateException ex) {
                   result = new Long(0);
              } catch (FinderException ex) {
                   result = new Long(0);
              return result;
    When i call this method from web service, the following exception is raised:
    com.sap.engine.services.ejb.exceptions.BaseTransactionRolledbackLocalException: Exception in method com.mypackage.GroupLocalHomeImpl0.findByPrimaryKey(java.lang.Object).
    P.S.
    1) I have transaction attribute set to "Required" for all methods of all beans
    2) I have unique index for each table:
    TMP_GROUP_I1: CAPTION
    TMP_EMPLOYEE_I1: LOGIN (however i think GROUP_ID must be added here too)
    3) I tried many:many relationship with this tables and it works fine
    4) I try another implementation of addEmployee method with
    EmployeeLocal employee = employeeHome.create(login, groupId);
    without using GroupLocal cmr-field and GroupLocalHome findByPrimaryKey method, the result is same error.
    Can somebody help me with this problem?
    Thanks in advance.
    Best regards, Abramov Andrey.

    gimbal2 wrote:
    1: The @JoinColumn on the listOfDepartments collection in Company is wrong. It should be something like this for a bidirectional relationship:
    @OneToMany(mappedBy="company") // company is the matching property name in Department
    private List <Department> listOfDepartment = new ArrayList<Department>();Note that I removed the fetch configuration; onetomany is fetched lazy by design. Saves some clutter eh.
    2: use a Set in stead of a List (hibernate doesn't like lists much in entities and will break when you create slightly more complex entity relations)
    3: don't just slap cascades on collections, especially of type ALL. Do it with care. In the many years I've been using JPA I've only had to cascade deletes in very specific situations, maybe once or twice. I never needed any of the other cascade types, they just invite sloppy code if you ask me. When working with persistence you should apply a little precision.I made all changes as you mentioned but still compID in department table shows null value...

  • Problem with 1:many relationship between entity beans.

    Hi All!
    I have two tables TMP_GROUP and TMP_EMPLOYEE with following fields:
    TMP_GROUP: ID, CAPTION, COMMENT, STATUS.
    TMP_EMPLOYEE: ID, LOGIN, GROUP_ID.
    For this tables i create two entity beans GROUP and EMPLOYEE respectively.
    The relationship looks like this
    descriptor ejb.xml:
    <ejb-relation>
                <description>description</description>
                <ejb-relation-name>employeesOfGroup</ejb-relation-name>
                <ejb-relationship-role>
                    <ejb-relationship-role-name>com.mypackage.GroupBean</ejb-relationship-role-name>
                    <multiplicity>One</multiplicity>
                    <relationship-role-source>
                        <ejb-name>GroupBean</ejb-name>
                    </relationship-role-source>
                    <cmr-field>
                        <cmr-field-name>employees</cmr-field-name>
                        <cmr-field-type>java.util.Collection</cmr-field-type>
                    </cmr-field>
                </ejb-relationship-role>
                <ejb-relationship-role>
                    <ejb-relationship-role-name>com.mypackage.EmployeeBean</ejb-relationship-role-name>
                    <multiplicity>Many</multiplicity>
                    <relationship-role-source>
                        <ejb-name>EmployeeBean</ejb-name>
                    </relationship-role-source>
                </ejb-relationship-role>
            </ejb-relation>
    descriptor persistent.xml:
    <table-relation>
                   <table-relationship-role
                        key-type="PrimaryKey">
                        <ejb-name>GroupBean</ejb-name>
                        <cmr-field>employees</cmr-field>
                   </table-relationship-role>
                   <table-relationship-role
                        key-type="NoKey">
                        <ejb-name>EmployeeBean</ejb-name>
                        <fk-column>
                             <column-name>GROUP_ID</column-name>
                             <pk-field-name>ejb_pk</pk-field-name>
                        </fk-column>
                   </table-relationship-role>
              </table-relation>
    Now i implement business method:
    public Long addEmployee(String login, long groupId) {
              Long result;
              try {
                   EmployeeLocal employee = employeeHome.create(login);
                   GroupLocal group =
                        groupHome.findByPrimaryKey(new Long(groupId));
                   Collection employees = group.getEmployees();
                   employees.add(employee);
                   result = (Long) employee.getPrimaryKey();
              } catch (CreateException ex) {
                   result = new Long(0);
              } catch (FinderException ex) {
                   result = new Long(0);
              return result;
    When i call this method from web service, the following exception is raised:
    com.sap.engine.services.ejb.exceptions.BaseTransactionRolledbackLocalException: Exception in method com.mypackage.GroupLocalHomeImpl0.findByPrimaryKey(java.lang.Object).
    P.S.
    1) I have transaction attribute set to "Required" for all methods of all beans
    2) I have unique index for each table:
    TMP_GROUP_I1: CAPTION
    TMP_EMPLOYEE_I1: LOGIN (however i think GROUP_ID must be added here too)
    3) I tried many:many relationship with this tables and it works fine
    4) I try another implementation of addEmployee method with
    EmployeeLocal employee = employeeHome.create(login, groupId);
    without using GroupLocal cmr-field and GroupLocalHome findByPrimaryKey method, the result is same error.
    Can somebody help me with this problem?
    Thanks in advance.
    Best regards, Abramov Andrey.

    I have posted excerpts from my orion-ejb-jar.xml file in this posting: Problem mapping a 1:M relationship between two entity EJBs w/ a compound PK
    Sorry for the duplicate postings, but I was getting errors on the submission.
    April

  • One to many relationship leads to recursion?

    Hi,
    I've created a web services function which returns an object retrieved from a database using the persistence api (the class was generated by the Netbeans 5.5 "Entity Class from Database" feature.
    I can successfully return an object which has no foreign keys. However, when I try to retrieve an entity which is on either side of a 1:N relationship, I receive a stackOverflowError.
    Here's my sample schema (I'm using Derby bundled with SJAS 9 for testing)
    create table Address (
       Id int not null,
       StreetName varchar(255),
       City varchar(255),
       PostalCode varchar(255),
       Party int,
       primary key (Id)
    create table Party (
       Id int,
       Name varchar(255),
       primary key(Id)
    alter table Address add constraint foreign key (Party) references Party;So as you can see, one Party might have many addresses.
    I can retrieve either an Address or Party from the database using something like:
    em.createNamedQuery("Party.findById")
       .setParameter("id", 1)
       .getSingleResult();When I try to return it, I get a stackOverflowError in the server log. I'm using the default Toplink provider so enabling full logging on this, I can see the SQL.
    When retrieving an address, it selects all of the address fields and correctly binds the supplied Id value. It then performs a select on the Party table using the Address.Party value. This in turn causes it to attempt to retrieve an Address. After three queries, the error is thrown.
    I can't see why the above schema should cause this problem. Where an Address is requested, I would expect it to retrieve the address fields, including the value of the Party field but not the Party object itself. On the other hand. when a Party is retrieved, I would expect it to recurse through and return a collection of Address objects.
    Have I misunderstood this or am I missing some fundamental point about JAX-WS?
    Thanks for your help,
    -Phil

    You have to set both sides of the relations...
    for example to do this in a more seamless manner:
    public UserProfile
         public void addLog (UserActivityLog activity)
              logs.add (activity);
              if (!equals (activity.getUserProfile ()))
                   activity.setUserProfile (this);
    Now this is the most primitive of ways to maintain two sided relations.
    There are a lot of other patterns to get around this.
    If you want to set the UserActivityLog to a specific UserProfile without
    having a firm reference to ther UserProfile, you should get the object
    from the database/persistenceManager... as you are using application
    identity, you can do something like pm.getObjectById.
    JDO does not do magic references. If you set something to null, it will
    remain null until you set it.
    Srini wrote:
    Hi Guys
    I am trying to create a one to many relationship between 2 JDOs.
    UserProfile - User JDO having user info
    UserActivityLog - JDO having user log info
    UserProfile -- UserActivityLog
    1 many
    UserProfile - has a collection of UserActivityLog objects
    UserActivityLog - has a reference to UserProfile
    Qn 1:
    I created a UserProfile along with a collection of 2 UserActivityLog
    objects.
    Navigation:
    Now given a UserProfile object,i am able to get the UserActivityLog objects.
    But given a UserActivityLog object ,i get a NULL UserProfile object.
    Issues:
    Why this is happening???Do i need to set the reference for "UserProfile" in
    UserActivityLog before inserting???
    If so,then how do i add a UserActivityLog to an existing
    UserProfile???cos,if i create a UserActivityLog with reference to
    UserProfile ,then it will throw a Duplicate Key violation for UserProfile as
    it is already persisted in DB.
    It will be great if you can direct me to some one to many relationship
    examples already implemented.
    Thanks
    Srini
    Stephen Kim
    [email protected]
    SolarMetric, Inc.
    http://www.solarmetric.com

  • One to many relationships in EJB

    I have two EBs related by a one to many relationship. The first of these tables is called Student and has studentId as its key. The second of the tables has a composite key made up of studentID, courseID and semesterID.
    However, when the tables are generated in NetBeans 5.5, I find that the Course table has studentID as both a primary key and a foreign key.
    I am at a loss to understand this as I am new to NetBeans and EJB.
    Can anyone advise?
    Thanks
    Martin O'Shea.
    The Student class:
    package CBSD_CW;
    import java.io.Serializable;
    import javax.persistence.*;
    import java.util.*;
    import javax.persistence.CascadeType;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    @Entity
    public class Student_EB implements Serializable {
        // Table columns.
        @Id
        @Column(name = "STUDENT_ID", nullable = false)
        private Long studentId; // Student ID. Entity <Student><ID> from file: SampleData.xml.
        @Column(name = "FIRST_NAME", length = 50, nullable = true)
        private String firstName; // First Name. Entity <Student><FirstName> from file: SampleData.xml.
        @Column(name = "LAST_NAME", length = 50, nullable = true)
        private String lastName; // Last Name. Entity <Student><LastName> from file: SampleData.xml.
        @Column(name = "STUDENT_LEVEL", length = 2, nullable = true)
        private String studentLevel; // Student Level. Entity <Student><Level> from file: SampleData.xml.
        @Column(name = "PROGRAM_NAME", length = 50, nullable = true)
        private String programName; // Program Name. Entity <Student><ProgramName> from file: SampleData.xml.
        @Column(name = "PROGRAM_NUMBER", length = 3, nullable = true)
        private String programNumber; // Program Number. Entity <Student><ProgramNumber> from file: SampleData.xml.
        // 1:M relationship with Course_EB.
        @OneToMany(cascade=CascadeType.ALL, mappedBy="student")
        private List<Course_EB> courses;
        public List<Course_EB> getCourses() {
           return courses;
        public void setCourses(List<Course_EB> courses) {
           this.courses = courses;
        // Accessors and mutators.
        public Long getId() {
            return this.studentId;
        public void setId(Long studentId) {
            this.studentId = studentId;
        public String getFirstName() {
            return firstName;
        public void setFirstName(String firstName) {
            this.firstName = firstName;
        public String getLastName() {
            return lastName;
        public void setLastName(String lastName) {
            this.lastName = lastName;
        public String getStudentLevel() {
            return studentLevel;
        public void setStudentLevel(String studentLevel) {
            this.studentLevel = studentLevel;
        public String getProgramName() {
            return programName;
        public void setProgramName(String programName) {
            this.programName = programName;
        public String getProgramNumber() {
            return programNumber;
        public void setProgramNumber(String programNumber) {
            this.programNumber = programNumber;
        // Other methods.
        public boolean equals(Object obj) {
           if (obj == this) {
               return (true);
           if (!(obj instanceof Student_EB)) {
               return (false);
           if (obj == null) {
               return (false);
           Student_EB student = (Student_EB) obj;
           return (student.studentId == studentId);
    The Course class:
    package CBSD_CW;
    import javax.persistence.CascadeType;
    import javax.persistence.EmbeddedId;
    import javax.persistence.Entity;
    import javax.persistence.JoinColumn;
    import javax.persistence.JoinTable;
    import javax.persistence.ManyToOne;
    @Entity
    public class Course_EB implements java.io.Serializable {
       Course_PK course;
       // M:1 relationship with Student_EB.
       private Student_EB student;
       @ManyToOne(cascade=CascadeType.ALL)
       @JoinTable(name = "Student_EB", joinColumns= @JoinColumn(name = "STUDENT_ID", referencedColumnName = "studentId"))
       public Student_EB getStudent() {
          return (student);
       public void setStudent(Student_EB student) {
          this.student = student;
       // Constructor.
       public Course_EB() {
       // Accessors and mutators.
       @EmbeddedId
       public Course_PK  getCourse_PK () {
          return (course);
       public void setCourse_PK(Course_PK course) {
          this.course = course;
    The Course_PK class:
    package CBSD_CW;
    import javax.persistence.Column;
    import javax.persistence.Embeddable;
    @Embeddable
    public class Course_PK implements java.io.Serializable {
       // Table columns.
       @Column(name = "STUDENT_ID", length = 4, nullable = false)
       private long studentId; // Student ID. Entity <Student><ID> from file: SampleData.xml.
       @Column(name = "COURSE_ID", length = 4, nullable = false) 
       private String courseId; // Course ID. Entity <Student><Course><Number> from file: SampleData.xml.
       @Column(name = "SEMESTER_CODE", length = 3, nullable = false)
       private String semesterCode; // Semester Code. Entity <Student><Course><SemesterCode> from file: SampleData.xml.
       @Column(name = "GRADE", nullable = true)
       private char grade; // Grade. Entity <Student><Course><Grade> from file: SampleData.xml.
       // Constructors.
       public Course_PK() {
       public Course_PK(long studentId, long courseid, String semesterCode) {
          this.studentId = studentId;
          this.courseId = courseId;
          this.semesterCode = semesterCode;
       // Accessors and mutators.
       public long getStudentId() {
          return (studentId);
       public void setStudentId(long studentId) {
          this.studentId = studentId;
       public String getCourseId() {
           return (courseId);
       public void setId(String courseId) {
           this.courseId = courseId;
       public String getSemesterCode() {
           return (semesterCode);
       public void setSemesterCode(String semesterCode) {
           this.semesterCode = semesterCode;
       public char getGrade() {
           return (grade);
       public void setGrade(char grade) {
           this.grade = grade;
       // Other methods.
       public boolean equals(Object obj) {
           if (obj == this) {
               return (true);
           if (!(obj instanceof Course_PK)) {
               return (false);
           if (obj == null) {
               return (false);
           Course_PK course = (Course_PK) obj;
           return ((course.studentId == studentId) &&
                   (course.courseId.equals(courseId)) &&
                   (course.semesterCode.equals(semesterCode)) &&
                   (course.grade == grade));
    }

    Because you have field
    @Column(name = "STUDENT_ID", length = 4, nullable = false)
       private long studentId; // Student ID. Entity <Student><ID> from file: SampleData.xml.In you Course_PK class. As a primary keys.
    An again you are joining it in field
        @ManyToOne(cascade=CascadeType.ALL)
       @JoinTable(name = "Student_EB", joinColumns= @JoinColumn(name = "STUDENT_ID", referencedColumnName = "studentId"))So it is appearing both inPrimary Key and in Foreign Key.

  • Need help mapping one-to-many relationship

    [Sorry, inadvertently cross-posted]
    Hello,
    I have a one-to-many mapping question that's probably a no-brainer for the
    experts of the group out there. My problem is that I can't get a collection
    of Items for a given Theme to be populated and I don't know if it's a
    problem in my system.jdo or in my classes (or both). For example, for Theme
    10,
    I want a collection of two Items, item_ids 1 and 2.
    I have db tables named ITEM and THEME with the following layouts:
    ITEM
    |==========================================================|
    | item_id(pk) | item_name | item_number | theme_id(fk) |
    |==========================================================|
    | 1 | This is Item1 | 1234 | 10 |
    | 2 | This is Item2 | 2954 | 10 |
    | 3 | This is Item3 | 2094 | 17 |
    | 4 | This is Item4 | 946 | 11 |
    | ... |
    |==========================================================|
    THEME
    |=======================================|
    | theme_id(pk) | theme_description |
    |=======================================|
    | 4 | Space |
    | 10 | Town |
    | 11 | Train |
    | 17 | Pirate |
    | ... |
    |=======================================|
    I have two PersistenceCapable classes that map to the above tables:
    package com.lego.data;
    public class Item
    public int item_id;
    private String item_number;
    private String item_name;
    private int theme_id;
    public Theme theme;
    public String toString()
    return
    item_number+":"+item_name+":"+theme.getCode()+":"+theme.getDescription();
    package com.lego.data;
    import java.util.*;
    public class Theme
    public int theme_id;
    public String theme_description;
    public Collection items;
    public String toString()
    return theme_id+":"+theme_description;
    and here is my system.jdo file:
    <?xml version = "1.0" encoding = "US-ASCII"?>
    <jdo>
    <package name="com.lego.data">
    <class name="Item" identity-type="application"
    objectid-class="com.lego.data.IntOId">
    <extension vendor-name="kodo" key="table" value="item"/>
    <extension vendor-name="kodo" key="lock-column" value="none"/>
    <extension vendor-name="kodo" key="class-column" value="none"/>
    <field name="item_id" primary-key="true">
    <extension vendor-name="kodo" key="data-column" value="item_id"/>
    </field>
    <field name="item_number">
    <extension vendor-name="kodo" key="data-column" value="item_number"/>
    </field>
    <field name="item_name">
    <extension vendor-name="kodo" key="data-column" value="item_name"/>
    </field>
    <field name="theme_id">
    <extension vendor-name="kodo" key="data-column" value="theme_id"/>
    </field>
    <field name="theme">
    <extension vendor-name="kodo" key="theme_id-data-column"
    value="theme_id"/>
    </field>
    </class>
    <class name="Theme" identity-type="application"
    objectid-class="com.lego.data.ThemeKey">
    <extension vendor-name="kodo" key="table" value="theme"/>
    <extension vendor-name="kodo" key="lock-column" value="none"/>
    <extension vendor-name="kodo" key="class-column" value="none"/>
    <field name="theme_id" primary-key="true">
    <extension vendor-name="kodo" key="data-column" value="theme_id"/>
    </field>
    <field name="theme_description">
    <extension vendor-name="kodo" key="data-column"
    value="theme_description"/>
    </field>
    <field name="items">
    <collection element-type="Item"/>
    <extension vendor-name="kodo" key="inverse" value="theme"/>
    </field>
    </class>
    </package>
    </jdo>
    Thanks in advance for the help.
    -Tim

    Abe White wrote:
    The first thing to check is that you are always setting the "theme" field in
    your Items. If you add an Item i to the "themes" collection of a Theme t, but
    forget to also set i's "theme" field to t, then the change will never get
    written to the database.
    Next, make sure that whenever you set the "theme" field of an Item, you also
    set
    its "theme_id" field. You map both of these fields to the same column, so you
    better be sure they stay in synch.
    On a related note, you might try making the "theme_id" field non-persistent if
    things still aren't working for you. Mapping two fields to the same column
    might be causing trouble. It would be safer to make theme_id non-persistent
    anyway, and to always grab the id from the Theme stored in your "theme"
    field.
    Better OO programming and all that, though I can see that you might have
    performance issues in mind when doing it your way.
    Anyway, if you find that it works when you make theme_id nonpersistent, let us
    know and we'll see why the double-mapping of the column is causing problems,
    and hopefully find a fix.Abe,
    Thanks for the response but I'm still confused. I failed to mention that
    the Item and Theme tables are in an existing schema, so as you saw in my
    system.jdo, I am specifying application identity.
    Since this is an existing schema, the Item table has theme_id as the
    foreign key to the Theme table. So are saying that it is a problem to map
    the both theme_id as a data column and a Theme object in the Item at the
    same time?
    I guess what I don't understand is exactly what my system.jdo should look
    like to map a one-to-many relationship. In my case, from Theme (1) to Item
    (many). (See my system.jdo in previous post).
    Thanks
    -Tim

  • JPA one to many relationship and serialization

    Hi,
    I modeled a one to may relationship like this:
    Parent Class WFData:
    @OneToMany(mappedBy = "wfData", targetEntity = Positionen.class)
    private Set<Positionen> positionen;
    Child Class Positionen
    @ManyToOne
    @JoinColumn(name = "WF_REF_ID", referencedColumnName = "ID")
    private WFData wfData;
    Now I want to create an EJB session bean with a method which returns an object of type WFData (parent) published as web service . When I try to deploy the web service I get the following error message: Unable to generate serialization framework for web service
    Does anyone know how to serialize a one-to-many relationship so I can use these objects in a web service?
    Best regards,
    Kevin

    I found the solution to get serialization correctly working and enable the service to be used in Visual Composer.
    You need to add the tag @XmlTransient to the getter method of the attribute in the child class that references the parent.
    @XmlTransient
    public WFData getWfData() {
        return wfData;

  • Techniques to eliminate ripple loading in one to many relationships

    Hi,
    In my domain model, I have a class O that has a one to many relationship with class M. The relationship is mapped in TOPLink as a one to many from O to M, and a one to one from M to O.
    An end user logs into our application that has an otherwise cold TOPLink cache and executes a use case that will render several to many aspects of each O instance, and there are many O instances to render a majority of the time.
    The first time a question is asked of an O instance that requires its M instances to answer the question, TOPLink will detect the unstubbing of that ValueHolder, and cause a SQL query to pull in the necessary M instances for that O instance.
    One technique to combat this ripple load is to mark the relationship between O and M to "useBatchReading". I am motivated to attempt a different technique in the particular scenario I am experiencing though.
    Another technique would seem to be to fetch all of the M instances for all of the O instances to be rendered, compute the relevant Collection of M instances for each O instance and then call mValueHolder.setValue(readCollectionOfMs) on each O instance. Is this technique feasible? Seems like it doesn't align with the intent of the TOPLink API.
    Are there any other techniques that can be used to solve this issue as well?
    Thanks,
    Doug

    Doug,
    What I believe you want is join and batch reading configured on the queries of your specific use case. That gives you much finer control then configuring these on the mappings.
    With TopLink you should have your use cases issue a fixed quantity of SQL statements irrelevant of the # of objects returned from the root query.
    Have you taken a look at the performance tuning chapter in the documentation?
    I hope this helps,
    Doug

  • Urgent : java bean having bidirectional one to many relationship

    Hi,
    We have complex requirement in our application.
    We need to copy java bean having bidirectional one to many relationship to another javabean having bidirectional one to many relationship..
    E.g
    Class Basket1 {
    public String color;
    pubic String type;
    public List<Basket1> basketList = new ArrayList()
    Class Basket2 {
    public String color;
    pubic String type;
    public List<Basket2> basketList = new ArrayList()
    We need to exact copy Basket1 to Basket2. We are in trouble to copy List of child because we do not have how many child Basket1 have of same type..
    Can someone help us how we can implement such kind of complex object bidirectional one to many relationship??

    I can't see anything bidirectional about these relationships. What I can see is a couple of BasketN classes that look identical so I don't know why they both exist, and they both contain lists of themselves as members, which suggests some kind of tree structure. Nothing bidirectional there. I can see tat these things can form circular object graphs but I don't see why you would want to do that.
    We need to exact copy Basket1 to Basket2And I don't know what that means. Please explain.

  • Creating data in a many-to-many-relationship

    Hello,
    we really have problems in implementing a JClient dialog based on BC4J for creating data in a many to many relationship - especially with cascade delete on both sides.
    Simplified our tables look like:
    create table A_TABLE
    A_ID VARCHAR2(5) not null,
    A_NAME VARCHAR2(30) not null,
    constraint PK_A_TABLE primary key (A_ID),
    constraint UK_A_TABLE unique (A_NAME)
    create table B_TABLE
    B_ID VARCHAR2(5) not null,
    B_NAME VARCHAR2(30) not null,
    constraint PK_B_TABLE primary key (B_ID),
    constraint UK_B_TABLE unique (B_NAME)
    create table AB_TABLE
    A_ID VARCHAR2(5) not null,
    B_ID VARCHAR2(5) not null,
    constraint PK_AB_TABLE primary key (A_ID, B_ID),
    constraint FK_AB_A foreign key (A_ID) references A_TABLE (A_ID) on delete cascade,
    constraint FK_AB_B foreign key (B_ID) references B_TABLE (B_ID) on delete cascade
    Could JDev Team please provide a BC4J/JClient sample that performs the following task:
    The dialog should use A_TABLE as master and AB_TABLE as detail. The detail displays the names associated with the IDs. Next to AB_TABLE should be a view of B_TABLE which only displays rows that are currently not in AB_TABLE. Two buttons are used for adding and removing rows in AB_TABLE. After adding or removing rows in the intersection the B_TABLE view should be updated. The whole thing should work in the middle and client tier. This means no database round trips after each add/remove, no posts for AB_TABLE and no query reexecution for B_TABLE until commit/rollback.
    This is a very common szenario: For an item group (A_TABLE) one can select and deselect items (AB_TABLE) from a list of available items (B_TABLE). Most of JDeveloper4s wizards use this. They can handle multi/single selections, selections from complex structures like trees and so on. Ok, the wizards are not based on BC4J - or? How can we do it with BC4J?
    Our main problems are:
    1. Updating the view of B_TABLE after add/remove reflecting the current selection
    2. A good strategy for displaying the names instead of the IDs (subqueries or joining the three tables)
    3. A JBO-27101 DeadEntityAccessException when removing an existing row from AB_TABLE and adding it again
    Other problems:
    4. We get a JBO-25030 InvalidOwnerException when creating a row in AB_TABLE. This is caused by the composition. We workaround this using createAndInitRow(AttributeList) on the view object (instead of create()). This is our add-Action:
    ViewObject abVO = panelBinding.getApplicationModule().findViewObject("ABView");
    ViewObject bVO = panelBinding.getApplicationModule().findViewObject("BView");
    Row bRow = bVO.getCurrentRow();
    NameValuePairs attribList = new NameValuePairs(
    new String[]{"BId"}, new Object[]{bRow.getAttribute("BId")});
    Row newRow = abVO.createAndInitRow(attribList);
    abVO.insertRow(newRow);
    5. After inserting the new row the NavigationBar has enabled commit/rollback buttons and AB_TABLE displays the row. But performing a commit does nothing. With the following statement after insertRow(newRow) the new row is created in the database:
    newRow.setAttribute("BId", bRow.getAttribute("BId"));
    Please give us some help on this subject.
    Best regards
    Michael Thal

    <Another attempt to post a reply. >
    Could JDev Team please provide a BC4J/JClient sample
    that performs the following task:
    The dialog should use A_TABLE as master and AB_TABLE
    as detail. The detail displays the names associated
    with the IDs. Next to AB_TABLE should be a view of
    B_TABLE which only displays rows that are currently
    not in AB_TABLE. Two buttons are used for adding and
    removing rows in AB_TABLE. After adding or removing
    rows in the intersection the B_TABLE view should be
    updated. The whole thing should work in the middle
    and client tier. This means no database round trips
    after each add/remove, no posts for AB_TABLE and no
    query reexecution for B_TABLE until commit/rollback.
    This is a very common szenario: For an item group
    (A_TABLE) one can select and deselect items
    (AB_TABLE) from a list of available items (B_TABLE).
    Most of JDeveloper4s wizards use this. They can
    handle multi/single selections, selections from
    complex structures like trees and so on. Ok, the
    wizards are not based on BC4J - or? How can we do it
    with BC4J?
    Our main problems are:
    1. Updating the view of B_TABLE after add/remove
    reflecting the current selectionYou should be able to use insertRow() to insert the row into proper collection.
    However to remove a row only from the collection, you need to add a method on the VO subclasses (and perhaps export this method so that the client side should see it) to unlink a row from a collection (but not remove the associated entities from the cache).
    This new method should use ViewRowSetImpl.removeRowAt() method to remove the row entry at the given index from it's collection. Note that this is an absolute index and not a range index in the collection.
    2. A good strategy for displaying the names instead
    of the IDs (subqueries or joining the three tables)You should join the three tables by using reference (and perhaps readonly) entities.
    3. A JBO-27101 DeadEntityAccessException when
    removing an existing row from AB_TABLE and adding it
    againThis is happening due to remove() method on the Row which is marking the row as removed. Attempts to add this row into another collection will throw a DeadEntityAccessException.
    You may 'remove the row from it's collection, then call 'Row.refresh' on it to revert the entity back to undeleted state.
    >
    Other problems:
    4. We get a JBO-25030 InvalidOwnerException when
    creating a row in AB_TABLE. This is caused by the
    composition. We workaround this using
    createAndInitRow(AttributeList) on the view object
    (instead of create()). This is our add-Action:
    ViewObject abVO =
    O =
    panelBinding.getApplicationModule().findViewObject("AB
    iew");
    ViewObject bVO =
    O =
    panelBinding.getApplicationModule().findViewObject("BV
    ew");
    Row bRow = bVO.getCurrentRow();
    NameValuePairs attribList = new NameValuePairs(
    new String[]{"BId"}, new
    String[]{"BId"}, new
    Object[]{bRow.getAttribute("BId")});
    Row newRow = abVO.createAndInitRow(attribList);
    abVO.insertRow(newRow);This is a handy approach. Note that Bc4j framework does not support dual composition where the same detail can be owned by two or more masters. In those cases, you also need to implement post ordering to post the masters before the detail (and reverse ordering for deletes).
    >
    5. After inserting the new row the NavigationBar has
    enabled commit/rollback buttons and AB_TABLE displays
    the row. But performing a commit does nothing. With
    the following statement after insertRow(newRow) the
    new row is created in the database:
    newRow.setAttribute("BId",
    d", bRow.getAttribute("BId"));This bug in JDev 903 was fixed and a patch set (9.0.3.1) is (I believe) available now via MetaLink.
    >
    >
    Please give us some help on this subject.
    Best regards
    Michael Thal

  • How to insert data in a one-to-many relationship

    How do you insert data into the client, my model entity beans have a one-to-many relationship.
    PARENT ENTITY BEAN
    PARENT-ID
    PARENT-NAME
    The ejbCreate(Integer parentID,String name)
    CHILD ENTITY BEAN
    CHILD-ID
    CHILD-NAME
    PARENT-ID(foreign key of PARENTID).
    ejbCreate(Integer parentID,String name,String foreignparentID)
    In a jsp page i collect the parent details and 3 corresponding chld details in a text box.
    Can you please tell me how do i proceed from here...
    ie. how to i insert data into the entity beans..
    Do i pass the child as a collection, and within parents ejbCreate() method do i lookup for the childs home interface and insert one -by -one from the collection.
    1. Considering the above example, can some one pls tell how the ejbCreate() mehod signatures, for the parent and child entity beans should be.
    2. Pls also show some sample client code as to how to make an insertion.
    3. In case you are passing a collection of child data, then in what format does one have to insert into a collection and also how does the container know how to insert the values in the child table , bcoz we are passing as a collection.
    4.In case collections cannot be inserted do we need to iterate into the collection in parent's ejbCreate() method, and manually insert into the database of the childtable, thereby creating child entity beans.
    Thanks for your time and support...
    regards
    kartik

    Hi,
    3. In this case of course child's ejbCreate(and postCreate) looks like
    ejbCreate(Integer childID,String name,ParentLocal parent) {
    setId(Id);
    setName(name);
    ejbPostCreate(Integer childID,String name,ParentLocal parent) {
    setParent(parent);
    Here you don't need IDs, but it happens only using Locals, not Remotes, if I'm not wrong. Container does it itself.
    1. Of course, if you have parent.getChildren() and parent.setChildren() then you don't need any loops, but it should be done anyway in postCreate, because in ejbCreate there no parent exists yet.
    Once more 3: example - I'm using JBoss 3.2.5 as EJB container. It has tomcat inside and EJB and JSP+Struts use the same jvm. It means for me that I don't need to use remote interfaces, just locals. And in this case I can implement ejb-relations. So, a have the abstract method parent.getChildren() which returns Collection of ChildLocal - s and method parent.setChildren(Collection childrenLocals) which creates/modifies children by itself.
    I have not used remotes for a long time, but as I remember it was not possible to implement ejb-relations using remotes.
    regards,
    Gio

  • Many-to-many relationship - show all values

    Hi,
    I'm building a cube in 2008R2 and have a many-to-many relationship through a bridging table but when displaying the results it is effectively an inner join and I would like to see a full outer join with the unknown rows set to "unknown".
    I've managed to achieve this by doing a full outer join in the view that creates my bridging table and having an unknown member in my dimensions but then when I added in a dimension that wasn't directly related to the bridging table the unknown rows
    were removed again. I was able to get past this by adding a row to my fact table with all the keys set to unknown and the metrics set to zero.
    Whilst this works it really does not seem like an ideal solution, especially as previously empty metrics are now returning a zero.
    Is there any way to achieve this in SSAS? Perhaps in the way unknown members are processed?
    Thanks,

    cccparkhill,
    What you did is the only way to achieve what you want.
    In cubes you connect Dimensions throw Facts. By definition dimensions are
    “How do business people describe the data that
    results from the business process?”
     and facts are “What are we measuring?”, noting the underlined
    we can understand that _normally and usually_ the relation between the dimensions and the facts represent incidents happened in the real world ... the way you approach, think, and deal with dimensions and facts in cubes is different than dealing with tables
    in normal relational transnational database.
    Personally I do what you did when I want to achieve "Left join"
    Please mark this reply as the answer
    or vote as helpful, as appropriate, to make it useful for other readers

  • Many to Many Relationship

    In powerpivot we are facing problem in resolving the many-to-many relationship between tables.
    Current table schema is:
    Having 4 tables-
    Bills - columns are- Bill No(primary key)
    Billing Fee Table-Fee ID(primary key), Bill Type, Sub Bill Type
    FeeList Table-FeeList ID(primary key),Fee ID(Foriegn Key to Billingble),
    Bill No(Foriegn Key to Bills)
    Payments Table-Pay ID(Primary Key), Bill No(Foriegn Key to Bills)
    Bills is the primary table for Feelist Table
    and Payments Table -Bill No is the primary key.
    Billing Fee Table is primary table for FeeList Table -
    Fee ID is the primary key.
    To create a pivot table using Payments Table, I need
    Bill Type and Sub Bill Type. Hence fetched from
    Biling Fee Table to FeeList Table based on the
    Fee ID column using RELATED function.
    As FeeList Table and Payments Table is having duplicate
    Bill Nos, it is not possible to get Bill Type and
    Sub Bill Type to Payments Table. I am trying to use LOOKUPVALUE
    function to get data based on the Bill No, as there is no direct relationship exists between these two tables.
    I have tried using
    =LOOKUPVALUE('FeeList Table'[Sub Bill Type], 'FeeList Table'[Bill No], 'Payments Table'[Bill No]) function. But
    the lookupvalue function returns an error if a duplicate is found.
    Error is as below:
    Calculation error in column 'Payments Table'[Sub Bill Type]: A table of multiple values was supplied where a single value was expected.
    Kindly assist to resolve this issue.
    Thanks

    Hi Rekha,
    What should your LOOKUPVALUE return if multiple rows are found in the FeeListTable? By the way it should work if a really finds "duplicates" (i.e. multiple times the same return value) but fails if it returns multiple rows with different values.
    If you for example would want to return the first entry that was found, you could try (have not checked in PP for typos):
    CALCULATE(MIN('FeeList Table'[Sub Bill Type]),
      FILTER('FeeList Table',
         'FeeList Table'[Bill No] = 'Payments Table'[Bill No]
    Edit: a very nice way to handle Many-to-Many relationships is explained here:
    http://blog.gbrueckl.at/2012/05/resolving-many-to-many-relationships-leveraging-dax-cross-table-filtering/
    Julian Wissel | BI for NAV @ http://en.navbi.com | Blog @ blog.navida.eu

  • Many to many relationships (Again)

    Hello,
    There was a posting on above subject.
    Re: Many to many relationships between Fact and Dimension
    They asked to look chapter 3 in the user's guide... <http://download.oracle.com/docs/pdf/B10996_01.pdf>. chapter 3 talks about defining Oracle Data Objects. I could find above subject in chapter 3 .
    Here is our situation We are using OWB 9.2.0.2.8. We are in a situation to build ETL from denormalized (relational tables) source to normalized target (relational tables). It is not a data warehouse situation. It could be a reverse of data warehouse. As given below
    Supplier >--------------------<Item
    becomes Supplier ------<supp_item.>--------------Item after many to many resolution, Where supp_item is interface table.
    We were able build Supplier and Item through seprate mapping. I could build supp_item through post mapping process. I look for alternate thought as well.
    We are using separate sequence number for Supplier , Item and supp_item. The sequences will be surrogate keys such as Supplier ( Suppseq(PK)), Item (Itemseq (PK)) and supp_item(suppitemseq (PK)) Here is the sample
    Supplier
    001|S001
    002|S002
    003|S003
    004|S004
    Item
    001|I001
    002|I002
    003|I003
    Supp_item (Suppseq|ItemSeq)
    001|002 --- S001 I002
    001003 -----S001 I003
    001|004 ----- S001 I 004
    002|002 ---- S 002 I002
    002|003 ---- S 002 I003
    003|001 --- S 003 I 003
    003|003 --- S 003 I 003
    Did any body face such situation? What is the best way to create a mapping (single map or multiple map with processflow sequence) for this situation?
    Let me know the steps exercised in OWB for this situation.
    I appreciate your help.
    Regards
    Ram

    Hi Ram,
    The easiest way to do this, would be to:
    - Load supplier in one mapping and generate the surrogate key.
    - Load item another (or the same) mapping and generate the surrogate key.
    - Load supplier_item in its own separate mapping, using a key lookup (or join) to (with) the supplier and item tables.
    Needless to say, you should create unique keys on the natural key of the supplier and item tables, to enable quick index-based lookups and make sure you get one unique value for every value of the natural key.
    Hope this helps,
    Mark.

Maybe you are looking for

  • Problem with Acrobat Pro XI

    I can't seem to use Acrobat Pro XI, everytime I try to edit a text, it keep popping up the window "Acrobat has encountered an unknown error." Please help me. I had tried to uninstall Acrobat Pro XI and reinstall it again; however, the same problem is

  • Service Manager 2012 R2 report libraries don't deploy

    So I've got a fresh install of Service Manager 2012 R2 with SQL Server '08 R2 in the 4 server layout, everything on Hyper-V. My issue is this: after registering the data warehouse, everything appears to function normally, the MPSyncJob completes its

  • Qosmio X300 asking for Username and password

    Good evening I just bought I Toshiba laptop and m really not tech. I bought it new and sealed from ebay but it is asking for a password!! Username it is telling me it was zjmarkeecomp and its hint for the password is iggy. Does this mean it was used

  • Need FireFox installations from version 3 till present for MAC and Windows

    Good day! I am working for a Software Testing Company, and I need installations for FireFox from Version 3 to present. for Mac and Windows. Is there any way I can get these installations, Cant seem to find them on website. It will be very much apprec

  • Changing MP3 Pitch/Speed.

    I know that you can modulate (change the Key center) of projects written in Garageband '08. Is it possible to make slight (fine tune) adjustments in pitch mp3's that I drag into Garageband '08? If doing so requires to slightly change the speed of the