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.

Similar Messages

  • Having trouble with a one to many relationship in Crystal reports 11

    I have an old report that I inherited.  I have two main tables from which I draw data into this report:  QAmonitortrack and monitorsperfm.  I am correctly getting my data out of the QAmonitortrack table as the data relationships are one to one, but when I try to retrive data from the monitosperfm table, I only get one record back for each csrid.  I am trying to calculate the number of [callid] in the monitosperfm table for the fiscal month.  I have been through almost all of the table links and tried changing the link properties to give me more than one callid for each csrid I pulled out of qamonitortrack table.
    Any suggestions?
    Thanks...sql listed below:
    SELECT "tblSupervisors"."LastName", "tblSupervisors"."FirstName", "tblCSR"."LastName", "tblCSR"."FirstName", "tblDirectors"."LastName", "tblDirectors"."FirstName", "tblSupervisors"."SupervisorID", "tblQAMonitorTrack"."CSR_ID", "tblQAMonitorTrack"."FiscalYear", "tblQAMonitorTrack"."FW_Month", "tblQAMonitorFWCalendar"."FiscalYear", "tblQAMonitorFWCalendar"."Fiscal_Month", "tblFM_BeginEndDates"."fm_start_date", "tblQAMonitorTrack"."FiscalWeek", "tblFM_BeginEndDates"."fm_end_date", "tblQAMonitorFWCalendar_1"."FiscalWeek", "tblQAMonitorFWCalendar_2"."FiscalWeek", "tblMonitorsPerFM"."callid", "tblMonitorsPerFM"."score", "tblQAMonitorFWCalendar"."FW_Start_Date", "tblQAMonitorFWCalendar"."FW_End_Date", "tblQAMonitorFWCalendar"."FW_Week_of_Month", "tblQAMonitorTrack"."CallsHandled", "tblCSR"."Group_ID", "tblPosition"."PositionDesc", "tblMonitorsPerFM"."dateofmonitor"
    FROM   ((((((((("SMG_APPS"."dbo"."tblQAMonitorTrack" "tblQAMonitorTrack" INNER JOIN "SMG_APPS"."dbo"."tblManagers" "tblManagers" ON "tblQAMonitorTrack"."Mgr_id"="tblManagers"."ManagerID") INNER JOIN "SMG_APPS"."dbo"."tblSupervisors" "tblSupervisors" ON ("tblQAMonitorTrack"."Sup_Id"="tblSupervisors"."SupervisorID") AND ("tblManagers"."ManagerID"="tblSupervisors"."ManagerID")) INNER JOIN "SMG_APPS"."dbo"."tblCSR" "tblCSR" ON "tblQAMonitorTrack"."CSR_ID"="tblCSR"."CSRID") INNER JOIN "SMG_APPS"."dbo"."tblFM_BeginEndDates" "tblFM_BeginEndDates" ON ("tblQAMonitorTrack"."FiscalYear"="tblFM_BeginEndDates"."fiscalyear") AND ("tblQAMonitorTrack"."FW_Month"="tblFM_BeginEndDates"."fiscal_month")) INNER JOIN "SMG_APPS"."dbo"."tblMonitorsPerFM" "tblMonitorsPerFM" ON ((((("tblQAMonitorTrack"."FiscalYear"="tblMonitorsPerFM"."fiscalyear") AND ("tblQAMonitorTrack"."FW_Month"="tblMonitorsPerFM"."fiscal_month")) AND ("tblQAMonitorTrack"."CSR_ID"="tblMonitorsPerFM"."csrid")) AND ("tblQAMonitorTrack"."Sup_Id"="tblMonitorsPerFM"."supervisorid")) AND ("tblQAMonitorTrack"."Process_Order"="tblMonitorsPerFM"."Process_Order")) AND ("tblQAMonitorTrack"."Mgr_id"="tblMonitorsPerFM"."managerid")) LEFT OUTER JOIN "SMG_APPS"."dbo"."tblQAMonitorFWCalendar" "tblQAMonitorFWCalendar" ON "tblQAMonitorTrack"."FiscalWeek"="tblQAMonitorFWCalendar"."FiscalWeek") LEFT OUTER JOIN "SMG_APPS"."dbo"."tblQAMonitorFWCalendar" "tblQAMonitorFWCalendar_1" ON "tblFM_BeginEndDates"."fm_start_date"="tblQAMonitorFWCalendar_1"."FW_Start_Date") LEFT OUTER JOIN "SMG_APPS"."dbo"."tblQAMonitorFWCalendar" "tblQAMonitorFWCalendar_2" ON "tblFM_BeginEndDates"."fm_end_date"="tblQAMonitorFWCalendar_2"."FW_End_Date") INNER JOIN "SMG_APPS"."dbo"."tblDirectors" "tblDirectors" ON "tblManagers"."DirectorID"="tblDirectors"."DirectorID") LEFT OUTER JOIN "SMG_APPS"."dbo"."tblPosition" "tblPosition" ON "tblDirectors"."PositionID"="tblPosition"."PositionID"
    WHERE   NOT ("tblSupervisors"."SupervisorID"=0 OR "tblSupervisors"."SupervisorID"=17 OR "tblSupervisors"."SupervisorID"=19 OR "tblSupervisors"."SupervisorID"=20 OR "tblSupervisors"."SupervisorID"=33 OR "tblSupervisors"."SupervisorID"=35) AND ("tblFM_BeginEndDates"."fm_end_date">={ts '2010-11-27 00:00:00'} AND "tblFM_BeginEndDates"."fm_end_date"<{ts '2010-11-28 00:00:00'}) AND "tblQAMonitorTrack"."FiscalYear"="tblQAMonitorFWCalendar"."FiscalYear" AND "tblQAMonitorTrack"."FW_Month"="tblQAMonitorFWCalendar"."Fiscal_Month" AND "tblQAMonitorTrack"."FiscalWeek">="tblQAMonitorFWCalendar_1"."FiscalWeek" AND "tblQAMonitorTrack"."FiscalWeek"<="tblQAMonitorFWCalendar_2"."FiscalWeek" AND ("tblCSR"."Group_ID"=1 OR "tblCSR"."Group_ID"=10 OR "tblCSR"."Group_ID"=15)
    ORDER BY "tblSupervisors"."SupervisorID", "tblQAMonitorTrack"."CSR_ID"

    If the db is huge, you may want to copy it, and delete all but a few hundred rows.
    Then you can play with the copy till you get the query doing what you want.
    You might try changing this section
    "tblQAMonitorTrack"."CSR_ID"="tblCSR"."CSRID") INNER JOIN "SMG_APPS"."dbo"."tblFM_BeginEndDates" "tblFM_BeginEndDates" ON ("tblQAMonitorTrack"."FiscalYear"="tblFM_BeginEndDates"."fiscalyear") AND ("tblQAMonitorTrack"."FW_Month"="tblFM_BeginEndDates"."fiscal_month")) INNER JOIN "SMG_APPS"."dbo"."tblMonitorsPerFM" "tblMonitorsPerFM" ON
    To left outer joins.
    Also, just create a connection to the tblMonitorsPerFM all by itself, run a query and see if you get multiple results directly from the DB...

  • Update one to many relationship

    Since cfgridupdate is somewhat buggy, does anyone have a
    better suggestion to edit/update two tables with a one-to-many
    relationship? Any suggestions are welcome.

    cfquery

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

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

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

  • Merge Two Reports in Excel Analyzer - One To Many Relationship

    I want to show AR Data with CO Data - e.g. a bill + Income and it's associated account ssignemnt on the FI/CO side. I want the report to be able to show a cost centre manager to be wary of the income credited to their cost centre when a debtor has been raisedaas they may not fully pay the bill. To do this I'm using the standard DSO for AR & GL line items. Fisrtly I run a query on GL line item data where the user can select from a cost centre variable to look at credits to their cost centre. This produces a list of source documents that are used (via replacement path variable) in a second query. The second GL Query gives me a list of the allocation numbers for those line items. Had to be two queres as there are two GL postings that needed linking (this is because the cost assignment comes from a ceratin acc type and the debtor information comes from another acc type). I then use the allocation number (again via a replacement path variable) to run a third query on the AR data that shows all bills and payments linked to that allocation number. It seems to work ok.
    However I have put these three queries in an Excel Analyzer workbook. All the user does is enter a cost centre when running the report. Each query is on a different sheet but what I'd like to do is merge the data on to the one sheet. I want to see the bill and it's payments from the AR data matched up with the cost assignment from the FI/CO data. This would be a one to many relationship e.g. one bill may have it's cost assignment split over more than one cost centre. Is there anyway to do this using simple excel functionality?
    So I'd like to see:
    Allocation No. 12345 Bill £100 Revenue £50 Cost Centre 1234 £25
                                                                           Cost Centre 2345 £25
    Anybody any ideas?

    Hi,
    Thanks for your answers.
    I did explore using infosets but really struggled with joining the data and getting a sensible output. For example where a bill was done in installments I was getting 12 lines (e.g. one for each month) rather than just one. THis meant it looked liked they'd paid twleve times as much etc.
    I did also try report to report. Which to my mind worked ok. Except the customer wanted it all in "One" report rather than having to drill down to see data.
    I'll try a multiprovider but I'm worried that I'll end up with similar issues as I had when using the infoset.
    Cheers
    Joel

  • How to change the fetch size for a one-to-many relationship

    With Toplink 10.1.3, since using scrollablecursor is a prerequisites for changing the fetchsize on a query (using the setFetchSize), I am wondering if it would be possible to change the fetchsize of the query which is associated to a one-to-many relationship.
    So, is this possible? How ?

    In TopLink 10.1.3 you can set the fetch-size on any query, it has nothing to do with using a ScrollableCursor.
    Example:
    readQuery.setFetchSize(100);
    To set the fetch size on a mapping query use,
    mapping.getSelectionQuery().setFetchSize(100);
    In 10.1.3 you can only set this in code, not currently through XML or the Mapping Workbench. In 10.1.3.1 you should be able to set the value through XML as well.

  • 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

  • One to Many Relationship Issue

    Post Author: jmb1977
    CA Forum: Formula
    I am having a problem in which I have a one to many relationship with contact phone numbers and students. In other words, one student can have multiple contacts. (I work for a school district)
    I made up two formulas...called Contact1Phone and Contact2Phone.
    Here is the code I use to display the data:
    IF {STUDCTCT.CNTNUMBER} in &#91;"C1"&#93; THEN STDUCTCT.CNTWPHONE
    Then the other formula does the same, except uses "C2".
    What I get is either C1 or C2 displays, but never both for the same student. Anyway to make this work? Any help on this would be greatly appreciated!

    Post Author: jmb1977
    CA Forum: Formula
    I forgot to add, I do know that placing STUDCTCT.CNTNUMBER in &#91;C1,C2&#93; as a selection then just simply place the CNTWPHONE field into the details section of the report will give me the results. But the reason why I am trying it the other way is that I can export the data as one record per student, thus I am trying to put the fields and formulas into the group section.

  • One-to-many relationship within one bean

    hello all,
    Does S1 support a container managed one-to-many relationship to itself?
    I used the verifer to verify my DD and the error is reported. (this prototype is migrated from weblogic6.1 and I use the S1 migration tool for the DD generation)
    -----------------database schema-----------------
    CREATE TABLE t_class_a
    c_name VARCHAR2(255),
    one_class_a_for_ma2918_id VARCHAR2(32), /* untruncated name: one_class_a_for_many_class_a_id */
    object_id VARCHAR2(32) NOT NULL
    CREATE UNIQUE INDEX t_class_a_id_PK ON t_class_a ( object_id );
    ALTER TABLE t_class_a ADD ( CONSTRAINT t_class_a_id_PK PRIMARY KEY ( object_id ) USING INDEX );
    ALTER TABLE t_class_a ADD ( CONSTRAINT FK_0 FOREIGN KEY ( one_class_a_for_ma2918_id ) REFERENCES t_class_a ( object_id ) );
    ---------------------------ejb-jar.xml------------------
    <abstract-schema-name>ClassABean</abstract-schema-name>
    <cmp-field>
    <field-name>objectId</field-name></cmp-field>
    <cmp-field>
    <field-name>name</field-name></cmp-field>
    <primkey-field>objectId</primkey-field>
    <relationships>
    <ejb-relation>
    <ejb-relation-name>manyClassA_oneClassA</ejb-relation-name>
    <ejb-relationship-role>
    <description>optional</description>
    <ejb-relationship-role-name>OneClassA-in-manyClassA_oneClassA</ejb-relationship-role-name>
    <multiplicity>One</multiplicity>
    <relationship-role-source>
    <ejb-name>ClassAEJB</ejb-name></relationship-role-source>
    <cmr-field>
    <cmr-field-name>manyClassAsForOneClassA</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type></cmr-field></ejb-relationship-role>
    <ejb-relationship-role>
    <description>optional</description>
    <ejb-relationship-role-name>ManyClassA-in-manyClassA_oneClassA</ejb-relationship-role-name>
    <multiplicity>Many</multiplicity>
    <relationship-role-source>
    <ejb-name>ClassAEJB</ejb-name></relationship-role-source>
    <cmr-field>
    <cmr-field-name>oneClassAForManyClassA</cmr-field-name>
    </cmr-field>
    </ejb-relationship-role>
    </ejb-relation>
    </relationships>
    -----------sun-cmp-mapping.xml--------
    <sun-cmp-mapping>
    <schema>mySchema</schema>
    <entity-mapping>
    <ejb-name>ClassAEJB</ejb-name>
    <table-name>T_CLASS_A</table-name>
    <cmp-field-mapping>
    <field-name>objectId</field-name>
    <column-name>OBJECT_ID</column-name></cmp-field-mapping>
    <cmp-field-mapping>
    <field-name>name</field-name>
    <column-name>C_NAME</column-name></cmp-field-mapping>
    <cmr-field-mapping>
    <cmr-field-name>manyClassAsForOneClassA</cmr-field-name>
    <column-pair>
    <column-name>T_CLASS_A.OBJECT_ID</column-name>
    <column-name>T_CLASS_A.ONE_CLASS_A_FOR_MA2918_ID</column-name></column-pair></cmr-field-mapping></entity-mapping></sun-cmp-mapping></sun-cmp-mappings>
    I beleive the migration tool missing the cmr-filed mapping for the oneClassAForManyClassA relation role.
    but even if I add this mapping it still can't pass the verifiy.
    So do I miss any thing or I can conclude S1 not support this one-to many self relation?
    Any hint would be welcome.

    It does.
    There is a known problem with parsing self-referenced relationship info - the one side (with <multiplicity> Many) must be the first in the <ejb-relation> entry.
    Regards,
    Marina

  • One-to-many relationships problem

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

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

  • One to many 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.

  • One to many relationships

    Hi I have a big problem :)
    I want to use one to many relationships.
    One yable with primary key, foreign key view_id. The second table on the many side with primary key view_id and another primary key.
    The problem is that ejbc gives the followin error:
    " [java] In relationship 'ViewType-SView', role 'ViewType-Has-SView', a weblogic-relationship-role element contains the wrong number of column mappings. A single column mapping must be given for each primary key column in the bean referenced by the mapping."
    And that makes no sense for me. Any ideas?

    weblogic-relationship-role element column mappings should be the same as defined in
    <ejb-relationship-role>
    <multiplicity></multiplicity>
    </ejb-relationship-role>
    Erno wrote:
    Hi I have a big problem :)
    I want to use one to many relationships.
    One yable with primary key, foreign key view_id. The second table on the many side with primary key view_id and another primary key.
    The problem is that ejbc gives the followin error:
    " [java] In relationship 'ViewType-SView', role 'ViewType-Has-SView', a weblogic-relationship-role element contains the wrong number of column mappings. A single column mapping must be given for each primary key column in the bean referenced by the mapping."
    And that makes no sense for me. Any ideas?

Maybe you are looking for

  • Cannot view folders in mini bridge

    Hello, when trying to use mini bridge in ID CS6, I cannot view folders. I can look at drives, and places such as desk top, but it will only find individual image files, and cannot find any folders. As most of my assest are in folders, this is exceedi

  • Anyone having trouble with guide snapping in Illustrator CS5?

    I was trying to adjust some type and I was pulling guides to adjust widths etc but when I moved a guide to meet the black of the type it would snap a pixel to the left or right of where I was trying to put it.  I tried turning off Smart Guides and sn

  • How do I get my movies from my iTunes library on my old laptop to my new mac pro?

    How do I get my movies from my itune library on my old laptop to my new mac pro?

  • Creating Libraries

    I am trying to use Pro*C to create libraries of C functions that perform various SQL actions. These libraries must stand alone so that they can be used by programmers that do not have Oracle available to them, then the programs can later be tested on

  • Moving documents from Desktop to launchpad

    First time mac user. I created a folder on my desktop. I would like to move this file onto my launchpad to prevent clutter on my desktop. How do I do this? Any help with a simple solution is appreciated.