PAUL CHAN NCSI HK NCS wrote:
..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] :(
// 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();
}
Paul,
I believe that the DuplicateIdentityException is because the cache contains an item with the same identity because the failed commit is not properly rolled back. In the code aobve, the db.rollback() call should be taking place in the catch clause so that when an exception occurs during commit, the tx will be properly rolled back. The code above is calling db.rollback() in the finally clause and this is incorrect. Unless there's some other process calling db.close(), the db.isActive() call will always return true so it will try to call db.rollback() but there will be nothing to be rolled back. Try calling db.rollback() in the finally clause instead.
Bruce
--
perl -e 'print unpack("u30","<0G)[EMAIL PROTECTED]&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'
The Castor Project http://www.castor.org/
Apache Geronimo http://geronimo.apache.org/
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user
