Use one as Many

Hi
When we use this node function why we need the third parameter ? We already mentioned the parameter to be used many times and the number of times it should appear by the first two parameters itself ? So why we need the third paramter ? I went through help website but couldn't make out
Radhika

this standard SAP example should clarify your doubt.
[http://help.sap.com/saphelp_nw2004s/helpdata/en/38/85b142fa26c811e10000000a1550b0/content.htm]
Third parameter is useful, for getting the same context changes from source to target.
Edited by: Praveen Gujjeti on Mar 24, 2010 12:14 PM

Similar Messages

  • 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

  • "Use one as many "function

    Hi All
    I have a scenario from RFC to WSDL in which if certain conditions fulfil only then can I pass the value to the target field "SERVCODE".
    The problem is there are many conditions which are to be fulfilled to have the value passed.
    I tried using the function "use One As Many" but I got stuck at the "OR" condtion because its taking only boolean values.
    Please have a look at the scenario and help me!!
    Also I am preferring to have a graphical mapping but if nothing works out User defined function would do.
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS <> BLANK & MARA-MATKL = 800001031----
    then  SERVCODE = 400 (400 is the Value to be passed to the target field to SERVCODE)
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS<> BLANK & MARA-MATKL <> 800001031 & VBAK u2013AUART = Z000 & MVKE u2013 MVGR2 = 001 -
    then   SERVCODE= 201(201is the Value to be passed to the target field  to SERVCODE)
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS <> BLANK & MARA-MATKL <> 800001031 & VBAK u2013AUART = Z000 & MVKE u2013 MVGR2 = 002 -
    then  SERVCODE= 202 (202 is the Value to be passed to the target field to SERVCODE)
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS <> BLANK & VBAK u2013AUART = Z001& MVKE u2013 MVGR2 = 001 -
    then SERVCODE= 301(301 is the value to be passed to the target field to SERVCODE)
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS <> BLANK& VBAK u2013AUART = Z001 & MVKE u2013 MVGR2 = 002 -
    then SERVCODE= 302 (302 is the Value to be passed to the target field to SERVCODE)
    u2022     IF VBAP-PSTYV <> Z004 VBAP-AUART = Z000 -
    then  SERVCODE = 1 (1 is the Value to be passed to the target field to SERVCODE)     
    u2022     IF VBAP-PSTYV <> Z004 VBAP-AUART = Z001 -
    then  SERVCODE = 101(101 is the Value to be passed to the target field to SERVCODE)
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS = BLANK &VBAP-AUART = Z000 & MVKE-MVGR2 = 001 -
    then SERVCODE = 201(201 is the Value to be passed to the target field to SERVCODE)
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS = BLANK & VBAP-AUART = Z000 & MVKE-MVGR2 = 002 -
    then SERVCODE = 202(202 is the Value to be passed to the target field to SERVCODE)
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS = BLANK & VBAP-AUART = Z001 & MVKE-MVGR2 = 001 -
    then SERVCODE = 301(301 is the Value to be passed to the target field to SERVCODE)
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS =BLANK & VBAP-AUART = Z001 & MVKE-MVGR2 = 002----
    then SERVCODE = 302 (302 is the Value to be passed to the target fieldto SERVCODE)
    Thanks a lot in advance !!

    You may post it on a wrong forum.  Here is SAP Business One Core forum, a forum dedicate to SAP Business One - a solution to SME.  Please close your thread and try this forum to start:
    Process Integration (PI) & SOA Middleware
    Thanks,
    Gordon

  • Difference between copy value and use one as many

    hi
    what  is the difference between copy value and use one as many?
    thanks

    [http://help.sap.com/saphelp_nw2004s/helpdata/en/26/d22366565be0449d7b3cc26b1bab10/content.htm]
    [http://help.sap.com/saphelp_nw2004s/helpdata/en/ef/df564b6aa24fc9ab0d685460747de5/content.htm]
    Much better understanding of UseOneAsMany: [http://help.sap.com/saphelp_nw2004s/helpdata/en/38/85b142fa26c811e10000000a1550b0/content.htm]
    Edited by: Praveen Gujjeti on Feb 18, 2010 11:42 AM

  • How to use one ResultSet many times in a jsp page ?

    Hi all,
    I have .jsp page and I have used it to get data from DB and display them to users. So I have to get data from DB in number of places in this particular jsp.
    I thought that it is better to have one ResultSet for entire page and once it is done its job, the ResultSet will be closed and I can use it again and again like this.
    Resultset rs = new ResultSet();
    try{
        //My operations
    }catch(Exception ex){
       //Handle Exceptions
    }finally{
       rs.close();
    }After above code snippet I can use same ResultSet again below the page.
    I just want to know this,
    1. is this a good coding practice?
    2. Should i put rs = null; within finally clause?
    any help will be appreciated
    thank in advance,
    Dilan.

    Ok, Finally I switched my coding to use DAO and DTO, and I learned it through internet.
    I removed all of data access codes from my jsp file(lets say 'functions.jsp'). I then created one interface and two clasess.
    here is my DAO interface.
    public interface UserFunctionsDAO{
        public List<UserFunctionsDTO> selectUserList();
    }here is DTO class
    public class UserFunctionsDTO{
        private String category = "";
        private String sub_category = "";
        private int cat_id = 0;
        private int sub_cat_id = 0;
        public UserFunctionsDTO(){}
        public UserFunctionsDTO(String category, String sub_category, int cat_id, int sub_cat_id){
            this.category = category;
            this.sub_category = sub_category;
            this.cat_id = cat_id;
            this.sub_cat_id = sub_cat_id;
        //Setters and getters will go here.
    }my concrete data access class is like this.
    public class UserFunctionsDataAccess implements UserFunctionsDAO{
        MyDB dbObject = null;
       private static final String SQL_GET_DISTINCT_CAT= "SELECT DISTINCT cat FROM cat_table";
       public List<UserFunctionsDTO> selectUserList(){
           dbObject = new MyDB();
           dbObject.sqlSelect(SQL_GET_DISTINCT_CAT);
           ResultSet rs = dbObject.getResultSet();
           ArrayList list = new ArrayList();
           while(rs.next()){
               list.add(new UserFunctionsDTO(rs.getString('category'), .......................));
           return list;     
    }I think now im following good coding practices, but I have one problem.
    1. How do I retrieve this userlist from my jsp page?
    2. Should I include UserFunctionsDTO in my jsp page as a bean?
    3. If I include it, how can I get the list from it?
    thanks in advance,
    Dilan.

  • Message mapping: one as many, function node

    hi
    how to use - one as many - function node in mapping. i want to mapping one value from source structure to many fields in target structure. but i dont know the exact functionality of - one as many -
    kindly solve my issue
    regards
    mano

    Hi,
    Check out this example from SAP, which demos the use of the function oneAsMany:
    [http://help.sap.com/saphelp_nw04/helpdata/en/38/85b142fa26c811e10000000a1550b0/frameset.htm]
    Hope this helps,
    Sumant.

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

  • One to many subqueries?

    Hi,all
    I have two tables:
    CREATE TABLE UserInfoTable (
    loginId VARCHAR(32) CONSTRAINT pk_userLoginId
    PRIMARY KEY,
    regionId NUMBER(12),
    accountId NUMBER(12) NOT NULL)
    CREATE TABLE AccountTable
    accountId NUMBER(12) NOT NULL PRIMARY KEY)
    i have established the two master tables on the master site,but
    when i create snapshot as:
    CREATE SNAPSHOT test.AccountTable ON PREBUILT TABLE
    REFRESH FORCE
    START WITH to_date('20/12/2001 07:39:49 am','dd-Mon-yyyy
    HH:MI:SS am')
    NEXT /*1:Hr*/ sysdate + 1/(30*24)
    FOR UPDATE
    AS select * from [email protected] A where
    exists (select 1 from [email protected] B
    where A.accountId = B.accountId and B.regionId = 2)
    i got the following error:
    ORA-12013:updatable snapshots must be simple enough to do
    fast refresh!
    i have create snapshot log on userinfotable.accountId and
    userinfotable.regionid on master site.but if i get rid of the
    above "FOR UPDATE",then it works well.
    this subquery is one to many subqueries?
    the document of oracle 9i said:
    Note: The materialized view site must have a compatibility level
    of 9.0.0 or higher because fast refresh of materialized views
    with one to many subqueries was not supported prior to release
    9.0.0 of Oracle. The compatibility level is controlled by the
    COMPATIBLE initialization parameter.
    i use Oracle enterprise edition 8.1.7.so it can't do updatable
    snapshots while using one to many subqueries?
    Anybody can help me?i have wandered on this problem serveral
    days.
    thanks in advance!

    .. do you know if there are firewalls that can implement one-to-many nat ? tipically one private ip statically natted to many public ip .. checkpoint, fortigate ..

  • One to many problem onan existing shema

    I'm trying to do an insert in a database using one-to-many mapping.
    I have two tables on an existing schema.
    The two tables are:
    ANAG
    | ID_ANAG     | RAG_SOC |
    |-------------------------|
    |     1     | a name |
    |-------------------------|
    | ...     | .....     |
    |-------------------------|
    INDI
    | ID_INDI     | ID_ENTITA     | INDIRIZZO|
    |-------------------------------------------
    | 101          | 1          | address 1|
    |------------------------------------------|
    | 102          | 1          | address 2|
    |------------------------------------------|
    | 103          | ....          | ....     |
    |------------------------------------------|
    One ANAG can have m INDI. Given an ANAG I can find the related INDI(s)
    with the relation
    ANAG.ID_ANAG=INDI.ID_ENTITA
    My two java classes are:
    package domain;
    import java.util.*;
    public class Anagrafica
    private int idAnag; //ID_ANAG
    private String ragSoc;
    private HashSet indis;
    // default constructor
    //get and set methods
    package domain;
    public class Indi
    private int idIndi; //ID_INDI
    private long idAnag; //ID_ENTITA
    private String indirizzo; //INDIRIZZO
    private Anagrafica anagrafica;
    // default constructor
    //get and set methods
    Anagrafica.jdo:
    <?xml version="1.0"?>
    <!-- This JDO Metadata file was auto-generated on 08/10/02 17.44.
    See http://www.solarmetric.com for Kodo JDO Documentation and examples. -->
    <jdo>
    <package name="domain">
    <class name="Anagrafica"
    identity-type="application"
    objectid-class="domain.AnagraficaPK">
    <extension key="table" value="ANAG" vendor-name="kodo"/>
    <extension key="class-column" value="none" vendor-name="kodo"/>
    <extension key="lock-column" value="none" vendor-name="kodo"/>
    <field name="idAnag" primary-key="true">
    <extension key="data-column" value="ID_ANAG"
    vendor-name="kodo"/>
    </field>
    <field name="ragSoc">
    <extension key="data-column" value="RAG_SOC"
    vendor-name="kodo"/>
    </field>
    <field name="indis">
    <collection element-type="domain.Indi"/>
    <extension vendor-name="kodo" key="inverse"
    value="anagrafica"/>
         </field>
    </class>
    </package>
    </jdo>
    Indi.jdo
    <?xml version="1.0"?>
    <!-- This JDO Metadata file was auto-generated on 08/10/02 17.21.
    See http://www.solarmetric.com for Kodo JDO Documentation and examples. -->
    <jdo>
    <package name="domain">
    <class name="Indi"
    identity-type="application" objectid-class="domain.IndiPK">
    <extension key="table" value="INDI" vendor-name="kodo"/>
    <extension key="class-column" value="none" vendor-name="kodo"/>
    <extension key="lock-column" value="none" vendor-name="kodo"/>
    <field name="idIndi" primary-key="true">
    <extension key="data-column" value="ID_INDI"
    vendor-name="kodo"/>
    </field>
    <field name="idAnag">
    <extension key="data-column" value="ID_ENTITA"
    vendor-name="kodo"/>
    </field>
    <field name="indirizzo">
    <extension key="data-column" value="INDIRIZZO"
    vendor-name="kodo"/>
    </field>
    <field name="anagrafica"/>
    </class>
    </package>
    </jdo>
    When I run the test program and I try to insert a new Anagrafica object I
    get the exception:
    [ C:3974641; S:1673361; T:3317565; D:09/10/02 16.03 ] INSERT INTO
    ANAG(ID_ANAG, RAG_SOC) VALUES
    (-914917554, 'A NEW RAGSOC')[ C:3974641; S:7389395; T:3317565; D:09/10/02
    16.03 ] INSERT INTO
    INDI(INDIRIZZO, IDANAG_ANAGRAFICAX, ID_INDI, ID_ENTITA) VALUES ('via 25
    dicembre', NULL,
    -914917554,0)javax.jdo.JDOFatalDataStoreException:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper: [SQL=INSERT INTO
    INDI(INDIRIZZO,
    IDANAG_ANAGRAFICAX, ID_INDI, ID_ENTITA) VALUES ('via 25 dicembre', NULL,
    -914917554,0)] ORA-00904:
    invalid column name
    [code=904;state=42000]
    NestedThrowables:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper: [SQL=INSERT INTO
    INDI(INDIRIZZO,
    IDANAG_ANAGRAFICAX, ID_INDI, ID_ENTITA) VALUES ('via 25 dicembre', NULL,
    -914917554, 0)] ORA-00904:
    invalid column name
    [ C:3974641; T:3317565; D:09/10/02 16.03 ] roll back data store
    transaction     at
    com.solarmetric.kodo.impl.jdbc.runtime.SQLExceptions.throwFatal(SQLExceptions.java:17)     at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.insert(JDBCStoreManager.java:421)     at
    com.solarmetric.kodo.runtime.StateManagerImpl.insert(StateManagerImpl.java:1783)     at
    com.solarmetric.kodo.runtime.PNewState.flush(PNewState.java:31)     at
    com.solarmetric.kodo.runtime.StateManagerImpl.flush(StateManagerImpl.java:372)     at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:426)     at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:295)     at
    test.AnagraficaJdo.main(AnagraficaJdo.java:49)NestedThrowablesStackTrace:java.sql.SQLException:
    ORA-00904: invalid column name
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)     at
    oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)     at
    oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)     at
    oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)     at
    oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822)     at
    oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1446)     at
    oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1371)     at
    oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1900)     at
    oracle.jdbc.driver.OracleStatement.doScrollStmtExecuteQuery(OracleStatement.java:5290)     at
    oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:697)     at
    com.solarmetric.kodo.impl.jdbc.datasource.StatementImpl.executeUpdate(StatementImpl.java:78)     at
    com.solarmetric.kodo.impl.jdbc.sql.NonSelectingSQL.execute(NonSelectingSQL.java:40)     at
    com.solarmetric.kodo.impl.jdbc.ormapping.ClassMapping.insert(ClassMapping.java:391)     at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.insert(JDBCStoreManager.java:416)     at
    com.solarmetric.kodo.runtime.StateManagerImpl.insert(StateManagerImpl.java:1783)     at
    com.solarmetric.kodo.runtime.PNewState.flush(PNewState.java:31)     at
    com.solarmetric.kodo.runtime.StateManagerImpl.flush(StateManagerImpl.java:372)     at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:426)     at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:295)     at
    test.AnagraficaJdo.main(AnagraficaJdo.java:49)
    How can I resolve the problem of the presence of IDANAG_ANAGRAFICAX and
    have the 1-m relation?
    Thank you in advance.
    Mirko

    I've changed the Indi class and the metadata but I still get an exception:
    javax.jdo.JDOFatalDataStoreException:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper:
    [SQL=INSERT INTO INDI
    (INDIRIZZO, IDANAG_ANAGRAFICAX, ID_INDI, IDANAGX) VALUES
    ('via 25 dicembre', NULL, -847766554, 0)]
    ORA-00904: invalid column name
    I know I'm missing something but I don't know what.
    I can't find any simple example of a one-to-many mapping of two tables on
    an existing schema.
    The final SQL should be: INSERT INTO INDI(INDIRIZZO, ID_ENTITA, ID_INDI)
    VALUES ('via 25 dicembre', -847766554, -847766554)
    thank you in advance for help
    Fred Lucas wrote:
    You should not have both primitive fields for the data in the tables and
    relations to other persistence-capable objects. So, your Indi class and
    metadata should probably look something like this:
    package domain;
    public class Indi
    private int idIndi; //ID_INDI
    private String indirizzo; //INDIRIZZO
    private Anagrafica anagrafica;
    // default constructor
    //get and set methods
    Indi.jdo
    <?xml version="1.0"?>
    <!-- This JDO Metadata file was auto-generated on 08/10/02 17.21.
    See http://www.solarmetric.com for Kodo JDO Documentation and examples. -->
    <jdo>
    <package name="domain">
    <class name="Indi"
    identity-type="application" objectid-class="domain.IndiPK">
    <extension key="table" value="INDI" vendor-name="kodo"/>
    <extension key="class-column" value="none" vendor-name="kodo"/>
    <extension key="lock-column" value="none" vendor-name="kodo"/>
    <field name="idIndi" primary-key="true">
    <extension key="data-column" value="ID_INDI"
    vendor-name="kodo"/>
    </field>
    <field name="indirizzo">
    <extension key="data-column" value="INDIRIZZO"
    vendor-name="kodo"/>
    </field>
    <field name="anagrafica">
    <extension key="data-column" value="ID_ENTITA"
    vendor-name="kodo"/>
    </field>
    </class>
    </package>
    </jdo>
    -Fred
    In article <[email protected]>, Mirko wrote:
    I'm trying to do an insert in a database using one-to-many mapping.
    I have two tables on an existing schema.
    The two tables are:
    ANAG
    | ID_ANAG     | RAG_SOC |
    |-------------------------|
    |     1     | a name |
    |-------------------------|
    | ...     | .....     |
    |-------------------------|
    INDI
    | ID_INDI     | ID_ENTITA     | INDIRIZZO|
    |-------------------------------------------
    | 101          | 1          | address 1|
    |------------------------------------------|
    | 102          | 1          | address 2|
    |------------------------------------------|
    | 103          | ....          | ....     |
    |------------------------------------------|
    One ANAG can have m INDI. Given an ANAG I can find the related INDI(s)
    with the relation
    ANAG.ID_ANAG=INDI.ID_ENTITA
    My two java classes are:
    package domain;
    import java.util.*;
    public class Anagrafica
    private int idAnag; //ID_ANAG
    private String ragSoc;
    private HashSet indis;
    // default constructor
    //get and set methods
    package domain;
    public class Indi
    private int idIndi; //ID_INDI
    private long idAnag; //ID_ENTITA
    private String indirizzo; //INDIRIZZO
    private Anagrafica anagrafica;
    // default constructor
    //get and set methods
    Anagrafica.jdo:
    <?xml version="1.0"?>
    <!-- This JDO Metadata file was auto-generated on 08/10/02 17.44.
    See http://www.solarmetric.com for Kodo JDO Documentation and examples. -->
    <jdo>
    <package name="domain">
    <class name="Anagrafica"
    identity-type="application"
    objectid-class="domain.AnagraficaPK">
    <extension key="table" value="ANAG" vendor-name="kodo"/>
    <extension key="class-column" value="none" vendor-name="kodo"/>
    <extension key="lock-column" value="none" vendor-name="kodo"/>
    <field name="idAnag" primary-key="true">
    <extension key="data-column" value="ID_ANAG"
    vendor-name="kodo"/>
    </field>
    <field name="ragSoc">
    <extension key="data-column" value="RAG_SOC"
    vendor-name="kodo"/>
    </field>
    <field name="indis">
    <collection element-type="domain.Indi"/>
    <extension vendor-name="kodo" key="inverse"
    value="anagrafica"/>
         </field>
    </class>
    </package>
    </jdo>
    Indi.jdo
    <?xml version="1.0"?>
    <!-- This JDO Metadata file was auto-generated on 08/10/02 17.21.
    See http://www.solarmetric.com for Kodo JDO Documentation and examples. -->
    <jdo>
    <package name="domain">
    <class name="Indi"
    identity-type="application" objectid-class="domain.IndiPK">
    <extension key="table" value="INDI" vendor-name="kodo"/>
    <extension key="class-column" value="none" vendor-name="kodo"/>
    <extension key="lock-column" value="none" vendor-name="kodo"/>
    <field name="idIndi" primary-key="true">
    <extension key="data-column" value="ID_INDI"
    vendor-name="kodo"/>
    </field>
    <field name="idAnag">
    <extension key="data-column" value="ID_ENTITA"
    vendor-name="kodo"/>
    </field>
    <field name="indirizzo">
    <extension key="data-column" value="INDIRIZZO"
    vendor-name="kodo"/>
    </field>
    <field name="anagrafica"/>
    </class>
    </package>
    </jdo>
    When I run the test program and I try to insert a new Anagrafica object I
    get the exception:
    [ C:3974641; S:1673361; T:3317565; D:09/10/02 16.03 ] INSERT INTO
    ANAG(ID_ANAG, RAG_SOC) VALUES
    (-914917554, 'A NEW RAGSOC')[ C:3974641; S:7389395; T:3317565; D:09/10/02
    16.03 ] INSERT INTO
    INDI(INDIRIZZO, IDANAG_ANAGRAFICAX, ID_INDI, ID_ENTITA) VALUES ('via 25
    dicembre', NULL,
    -914917554,0)javax.jdo.JDOFatalDataStoreException:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper: [SQL=INSERT INTO
    INDI(INDIRIZZO,
    IDANAG_ANAGRAFICAX, ID_INDI, ID_ENTITA) VALUES ('via 25 dicembre', NULL,
    -914917554,0)] ORA-00904:
    invalid column name
    [code=904;state=42000]
    NestedThrowables:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper: [SQL=INSERT INTO
    INDI(INDIRIZZO,
    IDANAG_ANAGRAFICAX, ID_INDI, ID_ENTITA) VALUES ('via 25 dicembre', NULL,
    -914917554, 0)] ORA-00904:
    invalid column name
    [ C:3974641; T:3317565; D:09/10/02 16.03 ] roll back data store
    transaction     at
    com.solarmetric.kodo.impl.jdbc.runtime.SQLExceptions.throwFatal(SQLExceptions.java:17)     at
    >>
    >>
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.insert(JDBCStoreManager.java:421)     at
    >>
    >>
    com.solarmetric.kodo.runtime.StateManagerImpl.insert(StateManagerImpl.java:1783)     at
    >>
    com.solarmetric.kodo.runtime.PNewState.flush(PNewState.java:31)     at
    com.solarmetric.kodo.runtime.StateManagerImpl.flush(StateManagerImpl.java:372)     at
    >>
    >>
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:426)     at
    >>
    >>
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:295)     at
    >>
    >>
    test.AnagraficaJdo.main(AnagraficaJdo.java:49)NestedThrowablesStackTrace:java.sql.SQLException:
    >>
    ORA-00904: invalid column name
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)     at
    oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)     at
    oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)     at
    oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)     at
    oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822)     at
    oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1446)     at
    >>
    >>
    oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1371)     at
    >>
    >>
    oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1900)     at
    >>
    >>
    oracle.jdbc.driver.OracleStatement.doScrollStmtExecuteQuery(OracleStatement.java:5290)     at
    >>
    >>
    oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:697)     at
    >>
    >>
    com.solarmetric.kodo.impl.jdbc.datasource.StatementImpl.executeUpdate(StatementImpl.java:78)     at
    >>
    >>
    com.solarmetric.kodo.impl.jdbc.sql.NonSelectingSQL.execute(NonSelectingSQL.java:40)     at
    >>
    >>
    com.solarmetric.kodo.impl.jdbc.ormapping.ClassMapping.insert(ClassMapping.java:391)     at
    >>
    >>
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.insert(JDBCStoreManager.java:416)     at
    >>
    >>
    com.solarmetric.kodo.runtime.StateManagerImpl.insert(StateManagerImpl.java:1783)     at
    >>
    com.solarmetric.kodo.runtime.PNewState.flush(PNewState.java:31)     at
    com.solarmetric.kodo.runtime.StateManagerImpl.flush(StateManagerImpl.java:372)     at
    >>
    >>
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:426)     at
    >>
    >>
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:295)     at
    >>
    test.AnagraficaJdo.main(AnagraficaJdo.java:49)
    How can I resolve the problem of the presence of IDANAG_ANAGRAFICAX and
    have the 1-m relation?
    Thank you in advance.
    Mirko
    Fred Lucas
    SolarMetric Inc.
    202-595-2064 x1122
    http://www.solarmetric.com

  • 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 used to open many tabs in the same page and i move from one to other by mouse but since3 two days the tabs open in the same page normaly but i can't move from one to other when i clik with mouse on any tab it don't open/ do u have any solve for this?

    i used to open many tabs in the same page and i move from one to other by mouse but since3 two days the tabs open in the same page normaly but i can't move from one to other when i clik with mouse on any tab it don't open/ do u have any solve for this

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do not click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • How can I export a list of events for one of many calendars - e.g. "sailing" to use in Excel

    How can I export a list of events for one of many calendars - e.g. "sailing" to use in Excel?

    See this thread here
    Display number of emails by sender

  • HT204380 When using facetime how many people can you be connected to at one given time? The reason for this question is I would like to utilize facetime for conference call meetings.

    When using facetime, how many people can you be connectedto at once? The reason I ask this question is, I am wanting to conduct teleconference meetings with my staff who are spread out throughout the state and I would like to be able to have seven people in total connected to facetime at once.

    Currently only one person. A lot of users want to be able to FT multiple users.
    Send feedback to Apple requesting it. Maybe in a future iOS update or iPad it will be available.
    http://www.apple.com/feedback/ipad.html
     Cheers, Tom

  • HT204387 Hello!  Can anyone teach me how to connect iphone 4S to ipad retina using bluetooth. I tried, but the devices won't discover each other at all. I just wanted to connect to share contact details so I don't have to key in one by one.   Many thanks

    Hello!
    Can anyone teach me how to connect iphone 4S to ipad retina using bluetooth. I tried, but the devices won't discover each other at all. I just wanted to connect to share contact details so I don't have to key in one by one.
    Many thanks
    Injin

    You need to go to the App stores and find compatible apps. iOS device do not natively have to ability to transfer info to a computer via BT to a computer.
    With iOS 8 you can use AirDrop

  • One to Many Using an Interface

    I have a one to many object mapping. There is a foreign key on the many table that is not being auto populated when it gets added to the one object. Is this normal activity? I would think that this column would not have to be explicitly set.
    Also, I am using sequencing on the primary key of both the one object and the many object.
    Following is a simplified code excert of what I am doing. Could I be doing something wrong?
    Thanks,
    Michael
    public void testAddManyObject(OneObject oneObject){
    UnitOfWork uow = this.getUnitOfWork();          
    ManyObject manyObject = new ManyObject();
    uow.assignSequenceNumber(manyObject);
    payoff.setRandomValue("10000");          
    oneObject.addManyObject(manyObject);
    uow.registerObject(payoff);
    uow.commit();
         }

    (I am assuming that "payoff" is your "oneObject", otherwise I'm not sure of it's relevance in the example).
    Does your addMany(Many aMany) look like this:
    public void addMany(Many aMany) {
    manyCollection.add(aMany);
    aMany.setOne(this);
    In other words, it's the 1-1 back reference that's really important in a 1-M... You shouldn't have to force the assignment of sequence numbers unless you want it for your business domain for some reason.
    - Don

Maybe you are looking for

  • Photos not showing up in iPhoto but still in Library

    I'm having a problem with iPhoto. I just got back from a trip. I was copying using the share photo function my photos from one computer to another and after that it seems that about 500 photos are not showing up on the original computer, these photos

  • Test_fwktutorial error. Application not found

    I have been worked on this for a whole day. I installed Jdeveloper for RUP6 and went through all the set up ( Task 1-6 ). However, I got pop up error -- Application not found when I tried test_fwktutorial.jsp. I have verified the database connection

  • Can't update firmware 1.6 on my mid 2011 Macbook Air

    After I install this firmware, Macbook Air shows spinning icon forever and never reboot.  Only way to recover from there is to power off and reboot by aborting update.  Is there any clue on this? MacBookAir4,2 Intel Core i7 1.8 GHz DRAM 4 GB Boot ROM

  • Adobe Acrobat form can be opened in Adobe Reader but no one can fill it out. Why not?

    So I created a form for my job that my co-workers and clients need to be able to fill out. It was created in Acrobat and while others can open it in their Adobe Reader they are unable to edit any of the fields/fill the form out. Any ideas what might

  • Urgent help with Nokia E71 back up/ restore

    the problem this morning when phone started switching on and off by itself. As I had similar problem recently (and got new handset), I tried to back up the content. the back up went well as far I could see and i was asked to restart the phone. once r