Unit Of work upgrade issue 9.0.3->10.1.4
402027May 31 2006 — edited Apr 17 2007Hi,
I recently upgraded from Toplink 9.0.3 to Toplink 10.1.3. I changed nothing in my code except the deployment java descriptor to use the new classes implemented instead of the deprecated classes. I also used the new TypeConversions for my CLOBs and BLOBs. Everything worked fine in my unit tests but then once I'd deployed the application into production my users kept on getting an irregular error. I can't reproduce the error myself as its so irregular. I have tracked it down to when my users enter a clob/blob of data into the database. The strange thing is that I close the unit of work and even test if its still active and I get false as an answer but somehow when I execute on the session it uses the UnitOfWork which has expired for some reason. I have checked my code and can't find anything that is changed.
All my code basically always checks whether a UOW is active and if it is not it uses the session to execute the query. Here is a java code extract:
if ( isTxActive() ) {
objectResults = uow.readAllObjects(Class.forName(objectType), expression);
objectResults = uow.registerAllObjects(objectResults);
} else
objectResults = session.readAllObjects(Class.forName(objectType), expression);
I use the following setup:
- Oracle 9i database
- JDK 1.5
- Oracle JDBC Thin Driver version - 10.1.0.2.0
I have tried the following:
- Specified my OraclePlatform i.e. Oracle9Platform
- Tried playing around with the SQL String binding
- Double checked my type conversions
Below is my logfile output and also my login parameters and extract of one of my descriptors.
Any help would be appreciated.
I was wondering if there is a timeout on the UnitOfWork or if its multi-threaded hence my application doesn't wait for my CLOB to finish being written?
Thanks in advance,
Paula
2006-05-24 11:32:05,870 (toplink) DEBUG - execute_query
2006-05-24 11:32:05,871 (toplink) DEBUG - execute_query
2006-05-24 11:32:05,871 (toplink) DEBUG - DatabaseAccessor(connected)--INSERT INTO chebi.AUTOGEN_STRUCTURES (ID, STRUCTURE_ID) VALUES (12599, 19211)
2006-05-24 11:32:05,874 (toplink) DEBUG - execute_query
2006-05-24 11:32:05,875 (toplink) DEBUG - execute_query
2006-05-24 11:32:05,875 (toplink) DEBUG - DatabaseAccessor(connected)--INSERT INTO chebi.DEFAULT_STRUCTURES (ID, STRUCTURE_ID) VALUES (6968, 19213)
2006-05-24 11:32:05,885 (toplink) DEBUG - execute_query
2006-05-24 11:32:05,886 (toplink) DEBUG - execute_query
2006-05-24 11:32:05,886 (toplink) DEBUG - DatabaseAccessor(connected)--INSERT INTO chebi.IMAGE_PRECOMPUTES (ID, FORMAT, IMAGE, STRUCTURE_ID) VALUES (7208, 'p
ng', empty_blob(), 19213)
2006-05-24 11:32:05,898 (toplink) DEBUG - DatabaseAccessor(connected)--SELECT IMAGE FROM chebi.IMAGE_PRECOMPUTES WHERE (ID = 7208) FOR UPDATE
2006-05-24 11:32:05,905 (toplink) DEBUG - write_BLOB
2006-05-24 11:32:05,905 (toplink) DEBUG - DatabaseAccessor(connected)--commit_transaction
2006-05-24 11:32:05,915 (toplink) DEBUG - end_unit_of_work_commit
2006-05-24 11:32:05,915 (toplink) DEBUG - release_unit_of_work
2006-05-24 11:32:05,915 (controller.DatabaseAction) DEBUG - ModifyStructureAction_postprocess: empty method
2006-05-24 11:32:05,915 (controller.DatabaseAction) DEBUG - ModifyStructureAction_findSuccess: start method
2006-05-24 11:32:05,915 (controller.DatabaseAction) DEBUG - ModifyStructureAction_findSuccess: preparing forward ( set form | release lock | reset token )
2006-05-24 11:32:05,915 (controller.DatabaseAction) DEBUG - ModifyStructureAction_findSuccess: forward to searchId
2006-05-24 11:32:05,917 (toplink.ToplinkDAO) DEBUG - find(String objectType, String col, String val): start method
2006-05-24 11:32:05,917 (toplink.ToplinkDAO) DEBUG - isTxActive: start method
2006-05-24 11:32:05,917 (toplink.ToplinkDAO) DEBUG - isTxActive: false
2006-05-24 11:32:05,917 (toplink) DEBUG - execute_query
2006-05-24 11:32:05,917 (toplink) DEBUG - DatabaseAccessor(connected)--SELECT ID, SOURCE, ASCII_NAME, STATUS, CREATED_ON, DEFINITION, MODIFIED_BY, NAME, MODI
FIED_ON, CREATED_BY, CHEBI_ACCESSION, MERGE_TYPE, PARENT_ID FROM chebi.COMPOUNDS WHERE (ID LIKE 6126)
2006-05-24 11:32:05,980 (toplink) DEBUG - execute_query
2006-05-24 11:32:06,046 (handlers.DefaultExceptionHandler) ERROR - Exception [TOPLINK-6027] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): ora
cle.toplink.exceptions.QueryException
Exception Description: Query sent to a unactivated UnitOfWork.
Query: ReadAllQuery(uk.ac.ebi.chebi.compounds.model.CompoundName)
uk.ac.ebi.chebi.compounds.application.curator2.exceptions.BeanUtilException: Exception [TOPLINK-6027] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060
118)): oracle.toplink.exceptions.QueryException
Exception Description: Query sent to a unactivated UnitOfWork.
Query: ReadAllQuery(uk.ac.ebi.chebi.compounds.model.CompoundName)
LOGIN:
public void applyLogin () {
DatabaseLogin login = new DatabaseLogin();
login.usePlatform( ToplinkDeploymentHelper.getPlatform(options) );
login.setDriverClassName(options.getDriver());
login.setConnectionString(options.getDbUrl());
login.setUserName(options.getDbUserName());
login.setPassword(options.getDbPassword());
// Configuration properties.
// login.setUsesNativeSequencing(true);
// login.setSequencePreallocationSize(100);
// Replace with
login.setDefaultSequence(new NativeSequence("", 1));
login.setShouldBindAllParameters(false);
login.setShouldCacheAllStatements(false);
// String binding is used when the SQL string might be too large to
// incorporate in the Oracle Thin driver. It will give an exception of string literal
// too long. Hence string binding should be turned on for long strings such
// as long names
login.setUsesStringBinding(true);
login.useStringBinding( );
// This specifies for large bytes to use binding to prevent the same problem
// above and improve performance
login.setUsesByteArrayBinding(true);
if ( login.shouldUseByteArrayBinding() ) { // Can only be used with binding.
login.setUsesStreamsForBinding(false);
}
login.setShouldForceFieldNamesToUpperCase(false);
login.setShouldOptimizeDataConversion(true);
login.setShouldTrimStrings(true);
login.setUsesBatchWriting(false);
if ( login.shouldUseBatchWriting() ) { // Can only be used with batch writing.
login.setUsesJDBCBatchWriting(true);
}
login.setUsesExternalConnectionPooling(false);
login.setUsesExternalTransactionController(false);
setLogin(login);
}
ImagePrecompute descriptor:
public ClassDescriptor buildImagePrecomputeDescriptor () {
ClassDescriptor descriptor = new ClassDescriptor();
descriptor.setJavaClass(uk.ac.ebi.chebi.compounds.model.ImagePrecompute.class);
descriptor.addTableName( options.getDbSchemaName().concat(".").concat("IMAGE_PRECOMPUTES") );
descriptor.addPrimaryKeyFieldName("IMAGE_PRECOMPUTES.ID");
descriptor.useSoftCacheWeakIdentityMap();
descriptor.setIdentityMapSize(50);
descriptor.useRemoteNoIdentityMap();
//descriptor.useRemoteSoftCacheWeakIdentityMap();
//descriptor.setRemoteIdentityMapSize(100);
descriptor.setSequenceNumberFieldName("IMAGE_PRECOMPUTES.ID");
descriptor.setSequenceNumberName("image_precompute_sequence");
descriptor.setAlias("ImagePrecomputes");
descriptor.getQueryManager().checkCacheForDoesExist();
DirectToFieldMapping idMapping = new DirectToFieldMapping();
idMapping.setAttributeName("id");
idMapping.setFieldName("IMAGE_PRECOMPUTES.ID");
descriptor.addMapping(idMapping);
OneToOneMapping structureMapping = new OneToOneMapping();
structureMapping.setAttributeName("structure");
structureMapping.setReferenceClass(uk.ac.ebi.chebi.compounds.model.Structure.class);
structureMapping.dontUseIndirection();
structureMapping.addForeignKeyFieldName("IMAGE_PRECOMPUTES.STRUCTURE_ID", "STRUCTURES.ID");
descriptor.addMapping(structureMapping);
DirectToFieldMapping imageMapping = new DirectToFieldMapping();
imageMapping.setAttributeName("image");
imageMapping.setFieldName("IMAGE_PRECOMPUTES.IMAGE");
TypeConversionConverter imageMappingConverter = new TypeConversionConverter(imageMapping);
imageMappingConverter.setObjectClass(byte[].class);
imageMappingConverter.setDataClass(java.sql.Blob.class);
imageMapping.setConverter(imageMappingConverter);
descriptor.addMapping(imageMapping);
DirectToFieldMapping formatMapping = new DirectToFieldMapping();
formatMapping.setAttributeName("format");
formatMapping.setFieldName("IMAGE_PRECOMPUTES.FORMAT");
descriptor.addMapping(formatMapping);
return descriptor;
}
Message was edited by:
pmatos