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;

Similar Messages

  • ONE-to-MANY relationship between tables and forms in APEX

    I recently started using APEX and I have run into an issue.
    I have a ONE-TO-MANY relationship between two tables, A1 and A2, respectively.
    A1:
    A1_ID
    Item
    A2:
    A2_ID
    SubItem
    A1_ID
    I have 2 forms (lets call it F1 and F2) that I use to capture data for A1 and A2.
    On F2, I have the following fields that are setup to capture data:
         A2.A1_ID
    **A1.Item (this is a drop down that is populated using a SELECT statement where the select uses A1.Item field)
         A2.SubItem (user would enter SubItem)
    Note: A2.A2_ID is populated using a SEQ
    Everytime I pick **A1.Item on F2, is there a way to link to A1 table and display A1.A1_ID for every **A1.Item selected on F2?
    If so, I want to store the value captured in F2 for the A1_ID field into A2 table to maintain my 1-to-MANY relationship.
    If this will work, how do I go about implementing this solution?
    Can someone help me?

    I think it sounds like you are asking for a Master-Detail form. Try that and see what you get.
    chris.

  • 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 relationship in hibernate

    I am very much new to hibernate,
    for testing purpose I am using JPA annotations and hibernate.
    While testing one to many relationship , I got a problem
    I have a PurchaseOrder class and OrderLine class having one to many relationship.
    package orderpackage;
    import java.util.ArrayList;
    import java.util.List;
    import javax.persistence.CascadeType;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.OneToMany;
    @Entity
    public class PurchaseOrder {
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      private int id;
      @OneToMany(cascade=CascadeType.ALL,mappedBy="order")
      private List <OrderLine> orderLine = new ArrayList<OrderLine>();
      public PurchaseOrder(String orderName) {
      this.orderName = orderName;
      public List<OrderLine> getOrderLine() {
      return orderLine;
      public void setOrderLine(List<OrderLine> orderLine) {
      this.orderLine = orderLine;
      private String orderName;
      public int getId() {
      return id;
      public void setId(int id) {
      this.id = id;
      public String getOrderName() {
      return orderName;
      public void setOrderName(String orderName) {
      this.orderName = orderName;
    OrderLine.java
    package orderpackage;
    import javax.persistence.CascadeType;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.ManyToOne;
    @Entity
    public class OrderLine {
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      private int id;
      private String itemName;
      private int qty;
      @ManyToOne(cascade=CascadeType.ALL)
      private PurchaseOrder order;
      public OrderLine(String itemName, int qty) {
      this.itemName = itemName;
      this.qty = qty;
      public PurchaseOrder getOrder() {
      return order;
      public void setOrder(PurchaseOrder order) {
      this.order = order;
      public int getId() {
      return id;
      public void setId(int id) {
      this.id = id;
      public String getItemName() {
      return itemName;
      public void setItemName(String itemName) {
      this.itemName = itemName;
      public int getQty() {
      return qty;
      public void setQty(int qty) {
      this.qty = qty;
         OrderTest.java
    package orderpackage;
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.cfg.Configuration;
    public class OrderTest {
      public static void main(String[] args) {
      PurchaseOrder order = new PurchaseOrder("order no 1");
      OrderLine orderLine1 = new OrderLine("item1",25);
      OrderLine orderLine2 = new OrderLine("item2",28);
      OrderLine orderLine3 = new OrderLine("item3",38);
      OrderLine orderLine4 = new OrderLine("item4",48);
      order.getOrderLine().add(orderLine1);
      order.getOrderLine().add(orderLine2);
      order.getOrderLine().add(orderLine3);
      order.getOrderLine().add(orderLine4);
      SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
      Session session = sessionFactory.openSession();
      session.beginTransaction();
      session.persist(order);
      session.getTransaction().commit();
      session.close();
    I can see Order and Order Line are get persisted but Order Line table don't have order_id populated automatically. Please help me out.

    That is because you're not setting it, obviously. Nowhere in your code are you actually populating the order property of the orderlines.

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

  • Persisting an instance of the many side of a in one to many relationship

    It seems as if most books only tell you how to setup the relationship for a one to many relationship but seems to fail to tell you the appropriate way to persist in this relationship. So, I have a parent class with many child classes. Also, I am using services and so I am converting from Entities to Dtos and visa versa.
    First, i want to insert a new child for the parent. Do I just convert the child Dto to a child entity and then persist the child entity with the reference to the parent? Then do I find the parent and add the child to the parents children so the entities are consistent?
    Or do I do a find on the parent and add the child to the parents children list and the child. Will the child be persisted automatically?
    With this said, what about updating a child? Do I remove the existing child and add a new one? or do I somehow find the child in the parents children set and update the info there and then somehow the child is persisted automatically? And since I am using Dto to entity, do I use a find to find the parent and then iterate through that parents children til I reach the child I modified by id somehow.
    What about Many to Many relationships? With a middle join table? How does JPA know to remove a join if I change the child reference? Does it remove the old and insert the new? Or do I have to do it myself somehow. Which if the later then I really can not have a parent child Dto I really need a parent childlink table where the child is referenced by the linktable? The book I have been reading has not made this very clear.

    Hello,
    The relationships cascade settings determine what should happen. I would not recommend persisting a new entity that references a non-managed entity. Instead either persist the child then make the associations or find the parent, make the associations then persist the child. In the second case, you do not need to explicietly persist the child if the parent->child relationship is marked cascade persist, since it will be found on flush or commit.
    Since you are using DTOs, updates require you merge the changes. You can directly merge the child, and if it has a link to its parent, modify the parent to add the child on the managed child that gets returned.
    As for ManyToMany, you must modify the side that controls the relationship. So if the parent owns it, then you must modify or merge the changes into the parent for the changes to be persisted to the database. If it is bi-directional, you must modify both sides so that the cache remains consistent with the database. This should be transparent to your application, and you only need an entity for the relation table if you want to map more complex information that doesn't fit into the JPA ManyToMany options. Otherwise, JPA should handle inserting and deleting enteries to the relation table for you.
    Best Regards,
    Chris

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

  • 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

  • Struggling with a one to many relationship in a sub-report

    Post Author: Scott_tansley
    CA Forum: General
    I have a database schema as per below: tblENQUIRY                 tblDatasheets                  tblReportParasIRSID (PK)       1 --> &  IRSID (FK)                       UID (PK)Attribute1                     SHEETID (PK)     1 > &  SHEETID (FK)Attribute2                     Attribute1                         LIST_ORDER                         tblStandardParasAttribute3                     Attribute2                         PARA_CODE (FK)    & < 1   CODE     (PK)etc...                            Attribute3                                                                     TEXT                                   etc...
    The PROBLEM I am a Crystal Reports Newbie, and having to work through things bit by bitu2026  I've managed to achieve quite a lot, but I'm totally stuck with this and would appreciate some help. I need to create a report (essentially a letter and some datasheets) around a one-to-many relationship, which I have managed to compile using a main report (for the one &#91;tblENQUIRY&#93;) and sub report (for the many &#91;tblDatasheets&#93;).  Essentially I need a covering letter, then the u2018manyu2019 datasheets, and then a number of other pages (which are largely static text). I have created a main report which includes the covering letter, holds a subreport for the datasheets, and then contains the text for the additional pages.  This all works fine, and I get the correct number of datasheets for each main report. My problem stems from the use of this sub report.  This sub-report needs to hold some attribute values for each datasheet, which is fine.  However, on each datasheet page I need to have some paragraphs, which are held in another one to many relationship.  Each datasheet may have up to six paragraphs held as a code in tblReportParas, with a relationship to the text as held in tblStandardParas. My original thought would have been to embed another sub report, containing the values from tblStandardParas!TEXT, into the first sub report.  However, I have found that it is not possible to have a sub-report inside another sub-report.  I had seperated the first sub-report out from the main report, and then embedded another sub-report into it.  This worked fine until I tried to stitch the sub-report back into the main report (at which point the sub-sub-report dissapeared from view). I have therefore reworked my sub-report a little, and the attribution is now stored in a pageheader, with the tblStandardParas!TEXT in a detail section below it.  This almost works! The only problem is that there is no relationship between the pageheader and detail sections.  To clarify, I would expect to have one datasheet, with the attribution at the top, and then the six paras below.  Then, the same on the next page (assuming there is a second datasheet) for that report.  Instead, I get the correct attribution, but the detail section actually gives every paragraph in the database, no matter which datasheet/or report it related to!  I therefore need to limit the detail section to only show those paragraphs where the SHEETID in tblReportParas is the same as the tblDatasheets SHEETID. Any offers of advice would be appreciated.

    Post Author: Scott_tansley
    CA Forum: General
    I managed to resolve this myself in the end.  I moves the tblEnquiry data into report header/footer sections, this allowed me to add the tblDatasheets information into the details section, which gave me multiple pages - and then finally, the Paragraphs were added through the use of a sub report. 
    There's probably an even better way, but for now it works, it's quick - and so I'm going to go with it!
    Thanks for your interest.

  • How do I create a One to many relationship page in Dreamweaver?

    How do I create a page in dreamweaver that comes up after the user logs in from the log in page that will allow the user to:
    Add, change and delete in 2 tables that are in my MYSQL database that is a one to many relationship
    One thing that is confusing is how the foreign key that links to the one side of the relationship is created in the many side without the user inputting the foreign key each time adding information to the many side table.
    I am creating this in Dreamweaver using a MYSQL database and PHP.

    >Would the following be a part of it:
    >
    >Outer join
    Probably not. When updating/inserting/deleting from 2 tables you perform each seperately. Table updates may join two or more tables to resolve the correct row(s) but you still only update one table at a time. Procedurally you would create a transaction, update the first table, update the second table and then commit the transaction.
    EDIT: Well I take back my last comment. I see that MySQL does seem to support multiple table updates. I don't use MySQL so I can't really help you on that but the MySQL manual gives pretty clear syntax.

  • 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

  • Newbie: one to many relationship SQL error

    Greetings all-
    This is probably a slam dunk for you JDO experts. I'm a JDO newbie, working
    with an existing schema in MySQL. I have a one to many relationship between
    two tables:
    Table "company":
    Fields:
    company_id: int(11) -- primary key
    name : varchar(64)
    division : varchar(64)
    Table "company_products"
    Fields:
    company_id: int(11) -- foreign key to table company
    product_name: varchar(64)
    product_description: varchar(64)
    So, I created the corresponding classes:
    public class Company {
    private int companyID;
    private String company_name;
    private String division;
    // Array of CompanyProduct
    private ArrayList companyProducts;
    // .. methods omitted
    public class CompanyProduct {
    private int companyID;
    private String productName;
    private String productDesc;
    // Methods omitted
    Then I created the "package.jdo" file:
    <?xml version="1.0"?>
    <jdo>
    <package name="com.packexpo.db">
    <class name="Company">
    <extension vendor-name="tt" key="table" value="company"/>
    <extension vendor-name="tt" key="pk-column" value="company_id"/>
    <extension vendor-name="tt" key="lock-column" value="none"/>
    <extension vendor-name="tt" key="class-column" value="none"/>
    <field name="companyID">
    <extension vendor-name="tt" key="data-column" value="company_id"/>
    </field>
    <field name="name">
    <extension vendor-name="tt" key="data-column" value="name"/>
    <extension vendor-name="tt" key="column-length" value="64"/>
    </field>
    <field name="division">
    <extension vendor-name="tt" key="data-column" value="division"/>
    <extension vendor-name="tt" key="column-length" value="64"/>
    </field>
    <field name="companyProducts">
    <collection element-type="com.packexpo.db.CompanyProduct"/>
    <extension vendor-name="tt" key="inverse" value="companyID"/>
    </field>
    </class>
    <class name="CompanyProduct">
    <extension vendor-name="tt" key="table" value="company_product"/>
    <extension vendor-name="tt" key="pk-column" value="company_id"/>
    <extension vendor-name="tt" key="lock-column" value="none"/>
    <extension vendor-name="tt" key="class-column" value="none"/>
    <field name="companyID">
    <extension vendor-name="tt" key="data-column" value="company_id"/>
    </field>
    <field name="productName">
    <extension vendor-name="tt" key="data-column" value="product_name"/>
    <extension vendor-name="tt" key="column-length" value="64"/>
    </field>
    <field name="productDesc">
    <extension vendor-name="tt" key="data-column"
    value="product_description"/>
    <extension vendor-name="tt" key="column-length" value="64"/>
    </field>
    </class>
    </package>
    </jdo>
    Enhancement works fine. I successfully query and retrive Company objects
    from the database, but as soon as I try to get the list of CompanyProducts,
    I get an SQL Error:
    javax.jdo.JDODataStoreException: [SQL=SELECT company.COMPANYPRODUCTSX FROM
    company WHERE company.company_id = 82061]
    E0610 Error in executeQuery()
    E0606 executeQuery() error --
    E0701 Error in getResult().
    E0708 Command results in error - 1054 Unknown column
    'company.COMPANYPRODUCTSX' in 'field list'
    NestedThrowables:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper: [SQL=SELECT
    company.COMPANYPRODUCTSX FROM company WHERE company.company_id = 82061]
    E0610 Error in executeQuery()
    E0606 executeQuery() error --
    E0701 Error in getResult().
    E0708 Command results in error - 1054 Unknown column
    'company.COMPANYPRODUCTSX' in 'field list'
    I know i have probably set up the package.jdo file incorrectly, but I'm at a
    loss for what I did wrong.
    Any suggestions?
    Thanks!
    -Mike

    Hi,
    915766 wrote:
    I need to write sql for below requirement:
    table structure is
    serial no LPN
    1 4
    2 4
    3 6
    4 6
    5 6
    6 3
    7 3
    8 3
    9 1
    I have to pick distinct 'LPN' like below:That sounds like a job for "GROUP BY lpn".
    (any serial no can be picked for the distinct LPN)It looks like you're displaying the lowest serial_no for each lpn. That's easy to do, using the aggregate MIN function.
    results needs to be as below:
    serial no LPN
    1 4
    3 6
    6 3
    9 1
    Please suggest with sql.Here's one way:
    SELECT    MIN (serial_no)   AS serial_no
    ,         lpn
    FROM      table_x
    GROUP BY  lpn
    ORDER BY  lpn     -- if wanted
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • Toplink one to many relationship

    I am working on DAO layer for One to many relationship
    how can we get the list child objects based on parent id..
    we are using toplink ...

    Hi,
    If you are using with JPA, try this:
    em.createQuery("select c from child c where c.parent.id = :id").setParameter("id", parentObject.getId())
                                                                                           .getResultList();

  • Summarizing data in a one-to-many relationship

    Post Author: Bob Amiral
    CA Forum: General
    I use an order tracking system that has a one to many relationship between the main order information file and the line items file.  For each order, there can be one or more items in the items file.  I am having no luck trying to summarize data in such a way that shows selected information from the order file with only a summary from the item file on one line.  Instead, the reports expands by adding a line for each and every entry from the item file that relates to the order.
    How can I summarize data from the item file to show only one line of item data in the same line as the order data?

    Post Author: Charliy
    CA Forum: General
    Group by Order #
    Suppress the Detail (and possibly the Group Header, depending on how you want it to look)
    Put Running Totals in the Group Footer that reset on change of group.

  • 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

Maybe you are looking for

  • Which is better...s-video or Apple AV cable

    Anyone care to share their experiences with which cable brought better results...the s-video from a Universal Dock or the Apple A/V kit that plugs into the headphone jack? How do those compare to the DLO product? I have a 56" DLP widescreen TV so I'm

  • Is it possible for me to script Illustrator to save as PDF and attach to email ?

    Hi, I am after a script to save my current working file as PDF (with some settings) and then bring up a blank outlook email with that file attached ? I do a lot of artwork and have to get it approved, I am getting bored of manually saving to PDF then

  • EP Web services need to be restarted after some inactivity period

    Hi All, My EP Web services go down after some inactivity period. The services need to be restarted. Can anybody help me on this? Thanks!

  • CO-PC-ACT:CKM3 performance: MLREPORT

    Dear all, In material price analysis(CKM3), if I click on 'Procurement' under 'Receipts', the details will be displayed after 10 minutes. I checked this program(SAPLCKM8N) and found that system spends more than 98% time on Sequential Read table 'MLRE

  • Lenovo T510

    Have a T510 Model 4349WQ9. Need to run using XP. Having problems with drivers for Video Controller VGA Compatible. Display Adapters are Intel HD Graphics and Nividia NVS 3100M Looking for drivers to support this under XP