Updating one side in a one-to-many

Hi,
Want to update fields in one table (many) from a value
from another table (one). However, this code is not running.
update table1 as t1 set t1.field3 = (select p.field4 from table4 as p where t1.id = p.id)
Thanks.

Depending on your requirement...
update table1 as t1 set t1.field3 = (select max(p.field4) from table4 as p where t1.id = p.id)
update table1 as t1 set t1.field3 = (select min(p.field4) from table4 as p where t1.id = p.id)
update table1 as t1 set t1.field3 = (select p.field4 from table4 as p where t1.id = p.id and rownum <= 1)
or others...
By the way, if there were no row on table4 corresponding to table1, how do you want to update?
My several sample update to NULL, is this permitable?

Similar Messages

  • Update one to many relationship

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

    cfquery

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

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

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

  • One-to-many mapping and update the many part

    Hello !
    Here's my problem,
    I've got an object A having a vector of object B.
    The mapping in toplink is one-to-many with the back-references set in B.
    Insertion : no problem.
    Now i would like to change the Vector of B (inserting new B, updating existing B) in a function with the Vector vC (modified vector of B).
    What is the best way to do this ?
    I tried many thing but either I have toplink 6004 error, or doing it by removing all elements of the Vector (deleting all B in database), and then setting A with C (recreating all object in the modified Vector).
    Another way to explain my case:
    how to do this in UnitOfWork ?
    function modifyAVectorOfB(A, vectorOfC)
    AClone = uow.registerObject(A);
    Aclone.setVectorOfB(vectorOfC);
    uow.commit;
    (and in database all existing object in C are updated, new object in C are created, removed object in C are deleted)

    Have found a solution, read all object in the modified Vector, read the modified object in the Unit Of Work with readObject(B) (So i get the database or cache version) and then comparing it with the modified to change what is needed to be change.

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

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

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

  • Problem Removing CMP 2.0 Bean from Many side of One-to-Many

    I'm getting an exception within the weblogic container when I try to
    delete a bean from the many side of a one-to-many CMR.
    The two entity beans are called CaseFile and CaseExpert. There are
    many CaseExperts for each CaseFile. When you call the remove method
    on the CaseExpert, Weblogic throws a null pointer exception when
    accessing the EntityCache as shown at the bottom of this message. I'm
    using the latest version of Weblogic 7 (WebLogic Server 7.0 Thu Jun
    20 11:47:11 PDT 2002 190955). My relationship section of my
    ejb-jar.xml file is also shown below.
    Any ideas?
    Thanks,
    David
    [email protected]
    javax.ejb.EJBException: EJB Exception:: java.lang.NullPointerException
    at weblogic.ejb20.cache.TxKey.<init>(TxKey.java:30)
    at weblogic.ejb20.cache.EntityCache.doGet(EntityCache.java:158)
    at weblogic.ejb20.cache.EntityCache.get(EntityCache.java:118)
    at weblogic.ejb20.manager.DBManager.getReadyBean(DBManager.java:252)
    at weblogic.ejb20.manager.DBManager.lookup(DBManager.java:949)
    at gov.usdoj.usa.ecms.casefile.exposure.ejb.CaseExpertBean_76ewyr__WebLo
    gic_CMP_RDBMS.__WL_setCaseFile(CaseExpertBean_76ewyr__WebLogic_CMP_RDBMS.java:45
    2)
    at gov.usdoj.usa.ecms.casefile.exposure.ejb.CaseExpertBean_76ewyr__WebLo
    gic_CMP_RDBMS.__WL_setCaseFile(CaseExpertBean_76ewyr__WebLogic_CMP_RDBMS.java:43
    1)
    at gov.usdoj.usa.ecms.casefile.exposure.ejb.CaseExpertBean_76ewyr__WebLo
    gic_CMP_RDBMS.ejbRemove(CaseExpertBean_76ewyr__WebLogic_CMP_RDBMS.java:1978)
    at weblogic.ejb20.manager.DBManager.remove(DBManager.java:876)
    at weblogic.ejb20.internal.EntityEJBLocalObject.remove(EntityEJBLocalObj
    ect.java:95)
    <relationships>
    <ejb-relation>
    <ejb-relation-name>caseExpert-caseFile</ejb-relation-name>
    <ejb-relationship-role>
    <ejb-relationship-role-name>CaseExpert-CaseFile</ejb-relationship-role-name>
    <multiplicity>many</multiplicity>
    <relationship-role-source>
    <ejb-name>CaseExpertEJB</ejb-name>
    </relationship-role-source>
    <cmr-field>
    <cmr-field-name>caseFile</cmr-field-name>
    </cmr-field>
    </ejb-relationship-role>
    <ejb-relationship-role>
    <ejb-relationship-role-name>CaseFile-CaseExperts</ejb-relationship-role-name>
    <multiplicity>one</multiplicity>
    <relationship-role-source>
    <ejb-name>CaseFileEJB</ejb-name>
    </relationship-role-source>
    <cmr-field>
    <cmr-field-name>caseExperts</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    </ejb-relation>
    </relationships>

    Wrong newsgroup, needs to go to one of the ejb newsgroups.
    mbg
    "Sai S Prasad" <[email protected]> wrote in message
    news:3ec28167$[email protected]..
    >
    Hi,
    I like to do the following:
    1) Map one bean corresponding to table A to many beans corresponding totable
    B 2) table B has two columns as the primary keys.
    3) One of the primary key column in table B is a foreign key pointing tothe primary
    key of table A.
    4) bean corresponding to table A has the cmr Collection field
    I am not able to map this scenario. I guess the mapping is possible aslong as
    each table has its own unrelated primary keys. If anyone has tried this,please...please...help.
    >
    >
    Thanks.

  • One to Many with multiple tables on One side and one table on Many side

    Sorry for the confusion in the title. Here is my question. In my program, I have 2 different tables which store 2 different type of entities. Each one of entities has a list of attachments which I stored in a common attachment table. There is a one-to-many relationship between entity tables and attachment table.
    ENTITY_ONE (
    ID
    NAME
    ENTITY_TWO (
    ID
    NAME
    ATTACHMENTS (
    ID
    ENTITY_ID
    ATTACHMENT_NAME
    ENTITY_ID in ATTACHMENTS table is used to link attachments to either entity one or entity two. All IDs are generated by one sequence. So they are always unique. My question is how I could map this relationship into EntityOne, EntityTwo and Attachment JAVA class?

    For EntityOne and EntityTwo you can just define a normal OneToMany mapping using the foreign key.
    Are you using JPA, or the TopLink API? JPA requires a mappedBy for the OneToMany, so this may be more difficult. You should be able to just add a JoinColumn on the OneToMany and make the column insertable/updateable=false.
    For the attachment, you could either map the foreign key as a Basic (DirectToFieldMapping) and maintain it in your model, or use a VariableOneToOne mapping in TopLink (this will require the entities share a common interface).
    James : http://www.eclipselink.org : http://en.wikibooks.org/wiki/Java_Persistence

  • My iPod touch is stuck. I chose to update one app, and now it displays "waiting" on many apps, with no movement.

    My iPod touch is stuck in update mode.

    You ONLY updated one app? If you do a bunch at the same time, it will say 'waiting' and only update one or two at a time until are are updated. I would just turn if off and on, then reconnect to wifi, and go to the App Store and retry updating.

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

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

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

  • Data services and one to many foreign keys?

    Hi,
    I am playing with the data features in Flash4.  I can get a flex app to work that will query and update a J2EE entity that has no foreign keys, but when I try the same with an entity that has many to one foreign keys I get a null pointer error coming from the server.  I created a servlet to do the same update and that worked.
    I'm wondering if the issue is a casting issue.  I know I have to do the configure data types thing to some of the generated service calls to let it know what action script class is appropriate (instead of a generic object ) e.g. findAll().  Do I have to do a similar thing for one to many foreign key situations?  i.e. lets say i have a department - employees model.  On the java side the department entity has a variable that is a set of employees.  In the department.as class I'd have a employees field thats an ArrayCollection.  Do I have to let it know somewhere that this is an ArrayCollection of employee.as objects?
    FYI, I've already changed to eager fetching of the fk values.
    Does anyone have this working?
    Thanks,
    Bill

    Hi,
    Thanks for your feedback!
    This looks like an issue.
    Can you please log a bug in http://bugs.adobe.com/flex with your sample.
    Thanks,
    Balaji
    http://balajisridhar.wordpress.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.
    %

  • How to resolve many-to-many join by 2 one-to-many joins

    Hi,
       I was asked many times how to resolve many to many relationship between two tables. I read to use 2 one -to- many relationships to resolve this. Can some expalin me when many to many relationship occurs between two tables and how to reslove them with practicle examples. Is there any article on this?
    Regards,
    Nanda Kishore

    Hi,
    Please check below link.
    http://www.forumtopics.com/busobj/viewtopic.php?p=859029&sid=20d79e3df07b0d8b41aadfbd902bb6b2
    http://blog.oaktonsoftware.com/2011/04/bridge-tables-and-many-to-many.html
    Thanks,
    Amit

  • One to Many data model solutions

    Hello Friends,
    Recently I got a requirement where I need to  join two line item DSO based on a Reference key, but it is with One to many relationship. I hestitate to use the Infoset because its a very huge DSO, which will affect the report performance.
    I even thought of updating one DSO data to the infocube by getting the lookup values from other DSO in the transformation. I am stuck in every road I take to fulfill this requirement.
    Can anyone share your ideas and thought please...... It will really helpfull..... Thanks for your time.....

    Hello Ganesh,
    Thanks very much for your answer..... I will explain my issue below:
    DSO A: ( Delta load)
    Company_code     G/L_acct     Doc_number     Reference_Key     Invoiced Amount
    1000          1009673          767787          100008          100$
    DSO B: (Full Load monthly)
    Company_code     Reference_Key     Reference_Key_itm     Sold_to          Tax_paid_amt
    1000          100008          010               A          200$
    1000          100008          020               B          300$
    1000          100008          030               C          400$
    1000          100008          040               D          500$
    DSO C:
    Company_code     Reference_Key     Reference_Key_itm     Sold_to          Tax_paid_amt     G/L_acct Invoiced Amount
    1000          100008          010               A          200$          1009673          100$
    1000          100008          020               B          300$          1009673          100$
    1000          100008          030               C          400$          1009673          100$
    1000          100008          040               D          500$          1009673          100$
    If I load DSO B - - > DSO C , and the do look up on DSO A: Then I will miss the delta changes which happen in the DSO A
    Can I load both DSO A and DSO B to DSO C?
    Edited by: Ram on Nov 24, 2009 6:55 PM

  • Possible Bug? Different behaviour for List and Set one-to-many mappings on deletePersistent()

    Hi,
    I have a PC class that represents a TreeNode object (a GcGroup), which
    has a one-to-many relationship with itself to keep track of its descendants.
    For example a hierarchy of A -> B -> C, where A has B,C as descendants
    and B has C as a descendant. This is tracked by adding or removing a
    descendant with a recursive method to update a TreeNode's parent's
    descendants when a child is added or removed.
    The odd behaviour happens when I delete a child and try to remove the
    child manually from all my parent's descendant relations when I use a
    HashSet (possibly happens with any Set). In this case kodo will remove
    the relations with the following SQL statement:
    DELETE FROM TREENODE_DESCENDANTSX JDOIDX = xxxx;
    So when I do my recursive call I get a JDOException thrown stating that
    the object xxxx has already been deleted.
    When I change the relationship to an ArrayList this exception is not
    thrown and I do not get the error.
    Looking at the SQL generated they look the same:
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] [ C:
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    27106317
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; S:
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    28819334
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; T:
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    10817575
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; D:
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    02/10/31 20:21
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ]
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    UPDATE GCGroup SET JDOLOCKX=8, child_count=0 WHERE (id = 81 AND JDOLOCKX
    = 7)
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] [ C:
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    27106317
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; S:
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    8331873
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; T:
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    10817575
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; D:
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    02/10/31 20:21
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ]
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    DELETE FROM GROUP__DESCENDANTSX WHERE JDOIDX = 12300
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] [ C:
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    27106317
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; S:
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    8331873
    2002-10-31 20:21:42,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; T:
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    10817575
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; D:
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    02/10/31 20:21
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ]
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    DELETE FROM GROUP__USERSX WHERE group_id = 12300
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] [ C:
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    27106317
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; S:
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    8331873
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; T:
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    10817575
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; D:
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    02/10/31 20:21
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ]
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    DELETE FROM GCGroup WHERE id = 12300
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] [ C:
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    27106317
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; T:
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    10817575
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; D:
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    02/10/31 20:21
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ]
    2002-10-31 20:21:42,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    commit data store transaction
    My methods look like the following:
    public void removeChild(TreeNode t) {
         _children.remove(t);
         removeDescendant(t);
    protected void removeDescendant(TreeNode t) {
         if (_parent != null) {
              _parent.removeDescendant(t);
         _descendants.remove(t);
    The following is the stack trace from the exception when using a HashSet:
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] [ C:
    2002-10-31 20:54:10,046 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    18799851
    2002-10-31 20:54:10,046 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; S:
    2002-10-31 20:54:10,046 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    30836962
    2002-10-31 20:54:10,046 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; T:
    2002-10-31 20:54:10,046 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    29139395
    2002-10-31 20:54:10,046 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; D:
    2002-10-31 20:54:10,046 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    02/10/31 20:54
    2002-10-31 20:54:10,046 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ]
    2002-10-31 20:54:10,046 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    UPDATE GCGroup SET JDOLOCKX=3, child_count=0 WHERE (id = 12450 AND
    JDOLOCKX = 2)
    2002-10-31 20:54:10,046 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] [ C:
    2002-10-31 20:54:10,046 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    18799851
    2002-10-31 20:54:10,046 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; S:
    2002-10-31 20:54:10,046 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    28630940
    2002-10-31 20:54:10,046 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; T:
    2002-10-31 20:54:10,062 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    29139395
    2002-10-31 20:54:10,062 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; D:
    2002-10-31 20:54:10,062 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    02/10/31 20:54
    2002-10-31 20:54:10,062 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ]
    2002-10-31 20:54:10,062 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    UPDATE GCGroup SET JDOLOCKX=41 WHERE (id = 2 AND JDOLOCKX = 40)
    2002-10-31 20:54:10,062 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] [ C:
    2002-10-31 20:54:10,062 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    18799851
    2002-10-31 20:54:10,062 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; S:
    2002-10-31 20:54:10,062 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    29663640
    2002-10-31 20:54:10,062 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; T:
    2002-10-31 20:54:10,062 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    29139395
    2002-10-31 20:54:10,062 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; D:
    2002-10-31 20:54:10,062 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    02/10/31 20:54
    2002-10-31 20:54:10,062 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ]
    2002-10-31 20:54:10,062 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    DELETE FROM GROUP__DESCENDANTSX WHERE JDOIDX = 12451
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] [ C:
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    18799851
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; S:
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    29663640
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; T:
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    29139395
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; D:
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    02/10/31 20:54
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ]
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    DELETE FROM GROUP__USERSX WHERE group_id = 12451
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] [ C:
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    18799851
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; S:
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    29663640
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; T:
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    29139395
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; D:
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    02/10/31 20:54
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ]
    2002-10-31 20:54:10,078 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    DELETE FROM GCGroup WHERE id = 12451
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] [ C:
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    18799851
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; S:
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    5057297
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; T:
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    29139395
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; D:
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    02/10/31 20:54
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ]
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    DELETE FROM GROUP__DESCENDANTSX WHERE JDOIDX = 12452
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] [ C:
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    18799851
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; S:
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    5057297
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; T:
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    29139395
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; D:
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    02/10/31 20:54
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ]
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    DELETE FROM GROUP__USERSX WHERE group_id = 12452
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] [ C:
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    18799851
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; S:
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    5057297
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; T:
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    29139395
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; D:
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    02/10/31 20:54
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ]
    2002-10-31 20:54:10,093 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    DELETE FROM GCGroup WHERE id = 12452
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] [ C:
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    18799851
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; T:
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    29139395
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; D:
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    02/10/31 20:54
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ]
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    roll back data store transaction
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] [ C:
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    18799851
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; S:
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    4629956
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; T:
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    29139395
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; D:
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    02/10/31 20:54
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ]
    2002-10-31 20:54:10,109 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    SELECT t0.id, t0.JDOLOCKX, t0.child_count, t0.description,
    t0.global_read, t0.global_write, t0.name, t0.owner_id, t0.parent_id,
    t0.rank, t0.root_id, t0.user_count, t0.user_exists, t0.visibility FROM
    GCGroup t0 WHERE t0.id = 12451
    2002-10-31 20:54:10,125 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] [ C:
    2002-10-31 20:54:10,125 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    18799851
    2002-10-31 20:54:10,125 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; S:
    2002-10-31 20:54:10,125 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    2951648
    2002-10-31 20:54:10,125 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; T:
    2002-10-31 20:54:10,125 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    29139395
    2002-10-31 20:54:10,125 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ; D:
    2002-10-31 20:54:10,125 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    02/10/31 20:54
    2002-10-31 20:54:10,125 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] ]
    2002-10-31 20:54:10,125 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo]
    SELECT t0.id, t0.JDOLOCKX, t0.child_count, t0.description,
    t0.global_read, t0.global_write, t0.name, t0.owner_id, t0.parent_id,
    t0.rank, t0.root_id, t0.user_count, t0.user_exists, t0.visibility FROM
    GCGroup t0 WHERE t0.id = 12452
    2002-10-31 20:54:10,140 INFO [STDOUT]
    com.gulfnet.common.actions.GroupAction : The exception is:
    javax.jdo.JDOException
    2002-10-31 20:54:10,140 INFO [org.jboss.web.localhost.Engine] action:
    com.gulfnet.common.actions.GroupAction : The exception is:
    javax.jdo.JDOException
    2002-10-31 20:54:10,140 INFO [STDOUT]
    com.gulfnet.common.actions.GroupAction : java.lang.NullPointerException
    2002-10-31 20:54:10,140 INFO [org.jboss.web.localhost.Engine] action:
    com.gulfnet.common.actions.GroupAction : java.lang.NullPointerException
    2002-10-31 20:54:10,140 ERROR [STDERR] javax.jdo.JDOException:
    java.lang.NullPointerException
    NestedThrowables:
    java.lang.NullPointerException
    2002-10-31 20:54:10,156 ERROR [STDERR] at
    com.solarmetric.kodo.ee.EEPersistenceManager.rollback(EEPersistenceManager.java:169)
    2002-10-31 20:54:10,156 ERROR [STDERR] at
    com.gulfnet.usermanager.UserManager.deleteGroup(UserManager.java:775)
    2002-10-31 20:54:10,156 ERROR [STDERR] at
    com.gulfnet.common.actions.GroupAction.deleteObject(GroupAction.java:146)
    2002-10-31 20:54:10,171 ERROR [STDERR] at
    com.gulfnet.common.actions.GroupAction.doAction(GroupAction.java:58)
    Kam

    Forgot to add that I am using SQLServer 2000, Jboss 3.0.3 and Kodo 2.3.4
    Kam

  • One to many relation doesn't work

    I tried without success to get a simple one to many relationship to work.
    The select works fine but
    I still have problems with insert.
    I have two tables on a existing schema:
    1     ANAG (ID_ANAG primary key,...)
    2     INDI (ID_INDI primary key, ID_ENTITA,...), where INDI.ID_ENTITA points
    to ANAG.ID_ANAG
    the two classes are:
    1     public class Anagrafica
         private int idAnag; //ID_ANAG
         private String ragSoc;
         private String ragSocFonet;
         private String codFisc;
         private String sesso;
         private Integer codTit;
         private Date dtNasc;
         private HashSet indis;
    2     public class Indirizzo
         private int idIndi; //ID_INDI
         private long idEntita; //ID_ENTITA
         private long tpEntita;
         private String indirizzo;
         private String localita;
         private String prov;
         private String cap;
         private Anagrafica anagrafica;
    the two metadata:
    1      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="ragSocFonet">
    <extension key="data-column" value="RAG_SOC_FONET"
    vendor-name="kodo"/>
    </field>
    <field name="codFisc">
    <extension key="data-column" value="COD_FISC"
    vendor-name="kodo"/>
    </field>
    <field name="sesso">
    <extension key="data-column" value="SESSO"
    vendor-name="kodo"/>
    </field>
    <field name="codTit">
    <extension key="data-column" value="COD_TIT"
    vendor-name="kodo"/>
    </field>
    <field name="dtNasc">
    <extension key="data-column" value="DT_NASC"
    vendor-name="kodo"/>
    </field>
    <field name="indis">
    <collection element-type="domain.Indirizzo"/>
    <extension vendor-name="kodo" key="table" value="INDI"/>
    <extension vendor-name="kodo" key="inverse"
    value="anagrafica"/>
    <extension vendor-name="kodo" key="idEntita-ref-column"
    value="ID_ANAG"/>
         </field>
    </class>
    </package>
    </jdo>
    2 Indirizzo.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="Indirizzo"
    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"/>
    <!--extension vendor-name="kodo" key="idEntita-data-column"
    value="ID_ENTITA"/-->
    <field name="idIndi" primary-key="true">
    <extension key="data-column" value="ID_INDI"
    vendor-name="kodo"/>
    </field>
    <field name="idEntita">
    <extension key="data-column" value="ID_ENTITA"
    vendor-name="kodo"/>
    </field>
    <field name="tpEntita">
    <extension key="data-column" value="TP_ENTITA"
    vendor-name="kodo"/>
    </field>
    <field name="indirizzo">
    <extension key="data-column" value="INDIRIZZO"
    vendor-name="kodo"/>
    </field>
    <field name="localita">
    <extension key="data-column" value="LOCALITA"
    vendor-name="kodo"/>
    </field>
    <field name="prov">
    <extension key="data-column" value="PROV"
    vendor-name="kodo"/>
    </field>
    <field name="cap">
    <extension key="data-column" value="CAP"
    vendor-name="kodo"/>
    </field>
    <field name="anagrafica">
    <extension vendor-name="kodo" key="idAnag-data-column"
    value="ID_ENTITA"/>
    </field>
    </class>
    </package>
    </jdo>
    The problem is:
    I create a new Anagrafica object and then I try to save it in the
    database. These are the SQL
    statements that are generated:
    INSERT INTO ANAG(DT_NASC, COD_FISC, RAG_SOC_FONET, SESSO, ID_ANAG,
    RAG_SOC, COD_TIT)
    VALUES (NULL, NULL, 'NATALE', NULL, 971963921, 'Natale', NULL)
    INSERT INTO INDI(TP_ENTITA, PROV, LOCALITA, ID_ENTITA, ID_INDI, INDIRIZZO,
    CAP)
    VALUES (0, NULL, NULL, 0, 971963921, 'via 25 dicembre', NULL)
    Why is the value of ID_ANAG (971963921) assigned to ID_INDI and not to
    ID_ENTITA?
    Regards
    Mirko

    Abe White wrote:
    <field name="indis">
    <collection element-type="domain.Indirizzo"/>
    <extension vendor-name="kodo" key="table" value="INDI"/>
    <extension vendor-name="kodo" key="inverse"
    value="anagrafica"/>
    <extension vendor-name="kodo" key="idEntita-ref-column"
    value="ID_ANAG"/>
         </field>
    Get rid of all extensions except the inverse:
    <field name="indis">
    <collection element-type="domain.Indirizzo"/>
    <extension vendor-name="kodo" key="inverse" value="anagrafica"/>
    </field>
    As in the examples in our documentation, all 1-many relations should only
    list their inverse 1-1 relation.
    Also, make sure your object model is consistent; i.e. make sure you'resetting
    both sides of the relation:
    indi.setAnagrafica (anag);
    anag.getIndis ().add (indi);
    Let us know if you continue to have problems.Hi Abe,
    I got rid of the unnecessary extensions and I set both sides of the
    relation as you suggest but I still have the same problem:
    INSERT INTO ANAG(ID_ANAG) VALUES (2088176453)
    INSERT INTO INDI(ID_INDI, ID_ENTITA) VALUES (2088176453, NULL)
    while I expect
    INSERT INTO ANAG(ID_ANAG) VALUES (2088176453)
    INSERT INTO INDI(ID_INDI, ID_ENTITA) VALUES (<some ID>, 2088176453)
    any ideas?
    regards

Maybe you are looking for