This works
 
          db.begin();
          Nation nation = new Nation();
          db.create(nation);
          NationDescription desc = new NationDescription();
          db.create(desc);
          desc.setLanguage("it");
          desc.setName("No desc");
          desc.setNation(nation);
          nation.addNationDescription(desc);
          desc = new NationDescription();
          db.create(desc);
          desc.setLanguage("en");
          desc.setName("No desc");
          desc.setNation(nation);
          nation.addNationDescription(desc);
          db.commit();
          db.close();
but not this:
 
        db.begin();
        NationDescription desc = null;
        Nation nation = new Nation();
        db.create(nation);
        while(enum.hasMoreElements()) {
          String lang = (String)enum.nextElement();
          desc = new NationDescription();
          db.create(desc);
          desc.setLanguage(lang);
          desc.setName("No desc");
          desc.setNation(nation);
          nation.addNationDescription(desc);
        }
        db.commit();
        db.close();
but both does the same thing in 2 different ways.
 
----- Original Message -----
Sent: Monday, October 01, 2001 5:20 PM
Subject: [castor-dev] Problem with CREATE

What's wrong with this code?
 
        db.begin();
        Nation nation = new Nation();
        db.create(nation);
        while(enum.hasMoreElements()) {
          String lang = (String)enum.nextElement();
          NationDescription desc = new NationDescription();
          db.create(desc);
          desc.setLanguage(lang);
          desc.setName("No desc");
          desc.setNation(nation);
          nation.addNationDescription(desc);
        }
        db.commit();
        db.close();
 
This always creates 2 nations on DB and 2xlangnumber nationdescriptions (I tried with 2 languages and with 3).
In the examples I found I don't have to db.create(desc). But if I remove that NationDescriptions will not be created.
Sorry for bad english :)
Thx
Francesco

Reply via email to