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

Similar Messages

  • Help needed on Many to Many Parent Child Relationship (PL/SQL)

    Friends,
    Please help me.
    I have table where in two columns are having many to many parent child relation ship. It means child can have multiple parents.
    Table strucuture and sample records given below. Here 334059 is GRAND PARENT of all child records.
    PARENT     CHILD     LEVEL     Usage
    334059     380499     1     This Level has 2 childs
    334059     334730     1     
    334730     335629     2     This level too has 2 childs where in 380499 is child of 334730 & 334059 also.
    334730     380499     2     
    380499     380497     2     This level has 3 childs and 88888 is having further child.
    380499     334730     2     
    380499     88888     2     
    88888     99999     3     It has one child 99999 and has further child 10101.
    99999     10101     4     It has one child 10101 and has further child 11111.
    10101     11111     5     It has one child 11111 and has no further child. I.e leaf node.
    11111     0     6     leaf node
    What I want is records in same level above. I am using below code but its implementing only UPTO 2nd LEVEL given above.
    Further its not going i.e 3,4,5,6 level. Could you please help me?
    DECLARE
    CURSOR main_pc(p_child pc.child%type) IS
    SELECT CHILD
    FROM pc where parent = p_child;
    CURSOR main_dw(p_child dw_exrdbo.exr_parent_child.child_fund%type,
    p_level NUMBER) IS
    SELECT DISTINCT CHILD_FUND,LEVEL_NUMBER FROM dw_exrdbo.exr_parent_child
    where parent_fund = p_child
    and parent_fund <> child_fund
    and level_number = p_level;
    v_next_parent pc.child%type;
    v_level NUMBER := 1;
    v_grand_parent dw_exrdbo.exr_parent_child.parent_fund%type := 334059;
    v_parent dw_exrdbo.exr_parent_child.parent_fund%type;
    vDone BOOLEAN;
    v_xyz dw_exrdbo.exr_parent_child.parent_fund%type;
    v_cnt NUMBER := 0;
    BEGIN
    DELETE FROM dw_exrdbo.exr_parent_child;
    COMMIT;
    INSERT INTO dw_exrdbo.exr_parent_child
    SELECT PARENT, CHILD, 'INVONE', 12345, 'P',0,1
    FROM pc where parent = v_grand_parent
    AND NOT EXISTS (select 'x' from dw_exrdbo.exr_parent_child where parent_fund = v_grand_parent);
    COMMIT;
    FOR i IN (select distinct child FROM pc WHERE parent = v_grand_parent) --334059
    LOOP
    DBMS_OUTPUT.PUT_LINE('Next Parent is '||v_parent);
    FOR x IN main_pc(i.child)
    LOOP
    INSERT INTO dw_exrdbo.exr_parent_child
    (parent_fund, child_fund, source_application, valuation_date_sid, parent_child_flag, child_count, level_number)
    VALUES(i.child, X.CHILD, 'INVONE', 12345, 'C',0,1+1);
    COMMIT;
    END LOOP;
    END LOOP;
    END;
    Thanks in advance!!!
    Regards,
    Jigger

    Hi, Jigger,
    Sorry, I can't tell what you want.
    Whenever you have a question, please post CREATE TABLE and INSERT statements for your sample data, and the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using.

  • One-to-Many:  New child not showing up when parent retrieved

    I have a one to many relationship. The parent contains a collection of children in a arraylist.
    A new child record is added independent of the parent, via a uow.
    The parent is retrieved.
    The new child doesn't show up.
    So the question is Does the parent first have to be retrieved and the child added to the parent. The child is not and should not be privately owned. The child is not dependent. If the parent goes away the child should still exist.

    "This last part" (as you describe it) is necessary. In a nutshell, you manage the object model (including both directions of a bi-directional relationship) and TopLink updates the database accordingly.
    This usually isn't a big issue. I.e., if you have a "addB(ClassB b)" method that looks like this, then you don't have to worry about managing the whole relationship all over the place:
    public void addB(ClassB b){
    bs.add(b);
    b.setA(this);
    At commit time the cache and database should be updated properly when you add a "b" to an "a".
    I have seen cases where the developer actually ended up not mapping the 1-M relationship in the model and had a "virtual" 1-M relationship. They would add a target to the "virtual" 1-M as you describe (just set the owner, i.e., tell the "b" it belongs to a particular "a". Then, they created a QueryKey in the Mapping Workbench in the Class "A" called "bs". Then they could build expressions and queries using "anyOf" through the "bs", even though it wasn't really mapped! I guess the point is that if you don't want to have to maintain that collection in code, and if it's not used in the application, then don't map it! Just create a QueryKey from A to B so that you can build the expressions as if it was there.
    - Don

  • Parent - Child mapping - ODI

    Hi experts,
    I have source as a below format, in .xls, this is parent- child relationship..
    Gen1     Gen2     Gen3     Gen4
    9000000009 blank     blank     blank
    blank     910000000 blank     blank
    blank     blank     9110000000     blank
    blank     blank     9120000009     blank
    blank     blank     blank     9121100009
    And trying the data into Oracle table with the below format.
    Gen1     Gen2     Gen3     Gen4
    9000000009               
    9000000009     9100000009          
    9000000009     9100000009     9110000000     
    9000000009     9100000009     9120000009     
    9000000009     9100000009     9120000009     9121100009
    Please help me what is the workaround I can follow to achieve using ODI.
    regards,
    Preet
    Edited by: 914626 on Mar 4, 2012 10:13 PM
    Edited by: 914626 on Mar 4, 2012 10:14 PM
    Edited by: 914626 on Mar 4, 2012 10:15 PM
    Edited by: 914626 on Mar 4, 2012 10:15 PM
    Edited by: 914626 on Mar 4, 2012 10:17 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

  • Informatica parent child mapping

      down votefavorite I have a scenario where suppose saycountry      province      city      zip
    ind           ts           hyd       xyz
    ind          maha          mum       abc
    Desired output:id   name         parent-id
    1    india         1
    2    telengana     1
    3    hyderabad     2
    4    xyz           3
    5    mumbai        1
    6    abc           5
    I have to do it with informatica mapping any ideas how do I show this parent child relationship. I am not able to get the logic for thisThanksKumar

    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

  • Need an approach regarding reporting for a one-to-many primary-child relationship, where there are more than three child objects for a primary object for reporting purpose

    Business Scenario- We have a parent organization with 6 different Business Units.One BU requires 9 stages for for Opportunity(Tender) Tracking.The client requirement is to show the basic details of the tender at the header level and to show details specific to individual sales stage as different tabs.There will be multiple opportunity members added as opportunity team and will be responsible for capturing details specific to individual sales stage(tab). The Tab should be enabled and disabled based on the role. Reporting is required against each stage with specific fields of child objects against each opportunity.
    We created multiple children entities under the oportunity(one to many mapping) but we are unable to add more than 3 child objects for a primary object for reporting purpose.
    Kindly suggest what needs to be done to meet the requirement

    Can you provide the exact steps you took to  "created multiple children entities under the oportunity" ?
    Jani Rautiainen
    Fusion Applications Developer Relations
    https://blogs.oracle.com/fadevrel/

  • Parent/child fonts problem

    Hi all
    I'm developing a program which has been writing out servicable PDF files for a few months, with embedded Truetype fonts; the files open without problem and display correctly. However, I am now trying to write out parent/child fonts (to allow character sets other than Latin) and I'm running into problems, even though I think I'm obeying the PDF spec.
    Specifically, when I open the PDF, my font is not used. In the Document properties, Fonts tab, only the parent font is displayed, and at the bottom of the dialog, the following appears: "Gathering font information... (0%)".
    Presumably, that means there is at least one mistake in my font declarations. The relevant sections from my PDF are as follows; I wonder if anyone can see anything obviously wrong? Note that there are many more figures in object 5's width collection, but I have removed them for the sake of brevity.
    4 0 obj
    <</Type/Font/Subtype/Type0/BaseFont/d+TraditionalArabicBold,Bold
    /Encoding/Identity-H/DescendantFonts [5 0 R ]>>
    endobj
    5 0 obj
    <</Type/Font/Subtype/CIDFontType2/BaseFont/d+TraditionalArabicBold,Bold/CIDSystemInfo<</Su pplement 0/Ordering(Identity)/Registry(Adobe)>>
    /FontDescriptor 6 0 R
    /Widths [244 244 244 244 244
    >>
    endobj
    6 0 obj
    <</Type/FontDescriptor/FontName/d+TraditionalArabicBold,Bold
    /FontFile2 7 0 R
    /Flags 32 /FontBBox [-120 -195 994 914] /MissingWidth 500 /StemV 120 /ItalicAngle 0 /CapHeight 1023 /XHeight 511 /Ascent 1023 /Descent -510 /MaxWidth 1063 /AvgWidth 482>>
    endobj
    Is there anything obviously wrong here?
    Thanks in advance for any help you can give.
    Rob

    Many thanks, Irosenth. I made the fixes you suggested, but still no luck (I still get 0% loading in the fonts tab). Looking at the preflight report on my new PDF, it lists "missing font" for each font I'm trying to embed (e.g. 'missing font "traditionalarabic"', so there's still something wrong in my PDF output.
    Here's a link to the latest version. If you have a chance to look at it, and have any suggestions, that would be great.
    https://docs.google.com/open?id=0B9qwyjaNkIuAQlFRcXg3VTBCM28

  • 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

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

  • Parent-Child Socket Problem

    I have two processes with a Parent-Child relationship.
    The child communicates to the parent over a socket.
    If I say "run" from my Eclipse IDE for each separately they work fine and the child can connect to the parent.
    However, if I have the parent start the child (Runtime.exec) the child always gets "Connection refused: connect" when it tries to connect to the parent.
    The parent is already initialized and has a thread doing an accept on the connection port.
    I'm running on Windows XP.
    Any idea why I get connection refused only when the parent starts the child?
    Thanks,
    -- Frank

    flawlor wrote:
    Thanks for the response.
    I took more care to make sure the parent listener thread was started and did a short sleep before starting the children, and now things seem OK.
    But interesting that you mentioned stdout/err from the child.
    I found that the child processes were all stalling at a certain point.
    When I had the parent read stdout, they progressed further.
    Apparently they are hanging on trying to write to stdout.
    I have them log what they need to and so don't really care about stdout.
    I tried adding > nul 2> nul to the end of the Runtime.exec command, but that didn't help.
    Any idea how to just discard the stdout/err from the children?You can redirect stderr to stdin if you use ProcessBuilder, you then have to create a thread that reads from stdin and throws the data away. (That's at least how you used to do it. I don't know if there is a better way now)
    Kaj

  • Context Problem when using Use One As Many

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

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

  • Unable to read one-to-many relations using Hibernate

    Hi,
    I am trying with a very simple one-to-many relationship. When I am storing the objects, there are no problems. But when I am trying to read out the collection, it says invalid descriptor index. Please help.
    Regards,
    Hibernate version:
    hibernate-3.1rc2
    Mapping documents:
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <hibernate-mapping>
         <class name="Parent">
              <id name="id">
                   <generator class="identity"/>
              </id>
              <set name="children">
                   <key column="parent_id"/>
                   <one-to-many class="Child"/>
              </set>
         </class>
         <class name="Child">
              <id name="id">
                   <generator class="identity"/>
              </id>
              <property name="name"/>
         </class>
    </hibernate-mapping>
    Code between sessionFactory.openSession() and session.close():
    The Parent class:
    public class Parent
         private Long id ;     
         private Set children;
         Parent(){}
         public Long getId()
              return id;
         public void setId(Long id)
              this.id=id;
         public Set getChildren()
              return children;
         public void setChildren(Set children)
              this.children=children;
    The Child class:
    public class Child
         private Long id;
         private String name;
         Child(){}
         public Long getId()
              return id;
         private void setId(Long id)
              this.id=id;
         public String getName()
              return name;
         public void setName(String name)
              this.name=name;
    The Main class:
    public class PCManager
         public static void main(String[] args)
              PCManager mgr = new PCManager();
              List lt = null;
              if (args[0].equals("store"))
                   mgr.createAndStoreParent(new HashSet(3));
              else if (args[0].equals("list"))
                   mgr.listEvents();
              HibernateUtil.getSessionFactory().close();
         private void createAndStoreParent(HashSet s)
              HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();
              Parent p1 = new Parent();
              int size = 3;
              for (int i=size; i>0; i--)
                   Child c = new Child();
                   c.setName("Child"+i);
                   s.add(c);
              p1.setChildren (s);
              Iterator elems = s.iterator();
              do {     
                   Child ch = (Child) elems.next();
                   HibernateUtil.getSessionFactory().getCurrentSession().save(ch);
              }while(elems.hasNext());
              HibernateUtil.getSessionFactory().getCurrentSession().save(p1);
              HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit();
         private void listEvents()
              HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();
              Parent result = (Parent) HibernateUtil.getSessionFactory().getCurrentSession().load(Parent.class, new Long(1));
              System.out.println("Id is :"+ result.getId());
              Set children = result.getChildren();
              Iterator elems = children.iterator();
              do {     
                   Child ch = (Child) elems.next();
                   System.out.println("Child Name"+ ch.getName());
              }while(elems.hasNext());
              HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit();          
    Full stack trace of any exception that occurs:
    When I run with "hbm2ddl.auto" property as validate and trying to list the contents, I get the following out put.
    C:\Documents and Settings\mirza\Desktop\hibernate-3.1rc2\MyHibernate>ant run -Da
    ction=list
    Buildfile: build.xml
    clean:
    [delete] Deleting directory C:\Documents and Settings\mirza\Desktop\hibernate
    -3.1rc2\MyHibernate\bin
    [mkdir] Created dir: C:\Documents and Settings\mirza\Desktop\hibernate-3.1rc
    2\MyHibernate\bin
    copy-resources:
    [copy] Copying 4 files to C:\Documents and Settings\mirza\Desktop\hibernate
    -3.1rc2\MyHibernate\bin
    compile:
    [javac] Compiling 5 source files to C:\Documents and Settings\mirza\Desktop\
    hibernate-3.1rc2\MyHibernate\bin
    run:
    [java] 09:09:23,433 INFO Environment:474 - Hibernate 3.1 rc2
    [java] 09:09:23,449 INFO Environment:489 - loaded properties from resource
    hibernate.properties: {hibernate.cglib.use_reflection_optimizer=true, hibernate
    .cache.provider_class=org.hibernate.cache.HashtableCacheProvider, hibernate.dial
    ect=org.hibernate.dialect.SQLServerDialect, hibernate.max_fetch_depth=1, hiberna
    te.jdbc.use_streams_for_binary=true, hibernate.format_sql=true, hibernate.query.
    substitutions=yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.cac
    he.region_prefix=hibernate.test, hibernate.jdbc.batch_versioned_data=true, hiber
    nate.connection.pool_size=1}
    [java] 09:09:23,465 INFO Environment:519 - using java.io streams to persis
    t binary types
    [java] 09:09:23,465 INFO Environment:520 - using CGLIB reflection optimize
    r
    [java] 09:09:23,481 INFO Environment:550 - using JDK 1.4 java.sql.Timestam
    p handling
    [java] 09:09:23,559 INFO Configuration:1257 - configuring from resource: /
    hibernate.cfg.xml
    [java] 09:09:23,559 INFO Configuration:1234 - Configuration resource: /hib
    ernate.cfg.xml
    [java] 09:09:23,872 INFO Configuration:460 - Reading mappings from resourc
    e: PCMapping.hbm.xml
    [java] 09:09:24,013 INFO HbmBinder:266 - Mapping class: Parent -> Parent
    [java] 09:09:24,045 INFO HbmBinder:266 - Mapping class: Child -> Child
    [java] 09:09:24,045 INFO Configuration:1368 - Configured SessionFactory: n
    ull
    [java] 09:09:24,061 INFO Configuration:1014 - processing extends queue
    [java] 09:09:24,061 INFO Configuration:1018 - processing collection mappin
    gs
    [java] 09:09:24,061 INFO HbmBinder:2233 - Mapping collection: Parent.child
    ren -> Child
    [java] 09:09:24,076 INFO Configuration:1027 - processing association prope
    rty references
    [java] 09:09:24,076 INFO Configuration:1049 - processing foreign key const
    raints
    [java] 09:09:24,155 INFO DriverManagerConnectionProvider:41 - Using Hibern
    ate built-in connection pool (not for production use!)
    [java] 09:09:24,170 INFO DriverManagerConnectionProvider:42 - Hibernate co
    nnection pool size: 1
    [java] 09:09:24,170 INFO DriverManagerConnectionProvider:45 - autocommit m
    ode: false
    [java] 09:09:24,170 INFO DriverManagerConnectionProvider:80 - using driver
    : sun.jdbc.odbc.JdbcOdbcDriver at URL: jdbc:odbc:MySQL
    [java] 09:09:24,170 INFO DriverManagerConnectionProvider:86 - connection p
    roperties: {}
    [java] 09:09:24,264 INFO SettingsFactory:77 - RDBMS: Microsoft SQL Server,
    version: 08.00.0194
    [java] 09:09:24,264 INFO SettingsFactory:78 - JDBC driver: JDBC-ODBC Bridg
    e (SQLSRV32.DLL), version: 2.0001 (03.85.1117)
    [java] 09:09:24,296 INFO Dialect:100 - Using dialect: org.hibernate.dialec
    t.SQLServerDialect
    [java] 09:09:24,311 INFO TransactionFactoryFactory:31 - Using default tran
    saction strategy (direct JDBC transactions)
    [java] 09:09:24,327 INFO TransactionManagerLookupFactory:33 - No Transacti
    onManagerLookup configured (in JTA environment, use of read-write or transaction
    al second-level cache is not recommended)
    [java] 09:09:24,327 INFO SettingsFactory:125 - Automatic flush during befo
    reCompletion(): disabled
    [java] 09:09:24,327 INFO SettingsFactory:129 - Automatic session close at
    end of transaction: disabled
    [java] 09:09:24,343 INFO SettingsFactory:144 - Scrollable result sets: ena
    bled
    [java] 09:09:24,343 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): d
    isabled
    [java] 09:09:24,343 INFO SettingsFactory:160 - Connection release mode: au
    to
    [java] 09:09:24,358 INFO SettingsFactory:184 - Maximum outer join fetch de
    pth: 1
    [java] 09:09:24,358 INFO SettingsFactory:187 - Default batch fetch size: 1
    [java] 09:09:24,358 INFO SettingsFactory:191 - Generate SQL with comments:
    disabled
    [java] 09:09:24,358 INFO SettingsFactory:195 - Order SQL updates by primar
    y key: disabled
    [java] 09:09:24,358 INFO SettingsFactory:338 - Query translator: org.hiber
    nate.hql.ast.ASTQueryTranslatorFactory
    [java] 09:09:24,374 INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTran
    slatorFactory
    [java] 09:09:24,374 INFO SettingsFactory:203 - Query language substitution
    s: {no='N', yes='Y'}
    [java] 09:09:24,374 INFO SettingsFactory:209 - Second-level cache: enabled
    [java] 09:09:24,374 INFO SettingsFactory:213 - Query cache: disabled
    [java] 09:09:24,374 INFO SettingsFactory:325 - Cache provider: org.hiberna
    te.cache.HashtableCacheProvider
    [java] 09:09:24,374 INFO SettingsFactory:228 - Optimize cache for minimal
    puts: disabled
    [java] 09:09:24,374 INFO SettingsFactory:233 - Cache region prefix: hibern
    ate.test
    [java] 09:09:24,405 INFO SettingsFactory:237 - Structured second-level cac
    he entries: disabled
    [java] 09:09:24,437 INFO SettingsFactory:257 - Echoing all SQL to stdout
    [java] 09:09:24,452 INFO SettingsFactory:264 - Statistics: disabled
    [java] 09:09:24,452 INFO SettingsFactory:268 - Deleted entity synthetic id
    entifier rollback: disabled
    [java] 09:09:24,452 INFO SettingsFactory:283 - Default entity-mode: POJO
    [java] 09:09:24,593 INFO SessionFactoryImpl:155 - building session factory
    [java] 09:09:24,938 INFO SessionFactoryObjectFactory:82 - Not binding fact
    ory to JNDI, no JNDI name configured
    [java] 09:09:24,954 INFO SchemaValidator:99 - Running schema validator
    [java] 09:09:24,954 INFO SchemaValidator:107 - fetching database metadata
    [java] 09:09:24,954 INFO Configuration:1014 - processing extends queue
    [java] 09:09:24,954 INFO Configuration:1018 - processing collection mappin
    gs
    [java] 09:09:24,954 INFO Configuration:1027 - processing association prope
    rty references
    [java] 09:09:24,954 INFO Configuration:1049 - processing foreign key const
    raints
    [java] 09:09:24,985 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState
    : S1002
    [java] 09:09:24,985 ERROR JDBCExceptionReporter:72 - [Microsoft][ODBC SQL S
    erver Driver]Invalid Descriptor Index
    [java] 09:09:25,001 ERROR SchemaValidator:129 - Error closing connection
    [java] java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Invalid transaction state
    [java] Initial SessionFactory creation failed.org.hibernate.exception.Gener
    icJDBCException: could not get table metadata: Child
    [java] java.lang.ExceptionInInitializerError
    [java] at HibernateUtil.<clinit>(Unknown Source)
    [java] at PCManager.listEvents(Unknown Source)
    [java] at PCManager.main(Unknown Source)
    [java] Caused by: org.hibernate.exception.GenericJDBCException: could not g
    et table metadata: Child
    [java] at org.hibernate.exception.SQLStateConverter.handledNonSpecificE
    xception(SQLStateConverter.java:91)
    [java] at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
    [java] at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
    [java] at sun.jdbc.odbc.JdbcOdbc.SQLDisconnect(JdbcOdbc.java:2988)
    [java] at sun.jdbc.odbc.JdbcOdbcDriver.disconnect(JdbcOdbcDriver.java:9
    80)
    [java] at sun.jdbc.odbc.JdbcOdbcConnection.close(JdbcOdbcConnection.jav
    a:739)
    [java] at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaVal
    idator.java:125)
    [java] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryIm
    pl.java:299)
    [java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configura
    tion.java:1145)
    [java] at HibernateUtil.<clinit>(Unknown Source)
    [java] at org.hibernate.exception.SQLStateConverter.convert(SQLStateCon
    verter.java:79)
    [java] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExcep
    tionHelper.java:43)
    [java] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExcep
    tionHelper.java:29)
    [java] at org.hibernate.tool.hbm2ddl.DatabaseMetadata.getTableMetadata(
    DatabaseMetadata.java:100)
    [java] at org.hibernate.cfg.Configuration.validateSchema(Configuration.
    java:946)
    [java] at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaVal
    idator.java:116)
    [java] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryIm
    pl.java:299)
    [java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configura
    tion.java:1145)
    [java] ... 3 more
    [java] Caused by: java.sql.SQLException: [Microsoft][ODBC SQL Server Driver
    ]Invalid Descriptor Index
    [java] at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
    [java] at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
    [java] at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3862)
    [java] at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultS
    et.java:5561)
    [java] at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.j
    ava:338)
    [java] at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.j
    ava:395)
    [java] at PCManager.listEvents(Unknown Source)
    [java] at PCManager.main(Unknown Source)
    [java] at org.hibernate.tool.hbm2ddl.TableMetadata.<init>(TableMetadata
    .java:30)
    [java] at org.hibernate.tool.hbm2ddl.DatabaseMetadata.getTableMetadata(
    DatabaseMetadata.java:85)
    [java] ... 7 more
    [java] Exception in thread "main"
    [java] Java Result: 1
    BUILD SUCCESSFUL
    Total time: 4 seconds
    Name and version of the database you are using:
    Microsoft SQLServer2000
    The generated SQL (show_sql=true):
    When the program is run with "hbm2ddl.auto" property as create, I get the following output.
    C:\Documents and Settings\mirza\Desktop\hibernate-3.1rc2\MyHibernate>ant run -Daction=store
    Buildfile: build.xml
    clean:
    [delete] Deleting directory C:\Documents and Settings\mirza\Desktop\hibernate
    -3.1rc2\MyHibernate\bin
    [mkdir] Created dir: C:\Documents and Settings\mirza\Desktop\hibernate-3.1rc
    2\MyHibernate\bin
    copy-resources:
    [copy] Copying 4 files to C:\Documents and Settings\mirza\Desktop\hibernate
    -3.1rc2\MyHibernate\bin
    compile:
    [javac] Compiling 5 source files to C:\Documents and Settings\mirza\Desktop\
    hibernate-3.1rc2\MyHibernate\bin
    run:
    [java] 09:12:54,820 INFO Environment:474 - Hibernate 3.1 rc2
    [java] 09:12:54,836 INFO Environment:489 - loaded properties from resource
    hibernate.properties: {hibernate.cglib.use_reflection_optimizer=true, hibernate
    .cache.provider_class=org.hibernate.cache.HashtableCacheProvider, hibernate.dial
    ect=org.hibernate.dialect.SQLServerDialect, hibernate.max_fetch_depth=1, hiberna
    te.jdbc.use_streams_for_binary=true, hibernate.format_sql=true, hibernate.query.
    substitutions=yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.cac
    he.region_prefix=hibernate.test, hibernate.jdbc.batch_versioned_data=true, hiber
    nate.connection.pool_size=1}
    [java] 09:12:54,852 INFO Environment:519 - using java.io streams to persis
    t binary types
    [java] 09:12:54,852 INFO Environment:520 - using CGLIB reflection optimize
    r
    [java] 09:12:54,867 INFO Environment:550 - using JDK 1.4 java.sql.Timestam
    p handling
    [java] 09:12:54,946 INFO Configuration:1257 - configuring from resource: /
    hibernate.cfg.xml
    [java] 09:12:54,946 INFO Configuration:1234 - Configuration resource: /hib
    ernate.cfg.xml
    [java] 09:12:55,259 INFO Configuration:460 - Reading mappings from resourc
    e: PCMapping.hbm.xml
    [java] 09:12:55,400 INFO HbmBinder:266 - Mapping class: Parent -> Parent
    [java] 09:12:55,447 INFO HbmBinder:266 - Mapping class: Child -> Child
    [java] 09:12:55,447 INFO Configuration:1368 - Configured SessionFactory: n
    ull
    [java] 09:12:55,447 INFO Configuration:1014 - processing extends queue
    [java] 09:12:55,447 INFO Configuration:1018 - processing collection mappin
    gs
    [java] 09:12:55,447 INFO HbmBinder:2233 - Mapping collection: Parent.child
    ren -> Child
    [java] 09:12:55,463 INFO Configuration:1027 - processing association prope
    rty references
    [java] 09:12:55,479 INFO Configuration:1049 - processing foreign key const
    raints
    [java] 09:12:55,557 INFO DriverManagerConnectionProvider:41 - Using Hibern
    ate built-in connection pool (not for production use!)
    [java] 09:12:55,557 INFO DriverManagerConnectionProvider:42 - Hibernate co
    nnection pool size: 1
    [java] 09:12:55,557 INFO DriverManagerConnectionProvider:45 - autocommit m
    ode: false
    [java] 09:12:55,573 INFO DriverManagerConnectionProvider:80 - using driver
    : sun.jdbc.odbc.JdbcOdbcDriver at URL: jdbc:odbc:MySQL
    [java] 09:12:55,573 INFO DriverManagerConnectionProvider:86 - connection p
    roperties: {}
    [java] 09:12:55,651 INFO SettingsFactory:77 - RDBMS: Microsoft SQL Server,
    version: 08.00.0194
    [java] 09:12:55,667 INFO SettingsFactory:78 - JDBC driver: JDBC-ODBC Bridg
    e (SQLSRV32.DLL), version: 2.0001 (03.85.1117)
    [java] 09:12:55,682 INFO Dialect:100 - Using dialect: org.hibernate.dialec
    t.SQLServerDialect
    [java] 09:12:55,698 INFO TransactionFactoryFactory:31 - Using default tran
    saction strategy (direct JDBC transactions)
    [java] 09:12:55,714 INFO TransactionManagerLookupFactory:33 - No Transacti
    onManagerLookup configured (in JTA environment, use of read-write or transaction
    al second-level cache is not recommended)
    [java] 09:12:55,714 INFO SettingsFactory:125 - Automatic flush during befo
    reCompletion(): disabled
    [java] 09:12:55,714 INFO SettingsFactory:129 - Automatic session close at
    end of transaction: disabled
    [java] 09:12:55,729 INFO SettingsFactory:144 - Scrollable result sets: ena
    bled
    [java] 09:12:55,729 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): d
    isabled
    [java] 09:12:55,745 INFO SettingsFactory:160 - Connection release mode: au
    to
    [java] 09:12:55,745 INFO SettingsFactory:184 - Maximum outer join fetch de
    pth: 1
    [java] 09:12:55,745 INFO SettingsFactory:187 - Default batch fetch size: 1
    [java] 09:12:55,745 INFO SettingsFactory:191 - Generate SQL with comments:
    disabled
    [java] 09:12:55,745 INFO SettingsFactory:195 - Order SQL updates by primar
    y key: disabled
    [java] 09:12:55,745 INFO SettingsFactory:338 - Query translator: org.hiber
    nate.hql.ast.ASTQueryTranslatorFactory
    [java] 09:12:55,777 INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTran
    slatorFactory
    [java] 09:12:55,792 INFO SettingsFactory:203 - Query language substitution
    s: {no='N', yes='Y'}
    [java] 09:12:55,792 INFO SettingsFactory:209 - Second-level cache: enabled
    [java] 09:12:55,792 INFO SettingsFactory:213 - Query cache: disabled
    [java] 09:12:55,792 INFO SettingsFactory:325 - Cache provider: org.hiberna
    te.cache.HashtableCacheProvider
    [java] 09:12:55,808 INFO SettingsFactory:228 - Optimize cache for minimal
    puts: disabled
    [java] 09:12:55,808 INFO SettingsFactory:233 - Cache region prefix: hibern
    ate.test
    [java] 09:12:55,808 INFO SettingsFactory:237 - Structured second-level cac
    he entries: disabled
    [java] 09:12:55,839 INFO SettingsFactory:257 - Echoing all SQL to stdout
    [java] 09:12:55,839 INFO SettingsFactory:264 - Statistics: disabled
    [java] 09:12:55,839 INFO SettingsFactory:268 - Deleted entity synthetic id
    entifier rollback: disabled
    [java] 09:12:55,839 INFO SettingsFactory:283 - Default entity-mode: POJO
    [java] 09:12:55,980 INFO SessionFactoryImpl:155 - building session factory
    [java] 09:12:56,325 INFO SessionFactoryObjectFactory:82 - Not binding fact
    ory to JNDI, no JNDI name configured
    [java] 09:12:56,341 INFO Configuration:1014 - processing extends queue
    [java] 09:12:56,341 INFO Configuration:1018 - processing collection mappin
    gs
    [java] 09:12:56,341 INFO Configuration:1027 - processing association prope
    rty references
    [java] 09:12:56,341 INFO Configuration:1049 - processing foreign key const
    raints
    [java] 09:12:56,356 INFO Configuration:1014 - processing extends queue
    [java] 09:12:56,356 INFO Configuration:1018 - processing collection mappin
    gs
    [java] 09:12:56,356 INFO Configuration:1027 - processing association prope
    rty references
    [java] 09:12:56,372 INFO Configuration:1049 - processing foreign key const
    raints
    [java] 09:12:56,372 INFO SchemaExport:153 - Running hbm2ddl schema export
    [java] 09:12:56,388 DEBUG SchemaExport:171 - import file not found: /import
    .sql
    [java] 09:12:56,388 INFO SchemaExport:180 - exporting generated schema to
    database
    [java] 09:12:56,403 DEBUG SchemaExport:283 -
    [java] alter table Child
    [java] drop constraint FK3E104FC976A59A
    [java] 09:12:56,466 DEBUG SchemaExport:283 -
    [java] drop table Child
    [java] 09:12:56,544 DEBUG SchemaExport:283 -
    [java] drop table Parent
    [java] 09:12:56,654 DEBUG SchemaExport:283 -
    [java] create table Child (
    [java] id numeric(19,0) identity not null,
    [java] name varchar(255) null,
    [java] parent_id numeric(19,0) null,
    [java] primary key (id)
    [java] )
    [java] 09:12:56,779 DEBUG SchemaExport:283 -
    [java] create table Parent (
    [java] id numeric(19,0) identity not null,
    [java] primary key (id)
    [java] )
    [java] 09:12:56,873 DEBUG SchemaExport:283 -
    [java] alter table Child
    [java] add constraint FK3E104FC976A59A
    [java] foreign key (parent_id)
    [java] references Parent
    [java] 09:12:56,952 INFO SchemaExport:200 - schema export complete
    [java] 09:12:56,952 WARN JDBCExceptionReporter:48 - SQL Warning: 5701, SQL
    State: 01000
    [java] 09:12:56,952 WARN JDBCExceptionReporter:49 - [Microsoft][ODBC SQL S
    erver Driver][SQL Server]Changed database context to 'master'.
    [java] 09:12:56,952 WARN JDBCExceptionReporter:48 - SQL Warning: 5703, SQL
    State: 01000
    [java] 09:12:56,952 WARN JDBCExceptionReporter:49 - [Microsoft][ODBC SQL S
    erver Driver][SQL Server]Changed language setting to us_english.
    [java] 09:12:56,983 INFO SessionFactoryImpl:432 - Checking 0 named queries
    [java] Hibernate:
    [java] insert
    [java] into
    [java] Child
    [java] (name)
    [java] values
    [java] (?) select
    [java] scope_identity()
    [java] Hibernate:
    [java] insert
    [java] into
    [java] Child
    [java] (name)
    [java] values
    [java] (?) select
    [java] scope_identity()
    [java] Hibernate:
    [java] insert
    [java] into
    [java] Child
    [java] (name)
    [java] values
    [java] (?) select
    [java] scope_identity()
    [java] Hibernate:
    [java] insert
    [java] into
    [java] Parent
    [java] default
    [java] values
    [java] select
    [java] scope_identity()
    [java] Hibernate:
    [java] update
    [java] Child
    [java] set
    [java] parent_id=?
    [java] where
    [java] id=?
    [java] Hibernate:
    [java] update
    [java] Child
    [java] set
    [java] parent_id=?
    [java] where
    [java] id=?
    [java] Hibernate:
    [java] update
    [java] Child
    [java] set
    [java] parent_id=?
    [java] where
    [java] id=?
    [java] 09:12:57,390 INFO SessionFactoryImpl:831 - closing
    [java] 09:12:57,390 INFO DriverManagerConnectionProvider:147 - cleaning up
    connection pool: jdbc:odbc:MySQL
    BUILD SUCCESSFUL
    Total time: 5 seconds
    Debug level Hibernate log excerpt:
    Included in the above description.

    That's not the right mapping for the 1:m relationship in Hibernate.
    First of all, I believe the recommendation is to have a separate .hbm.xml file for each class, so you should have one for Parent and Child.
    Second, you'll find the proper syntax for a one-to-many relationship here:
    http://www.hibernate.org/hib_docs/v3/reference/en/html/tutorial.html#tutorial-associations
    See if those help.
    The tutorial docs for Hibernate are quite good. I'd recommend going through them carefully.
    %

  • I have had TOPLINK-28018  error afte I had added one-to-many or many-to-one

    Hello.
    I am using TopLink and Spring. I have the followng persistence.xml:
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    version="1.0">
    <persistence-unit name="registry" transaction-type="RESOURCE_LOCAL">
    <mapping-file>ru/lanit/ps/registry/model/rpaymenttype.xml</mapping-file>
    <mapping-file>ru/lanit/ps/registry/model/radministrativelevel.xml</mapping-file>
    <mapping-file>ru/lanit/ps/registry/model/rterritory.xml</mapping-file>
    <mapping-file>ru/lanit/ps/registry/model/stateowner.xml</mapping-file>
    <properties>
    <property name="com.intellij.javaee.persistence.datasource" value="Datasource"/>
    <property name="toplink.logging.level" value="FINE"/>
    <property name="toplink.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
    <property name="toplink.jdbc.url" value="jdbc:hsqldb:mem:PUBSER"/>
    <property name="toplink.jdbc.password" value=""/>
    <property name="toplink.jdbc.user" value="sa"/>
    </properties>
    </persistence-unit>
    </persistence>
    All my classes are inherited from StateOwner.class and only the RTerritory class has "one-to-many" and "many-to-one" relationships. When I add rterritory.xml to persistence.xml I have the following error (before all works fine):
    log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
    log4j:WARN Please initialize the log4j system properly.
    [TopLink Config]: 2007.12.18 02:47:15.812--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.lang.Long ru.lanit.ps.registry.model.StateOwner.getId()] is being defaulted to: ID.
    [TopLink Config]: 2007.12.18 02:47:15.859--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.lang.Long ru.lanit.ps.registry.model.StateOwner.getStateTerritoryId()] is being defaulted to: STATETERRITORYID.
    [TopLink Config]: 2007.12.18 02:47:15.875--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.lang.String ru.lanit.ps.registry.model.StateOwner.getStringId()] is being defaulted to: STRINGID.
    [TopLink Config]: 2007.12.18 02:47:15.875--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.lang.String ru.lanit.ps.registry.model.StateOwner.getStateStatus()] is being defaulted to: STATESTATUS.
    [TopLink Config]: 2007.12.18 02:47:15.875--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.lang.Long ru.lanit.ps.registry.model.StateOwner.getStateVersion()] is being defaulted to: STATEVERSION.
    [TopLink Config]: 2007.12.18 02:47:15.890--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.lang.String ru.lanit.ps.registry.model.StateOwner.getStateAuthor()] is being defaulted to: STATEAUTHOR.
    [TopLink Config]: 2007.12.18 02:47:15.890--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.sql.Timestamp ru.lanit.ps.registry.model.StateOwner.getStateCreationDate()] is being defaulted to: STATECREATIONDATE.
    [TopLink Config]: 2007.12.18 02:47:15.890--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.sql.Timestamp ru.lanit.ps.registry.model.StateOwner.getStateModificationDate()] is being defaulted to: STATEMODIFICATIONDATE.
    [TopLink Config]: 2007.12.18 02:47:15.890--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.lang.String ru.lanit.ps.registry.model.StateOwner.getStateComment()] is being defaulted to: STATECOMMENT.
    [TopLink Config]: 2007.12.18 02:47:15.906--ServerSession(25709120)--Thread(Thread[main,5,main])--The column name for element [public java.sql.Timestamp ru.lanit.ps.registry.model.StateOwner.getStateProcessedDate()] is being defaulted to: STATEPROCESSEDDATE.
    [TopLink Config]: 2007.12.18 02:47:15.906--ServerSession(25709120)--Thread(Thread[main,5,main])--The discriminator column name for the root inheritance class [class ru.lanit.ps.registry.model.StateOwner] is being defaulted to: DTYPE.
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'GroundOfRefusalServiceTarget' defined in class path resource [groundofrefusal.xml]: Cannot resolve reference to bean 'GroundOfRefusalDao' while setting bean property 'dao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'GroundOfRefusalDao' defined in class path resource [groundofrefusal.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [openJPAsettings.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: predeploy for PersistenceUnit [registry] failed.
    Internal Exception: java.lang.NullPointerException
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'GroundOfRefusalDao' defined in class path resource [groundofrefusal.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [openJPAsettings.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: predeploy for PersistenceUnit [registry] failed.
    Internal Exception: java.lang.NullPointerException
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [openJPAsettings.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: predeploy for PersistenceUnit [registry] failed.
    Internal Exception: java.lang.NullPointerException
    Caused by: javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: predeploy for PersistenceUnit [registry] failed.
    Internal Exception: java.lang.NullPointerException
         at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:615)
         at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createContainerEntityManagerFactory(EntityManagerFactoryProvider.java:178)
         at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:218)
         at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:251)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1099)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:861)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1099)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:861)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
         at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
         at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91)
         at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)
         at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
         at ru.lanit.ps.registry.VerifyApplicationContext.setUp(VerifyApplicationContext.java:44)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
         at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
         at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
         at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
         at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
         at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
         at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
         at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
         at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
         at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
         at com.intellij.rt.junit4.Junit4ClassSuite.run(Junit4ClassSuite.java:78)
         at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
    Caused by: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: predeploy for PersistenceUnit [registry] failed.
    Internal Exception: java.lang.NullPointerException
         at oracle.toplink.essentials.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:212)
         ... 61 more
    Caused by: java.lang.NullPointerException
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.OneToManyAccessor.process(OneToManyAccessor.java:142)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.RelationshipAccessor.processRelationship(RelationshipAccessor.java:275)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.processRelationshipDescriptors(MetadataProject.java:564)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.process(MetadataProject.java:497)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.processAnnotations(MetadataProcessor.java:231)
         at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:354)
         at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:584)
         ... 60 more
    Process finished with exit code -1
    This is my RTerritory.class and rterritory.xml
    public class RTerritory extends StateOwner {
    private static final long serialVersionUID = 5372570539234097349L;
    //link to parent
    private RTerritory parentTerritory;
    //title
    private String title;
    //string type
    private String type;
    //Level
    private Integer level;
    //set of children
    private Set<RTerritory> children = new HashSet<RTerritory>(0);
    public RTerritory() {
    public RTerritory(Long RTerritory, String title, String type) {
    setId(RTerritory);
    this.title = title;
    this.type = type;
    public RTerritory(Long id, RTerritory parentTerritory, String title, String type, Integer level) {
    super(id);
    this.parentTerritory = parentTerritory;
    this.title = title;
    this.type = type;
    this.level = level;
    public RTerritory(Long RTerritory, RTerritory parentTerritory, String title,
    String type, Set<RTerritory> RTerritories) {
    setId(RTerritory);
    this.parentTerritory = parentTerritory;
    this.title = title;
    this.type = type;
    this.children = RTerritories;
    public RTerritory(Long id, RTerritory parentTerritory, String title, String type, Integer level, Set<RTerritory> children) {
    super(id);
    this.parentTerritory = parentTerritory;
    this.title = title;
    this.type = type;
    this.level = level;
    this.children = children;
    public Integer getLevel() {
    return level;
    public void setLevel(Integer level) {
    this.level = level;
    public RTerritory getParentTerritory() {
    return this.parentTerritory;
    public void setParentTerritory(RTerritory parent_Territory) {
    this.parentTerritory = parent_Territory;
    public boolean hasParentTerritory() {
         return getParentTerritory() != null;
    public String getTitle() {
    return this.title;
    public void setTitle(String title) {
    this.title = title;
    public String getType() {
    return this.type;
    public void setType(String type) {
    this.type = type;
    public Set<RTerritory> getChildren() {
    return this.children;
    public void setChildren(Set<RTerritory> children) {
    this.children = children;
    public void addChildTerritory(RTerritory territory) throws Exception {
    if (children != null && territory != null) {
    children.add(territory);
    territory.setParentTerritory(this);
    } else {
    throw new Exception("Parameter is null or children is null");// TODO throw exception ?
    public void removeChildTerritory(RTerritory territory) {
    if (children != null && territory != null) {
    children.remove(territory);
    territory.setParentTerritory(null); // TODO territory.setParentTerritory(this.getParentTerritory()) ?
    public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    if (!super.equals(o)) return false;
    RTerritory that = (RTerritory) o;
    if (level != null ? !level.equals(that.level) : that.level != null) return false;
    if (title != null ? !title.equals(that.title) : that.title != null) return false;
    if (type != null ? !type.equals(that.type) : that.type != null) return false;
    return true;
    public int hashCode() {
    int result = super.hashCode();
    result = 31 * result + (title != null ? title.hashCode() : 0);
    result = 31 * result + (type != null ? type.hashCode() : 0);
    result = 31 * result + (level != null ? level.hashCode() : 0);
    return result;
         @Override
         public boolean isReference() {
              return true;
    <?xml version="1.0" encoding="UTF-8"?>
    <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
    version="1.0">
    <package>ru.lanit.ps.registry.model</package>
    <entity class="RTerritory" name="RTerritory">
    <table name="reg_r_territory"/>
    <primary-key-join-column name="R_TERRITORY" referenced-column-name="STATUS_ID"/>
    <attribute-override name="id">
    <column name="R_TERRITORY"/>
    </attribute-override>
    <attributes>
    <basic name="title">
    <column length="256" name="TITLE" nullable="false"/>
    </basic>
    <basic name="type">
    <column length="256" name="TYPE" nullable="false"/>
    </basic>
    <basic name="level">
    <column name="LEVEL"/>
    </basic>
    <!--<many-to-one name="parentTerritory" target-entity="RTerritory">
    <join-column name="PARENT_TERRITORY_ID"/>
    <cascade>
    <cascade-persist/>
    <cascade-merge/>
    <cascade-refresh/>
    </cascade>
    </many-to-one>-->
    <one-to-many name="children" mapped-by="parentTerritory" target-entity="RTerritory">
    <cascade>
    <cascade-all/>
    </cascade>
    </one-to-many>
    <transient name="parentTerritory"/>
    <!--<transient name="children"/>-->
    </attributes>
    </entity>
    </entity-mappings>
    If I make "parentTerritory" and "children" transient - all works well. Above workes also (comment out and without transient) on OpenJpa.
    What do I do wrong if I use TopLink?
    This is part of my applicationContext.xml
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceXmlLocation"
    value="/META-INF/persistence.xml"/>
    <property name="jpaVendorAdapter">
    <bean class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter"/>
    </property>
    <property name="loadTimeWeaver">
    <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
    </property>
    </bean
    Thanks a lot.

    Hello.
    Thanks a lot for answer.
    When I comment out and remove transient I obtain the following exception:
    Internal Exception: java.util.NoSuchElementException
         at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:615)
         at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createContainerEntityManagerFactory(EntityManagerFactoryProvider.java:178)
         at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:218)
         at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:251)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1099)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:861)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1099)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:861)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
         at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
         at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91)
         at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)
         at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
         at ru.lanit.ps.registry.VerifyApplicationContext.setUp(VerifyApplicationContext.java:44)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
         at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
         at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
         at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
         at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
         at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
         at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
         at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
         at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
         at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
         at com.intellij.rt.junit4.Junit4ClassSuite.run(Junit4ClassSuite.java:78)
         at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
    Caused by: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: predeploy for PersistenceUnit [registry] failed.
    Internal Exception: java.util.NoSuchElementException
         at oracle.toplink.essentials.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:212)
         ... 61 more
    Caused by: java.util.NoSuchElementException
         at java.util.AbstractList$Itr.next(AbstractList.java:427)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataDescriptor.getPrimaryKeyFieldName(MetadataDescriptor.java:539)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ObjectAccessor.processOneToOneForeignKeyRelationship(ObjectAccessor.java:113)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ObjectAccessor.processOwningMappingKeys(ObjectAccessor.java:190)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ManyToOneAccessor.process(ManyToOneAccessor.java:106)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.RelationshipAccessor.processRelationship(RelationshipAccessor.java:275)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataDescriptor.getMappingForAttributeName(MetadataDescriptor.java:486)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.RelationshipAccessor.getOwningMapping(RelationshipAccessor.java:122)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.OneToManyAccessor.process(OneToManyAccessor.java:142)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.RelationshipAccessor.processRelationship(RelationshipAccessor.java:275)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.processRelationshipDescriptors(MetadataProject.java:564)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.process(MetadataProject.java:497)
         at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.processAnnotations(MetadataProcessor.java:231)
         at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:354)
         at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:584)
         ... 60 more
    Process finished with exit code -1
    I want to say that exception is same and I don't use GlassFish I run Unit test.
    This is my rterritory.xml now:
    <?xml version="1.0" encoding="UTF-8"?>
    <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
    version="1.0">
    <package>ru.lanit.ps.registry.model</package>
    <entity class="RTerritory" name="RTerritory">
    <table name="reg_r_territory"/>
    <primary-key-join-column name="R_TERRITORY" referenced-column-name="STATUS_ID"/>
    <attribute-override name="id">
    <column name="R_TERRITORY"/>
    </attribute-override>
    <attributes>
    <basic name="title">
    <column length="256" name="TITLE" nullable="false"/>
    </basic>
    <basic name="type">
    <column length="256" name="TYPE" nullable="false"/>
    </basic>
    <basic name="level">
    <column name="LEVEL"/>
    </basic>
    <many-to-one name="parentTerritory" target-entity="RTerritory">
    <join-column name="PARENT_TERRITORY_ID"/>
    <cascade>
    <cascade-persist/>
    <cascade-merge/>
    <cascade-refresh/>
    </cascade>
    </many-to-one>
    <one-to-many name="children" mapped-by="parentTerritory" target-entity="RTerritory">
    <cascade>
    <cascade-all/>
    </cascade>
    </one-to-many>
    <!--<transient name="parentTerritory"/>
    <transient name="children"/>-->
    </attributes>
    </entity>
    </entity-mappings>
    I can't understand What do I do wrong when I include "one-to-many" and "many-to-one" mapping? I want to note it (above mapping) works rightly if I use OpenJpa and one works rightly with TopLink if I remove one-to-many and many-to-one and do them transient.
    Thanks a lot.
    Message was edited by:
    user610937
    Message was edited by:
    user610937

  • Parent / Child URLs

    Silly question perhaps... but how does one display the parent/child relationship in a published site url?http://www.everydayconferencing.co.uk/index.html
    I have 3 Top levels pages (parent), and each top level page has sub pages (child), yet when I go to any of the (sub) child' pages, the 'parent' string in the url is not present (displayed before the child url. E.G. everydayconferencing/couk/kingston-venue/rear-hall).
    I had assumed that as this structure is setup in the "plan view" of Muse, the code exported would honour the parent/child hierarchy?
    Any input appreciated.

    Hi there,
    What you are saying happens when there are folders on the website, and web pages inside folders.
    Example: everydayconferencing/couk/kingston-venue/rear-hall.html, in this URL everydayconferencing, couk, kingston-venure, rear-hall these are folders inside one another and the very first folder is in the root, rear-hall.html is the webpage.
    But Muse functions differently, it will save all your pages in the root level, so URLs would be short and simple, there will be no folder created for webpages.
    Thanks.

  • One-to-many in bubble chart - or a 'stacked' bubble chart?

    Hi all
    I am working on a bubble chart app. I have found many examples of using the bubble chart to display data in a one to one basis - so there is a single data point which has a value one both the horizontal and vertical axises.
    Can someone please tell me how I can have display data which has a single vertical value, but multiple datapoints on the horizontal - and all data points for that single vertical value are dislayed on the same line?
    I hope I have explained this clearly.
    In a bar chart this is called 'Stacked'. Can I do a similar thing with a Bubble Chart - is it even possible?
    Kind regards,

    OK I think I can answer my own question.
    it seems that the Bubble Chart can have a one-to many data points. the problem was that the horizontal and vertical axis would display duplicate values.
    I found this link to be useful: http://www.mail-archive.com/[email protected]/msg96652.html//www.mail-archive.com/[email protected]/msg96652.html

Maybe you are looking for

  • Correct video encoding settings to play on ipad?

    Here's the settings that my dvd ripper (iskysoft) used to convert a home movie DVD to an "apple TV" format file file type: .mp4 format: xvid resolution: 512 x 384 frame rate: 24 bit rate 1500 This file plays fine on the apple tv and itunes, but not o

  • Podcast Producing in a Windows World

    I'm running into some major issues at the school I work for trying to get Podcast Producer up and running. I've got an Apple Xserve with 10.5.1 that is a member of a Windows Active Directory Domain (No way for that to change). My question really appl

  • In Snow Leopard I cannot arrange by name/alpha in the finder column view

    I am using Snow Leopard MAC OS 10.6.8 and can no longer sort/arrange my folders and files in alpha order when I am in column view. I used to be able to do this by view>arrange by>name. But now it does not work.

  • Importing VPF data

    What are the possible ways of importing VPF data into Oracle Spatial? Jacek Skowronek

  • Lenovo V470/V570 Boot-up problems

    I purchased a Lenovo V570 laptop 10 days ag from Best Buy. It worked really good for 8 days then got stuck at the spinning cursor at the boot-up screen. I tried multiple methods to fixing this including removing it form power source, removing the bat