Hi All,

 Following is my mapping.xml file. I would like to use Oracle sequence for
inserting value into En_ID field.

<key-generator name="SEQUENCE" alias="seqgen">
        <param name="sequence" value="{0}_SEQ"/>
</key-generator>
  <class name="com.PCPgo.prm.web.encounter.EncounterJdo" identity="id">
    <description>Encounter</description>
    <map-to table="ENCOUNTER" xml="group" />
     <field name="id" type="long" key-generator="seqgen">
      <sql name="EN_ID" type="integer" />
      <xml node="element" />
    </field>
    <field name="name" type="string" >
      <sql name="EN_NAME" type="varchar" dirty="ignore"/>
      <xml node="element"/>
    </field>
  </class>

Now, While creating EncounterJdo object, I am setting value as follows.

 EncounterJdo encounterJdo= new EncounterJdo();
 encounterJdo.setName("Allan");
  if (db == null)
             throw new InternalException("DB is null");
           db.begin();
             db.create(encounterJdo);
             db.commit();
             db.close();

 but it inserts EN_ID =0 and NAME = "Allan" and now if I run again it throws
following error. It means it doesn't generate sequence

 org.exolab.castor.jdo.DuplicateIdentityException: Duplicate identity found
for
 object of type com.PCPgo.prm.web.encounter.EncounterJdo with identity 0:
 an objec t with the same identity already exists in persistent storage

 Hope for solution.

 Best regards,
 Kumar

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to