Hi all
I have a problem need your help. The problem exist when JDO is used at web
application server.
The problem is similar to following JSP example
The OBDiseaseBean has one-to-many mapping to a child
table OBClinicalPresentation as a ArrayList inside OBDiseaseBean.
The following code is try to add OBClinicalPresentation record to
the OBDiseaseBean, but the remark field size of of OBDiseaseBean
is too large Following exception is thrown
[code]
Nested error: org.exolab.castor.jdo.PersistenceException: Nested error:
java.sql.SQLException: ORA-01401: inserted value too large for column
[/code]
Therefore, I remark the [b]bean.setRemk(b.toString());[/b] method on coding
and try to add the OBClinicalPresentation record again (Reload the JSP).
Following Exception is thrown.
[code]
Nested error: org.exolab.castor.jdo.DuplicateIdentityException: Duplicate
identity found for object of type OBClinicalPresentation with identity : an
object with the same identity already exists in persistent storage
[/code]
Note that there is no [b]duplicated record[/b] exist at Database, but
JDO continues to throw DuplicateIdentityException until
I restart web application server.
Therefore, how can i solve this [b]problem/error/bug ??[/b] :(
Mapping file
[code]
<mapping>
<class name="OBDiseaseBean" identity="outbrRefNo" >
<cache-type type="none"/>
<description></description>
<map-to table="P_ID_OUTBR"/>
<field name="outbrRefNo" type="string">
<sql name="OUTBR_REF_NO" type="varchar"/>
</field>
<field name="obClinicalPresentationList"
type="OBClinicalPresentation" collection="arraylist" >
<sql many-key="OUTBR_REF_NO" />
</field>
</class>
<class name="OBClinicalPresentation" identity="outbrRefNo
symtmAndSignType" depends="OBDiseaseBean" >
<cache-type type="none"/>
<map-to table="P_ID_OUTBR_CLIN_PRES"/>
<field name="outbrRefNo" type="string">
<sql name="OUTBR_REF_NO" type="varchar"/>
</field>
<field name="symtmAndSignType" type="string">
<sql name="SYMTM_AND_SIGN_TYPE" type="varchar"/>
</field>
<field name="symtmAndSignCaseNo" type="string">
<sql name="SYMTM_AND_SIGN_CASE_NO" type="varchar"/>
</field>
<field name="symtmAndSignRemk" type="string">
<sql name="SYMTM_AND_SIGN_REMK" type="varchar"/>
</field>
</class>
</mapping>
[/code]
Sample coding
[code]
<[EMAIL PROTECTED] import="org.exolab.castor.jdo.*" %>
<[EMAIL PROTECTED] import="org.exolab.castor.mapping.*, java.util.*" %>
<%
JDO jdo = new JDO();
jdo.setConfiguration(
getClass().getResource("/cfg/PHIS-db.xml").toString());
jdo.setDatabaseName("PHIS");
QueryResults rs = null;
OQLQuery query = null;
Database db = null;
try {
db = jdo.getDatabase();
db.begin();
query = db.getOQLQuery("SELECT record FROM "+
"OBDiseaseBean record WHERE record.outbrRefNo = $1 ");
query.bind("KFO200300054");
rs = query.execute();
// Get the record
OBDiseaseBean bean = (OBDiseaseBean) rs.next();
OBClinicalPresentation cp = new OBClinicalPresentation();
cp.setOutbrRefNo("KFO200300054");
cp.setSymtmAndSignType("99");
// Add a child record
List list = bean.getObClinicalPresentationList();
list.add(cp);
// set one field over the size limit
StringBuffer b = new StringBuffer();
for( int i=0; i<500; i++ )
b.append(i);
bean.setRemk(b.toString());
// try to commmit
db.commit();
db.close();
out.println("Success");
} catch (Exception e) {
out.println(e.getMessage());
e.printStackTrace();
} finally {
if( rs != null )
rs.close();
if( query != null )
query.close();
if( db != null && db.isActive() )
db.rollback();
else if( db != null )
db.close();
}
%>
[/code]
Paul
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user