Hello,
I'm using Firefox 19.0.1, SmartGWT 3.1 and GWT SDK 2.4.0.
I would like to insert data into 3 different database tables, in one transaction. In case a insert operation goes wrong, I want to do a complete rollback over all (3) tables.
I tried already several ways, but nothing works correctly. If the second insert operation goes wrong, the first operation is still saved at the database.
I'm using the smartgwt power edition, ass I can see in my pom.xml file:
I set autoJoinTransaction true, at the server.properties:
My DMI class lock as following, for the add operation:
(I debugged, that rpcManager.getTransactionPolicy() is 0)
I'm using the same DSRequest for all 3 operations (3 different database tables, 3 different datasources).
As I see at the console, I'm using the same transaction for all operations, but rollback is still not happening.
Console:
Do you have any idea, what I'm doing wrong?
I'm using Firefox 19.0.1, SmartGWT 3.1 and GWT SDK 2.4.0.
I would like to insert data into 3 different database tables, in one transaction. In case a insert operation goes wrong, I want to do a complete rollback over all (3) tables.
I tried already several ways, but nothing works correctly. If the second insert operation goes wrong, the first operation is still saved at the database.
I'm using the smartgwt power edition, ass I can see in my pom.xml file:
Code:
...
<dependency>
<groupId>com.isomorphic</groupId>
<artifactId>smartgwt-power</artifactId>
<version>${smartgwt.version}</version>
</dependency>
....
Code:
webRoot: __AUTODETECT__ gwtModuleName: Rim isomorphicPathRootRelative: $gwtModuleName/sc project.datasources: $webRoot/ds, $webRoot/ds/administration, $webRoot/ds/controlling, $webRoot/ds/calcdata, $webRoot/ds/calcdata/precalc, $webRoot/ds/calculation, $webRoot/ds/masterdata, $webRoot/ds/portfolio, $webRoot/shared/ds, $webRoot/ds/portfolio/brochuremapping project.ui: $webRoot/shared/ui project.apps: $webRoot/shared/app sql.RTGRIM.driver.context: sql.RTGRIM.database.type: sqlserver sql.RTGRIM.interface.type: driverManager sql.RTGRIM.driver.serverName: Embedded in JDBC URL sql.RTGRIM.driver.url: .... sql.RTGRIM.driver: com.microsoft.sqlserver.jdbc.SQLServerDriver sql.RTGRIM.interface.credentialsInURL: true sql.RTGRIM.driver.networkProtocol: tcp sql.RTGRIM.driver.driverType: thin sql.RTGRIM.autoJoinTransactions: true
(I debugged, that rpcManager.getTransactionPolicy() is 0)
Code:
@SuppressWarnings("unchecked")
public DSResponse add(DSRequest dsRequest, HttpServletRequest request) {
Long brandID = (Long) dsRequest.getValues().get(Cols.BRAND_TO_BROCHURE_MAPPING_BRAND_ID);
Long brochureTypeID = (Long) dsRequest.getValues().get(Cols.BRAND_TO_BROCHURE_MAPPING_BROCHURE_TYPE_ID);
Long calculationTypeID = (Long) dsRequest.getValues().get(Cols.BRAND_TO_BROCHURE_MAPPING_CALCULATION_ID);
Long calculationBrandID = (Long) dsRequest.getValues().get(Cols.BRAND_TO_BROCHURE_MAPPING_CALCULATION_BRAND_ID);
Long calculationBrochureTypeID = (Long) dsRequest.getValues().get(
Cols.BRAND_TO_BROCHURE_MAPPING_CALCULATION_BROCHURE_ID);
String hotelID = (String) dsRequest.getValues().get(Cols.HOTEL_MAPPING_HOTEL_ID);
Long seasonID = (Long) dsRequest.getValues().get(Cols.HOTEL_MAPPING_SEASON_ID);
// set hotel to brand values
Map<String, Object> hotelToBrandValues = getHotelToBrandValue(hotelID, brandID, seasonID);
dsRequest.setValues(hotelToBrandValues);
dsRequest.setDataSourceName(DataSourceIDs.HOTEL_TO_BRAND);
DSResponse response;
try {
// save hotel to brands
response = dsRequest.execute();
Integer hotelToBrandID = 55; // (Integer)
// response.getFieldValue(Cols.HOTEL_TO_BRAND_ID);
// set hotel to brand to brochure type
Map<String, Object> hotelToBrandToBrochureTypeValues = getHotelToBrandToBrochureTypeValue(hotelToBrandID,
brochureTypeID);
dsRequest.setValues(hotelToBrandToBrochureTypeValues);
dsRequest.setDataSourceName(DataSourceIDs.HOTEL_TO_BRAND_TO_BROCHURE_TYPE);
try {
// save hotel to brands to brochure type
response = dsRequest.execute();
Integer hotelToBrandToBrochureTypeID = (Integer) response
.getFieldValue(Cols.HOTEL_TO_BRAND_TO_BROCHURE_ID);
// set calculationType for brochure values
Map<String, Object> calculationTypeForBrochureValues = getCalculationTypeForBrochureValues(
calculationTypeID, hotelToBrandToBrochureTypeID, calculationBrandID, calculationBrochureTypeID);
dsRequest.setValues(calculationTypeForBrochureValues);
dsRequest.setDataSourceName(DataSourceIDs.CALCULATION_TYPE_FOR_BROCHURE);
try {
// save calculationType for brochure values
response = dsRequest.execute();
} catch (Exception e) {
LOGGER.error(
"An Exception occurred while trying to add new brand and brochure mappings - Step: save calculationTypeForBrochure.",
e);
return new DSResponse(
"Ein Fehler ist beim Speichern neuer Hotelzuordnungen aufgetreten. Schritt: speichere Kalkulationstyp für Codierungstyp");
}
} catch (Exception e) {
LOGGER.error(
"An Exception occurred while trying to add new brand and brochure mappings - Step: save hotelToBrandToBrochureType.",
e);
return new DSResponse(
"Ein Fehler ist beim Speichern neuer Hotelzuordnungen aufgetreten. Schritt: speichere Hotel zu Marke zu Codierungstyp");
}
} catch (Exception e) {
LOGGER.error(
"An Exception occurred while trying to add new brand and brochure mappings - Step: save hotelToBrand.",
e);
return new DSResponse(
"Ein Fehler ist beim Speichern neuer Hotelzuordnungen aufgetreten. Schritt: speichere Hotel zu Marke");
}
return response;
}
I'm using the same DSRequest for all 3 operations (3 different database tables, 3 different datasources).
As I see at the console, I'm using the same transaction for all operations, but rollback is still not happening.
Console:
Code:
=== 2013-12-10 16:31:54,591 [0-13] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
=== 2013-12-10 16:31:54,591 [0-13] DEBUG DeclarativeSecurity - DataSource HotelToBrand is not in the pre-checked list, processing...
=== 2013-12-10 16:31:54,591 [0-13] DEBUG AppBase - [builtinApplication.BrandAndBrochureMapping_add] No userTypes defined, allowing anyone access to all operations for this application
=== 2013-12-10 16:31:54,592 [0-13] DEBUG AppBase - [builtinApplication.BrandAndBrochureMapping_add] No public zero-argument method named '_BrandAndBrochureMapping_add' found, performing generic datasource operation
=== 2013-12-10 16:31:54,592 [0-13] INFO SQLDataSource - [builtinApplication.BrandAndBrochureMapping_add] Performing add operation with
criteria: {CalculationBrandID:9,CalculationBrochureTypeID:8,BrandID:9,BrochureTypeID:7,CalculationRelationTypeID:4,HotelID:"AMT013083I",SeasonID:2} values: {BrandID:9,HotelID:"AMT013083I",SeasonID:2}
=== 2013-12-10 16:31:54,592 [0-13] DEBUG SQLValuesClause - [builtinApplication.BrandAndBrochureMapping_add] Sequences: {ID=__default}
=== 2013-12-10 16:31:54,594 [0-13] DEBUG SQLConnectionManager - [builtinApplication.BrandAndBrochureMapping_add] Returning borrowed connection '763698666'
=== 2013-12-10 16:31:54,594 [0-13] DEBUG SQLTransaction - [builtinApplication.BrandAndBrochureMapping_add] Started new RTGRIM transaction "763698666"
=== 2013-12-10 16:31:54,595 [0-13] DEBUG SQLDriver - [builtinApplication.BrandAndBrochureMapping_add] About to execute SQL update in 'RTGRIM' using connection'763698666'
=== 2013-12-10 16:31:54,595 [0-13] INFO SQLDriver - [builtinApplication.BrandAndBrochureMapping_add] Executing SQL update on 'RTGRIM': INSERT INTO dbo.HimKalk_HotelToBrand (BrandID, HotelID, SeasonID) VALUES (9, 'AMT013083I', 2)
=== 2013-12-10 16:31:54,597 [0-13] DEBUG SQLDataSource - [builtinApplication.BrandAndBrochureMapping_add] add operation affected 1 rows
=== 2013-12-10 16:31:54,597 [0-13] INFO SQLDataSource - [builtinApplication.BrandAndBrochureMapping_add] primaryKeys: {ID=18}
=== 2013-12-10 16:31:54,597 [0-13] DEBUG DeclarativeSecurity - [builtinApplication.BrandAndBrochureMapping_add] Processing security checks for DataSource null, field null
=== 2013-12-10 16:31:54,597 [0-13] DEBUG DeclarativeSecurity - [builtinApplication.BrandAndBrochureMapping_add] DataSource HotelToBrand is not in the pre-checked list, processing...
=== 2013-12-10 16:31:54,598 [0-13] DEBUG AppBase - [builtinApplication.BrandAndBrochureMapping_add, builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application
=== 2013-12-10 16:31:54,598 [0-13] DEBUG AppBase - [builtinApplication.BrandAndBrochureMapping_add, builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation
=== 2013-12-10 16:31:54,598 [0-13] INFO SQLDataSource - [builtinApplication.BrandAndBrochureMapping_add, builtinApplication.null] Performing fetch operation with
criteria: {ID:18} values: {ID:18}
=== 2013-12-10 16:31:54,599 [0-13] INFO SQLDataSource - [builtinApplication.BrandAndBrochureMapping_add, builtinApplication.null] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause
=== 2013-12-10 16:31:54,600 [0-13] INFO SQLDataSource - [builtinApplication.BrandAndBrochureMapping_add, builtinApplication.null] Executing SQL query on 'RTGRIM': SELECT HimKalk_HotelToBrand.BrandID, HimKalk_HotelToBrand.HotelID, HimKalk_HotelToBrand.ID, HimKalk_HotelToBrand.SeasonID FROM dbo.HimKalk_HotelToBrand WHERE (HimKalk_HotelToBrand.ID=18)
=== 2013-12-10 16:31:54,600 [0-13] DEBUG SQLDriver - [builtinApplication.BrandAndBrochureMapping_add, builtinApplication.null] About to execute SQL query in 'RTGRIM' using connection '763698666'
=== 2013-12-10 16:31:54,600 [0-13] INFO SQLDriver - [builtinApplication.BrandAndBrochureMapping_add, builtinApplication.null] Executing SQL query on 'RTGRIM': SELECT HimKalk_HotelToBrand.BrandID, HimKalk_HotelToBrand.HotelID, HimKalk_HotelToBrand.ID, HimKalk_HotelToBrand.SeasonID FROM dbo.HimKalk_HotelToBrand WHERE (HimKalk_HotelToBrand.ID=18)
=== 2013-12-10 16:31:54,603 [0-13] INFO DSResponse - [builtinApplication.BrandAndBrochureMapping_add, builtinApplication.null] DSResponse: List with 1 items
=== 2013-12-10 16:31:54,603 [0-13] INFO DSResponse - [builtinApplication.BrandAndBrochureMapping_add] DSResponse: List with 1 items
=== 2013-12-10 16:32:08,903 [0-13] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
=== 2013-12-10 16:32:08,903 [0-13] DEBUG DeclarativeSecurity - DataSource HotelToBrandToBrochureType is not in the pre-checked list, processing...
=== 2013-12-10 16:32:08,903 [0-13] DEBUG AppBase - [builtinApplication.BrandAndBrochureMapping_add] No userTypes defined, allowing anyone access to all operations for this application
=== 2013-12-10 16:32:08,904 [0-13] DEBUG AppBase - [builtinApplication.BrandAndBrochureMapping_add] No public zero-argument method named '_BrandAndBrochureMapping_add' found, performing generic datasource operation
=== 2013-12-10 16:32:08,904 [0-13] DEBUG DSRequest - [builtinApplication.BrandAndBrochureMapping_add] Clobbering existing FreeResourcesHandler of type 'com.isomorphic.sql.SQLDataSource' with a 'com.isomorphic.sql.SQLDataSource'
=== 2013-12-10 16:32:08,904 [0-13] INFO SQLDataSource - [builtinApplication.BrandAndBrochureMapping_add] Performing add operation with
criteria: {CalculationBrandID:9,CalculationBrochureTypeID:8,BrandID:9,BrochureTypeID:7,CalculationRelationTypeID:4,HotelID:"AMT013083I",SeasonID:2} values: {HotelToBrandID:55,BrochureTypeID:7}
=== 2013-12-10 16:32:08,904 [0-13] DEBUG SQLValuesClause - [builtinApplication.BrandAndBrochureMapping_add] Sequences: {ID=__default}
=== 2013-12-10 16:32:08,905 [0-13] DEBUG SQLDriver - [builtinApplication.BrandAndBrochureMapping_add] About to execute SQL update in 'RTGRIM' using connection'763698666'
=== 2013-12-10 16:32:08,905 [0-13] INFO SQLDriver - [builtinApplication.BrandAndBrochureMapping_add] Executing SQL update on 'RTGRIM': INSERT INTO dbo.HimKalk_HotelToBrandToBrochureType (BrochureTypeID, HotelToBrandID) VALUES (7, 55)
=== 2013-12-10 16:32:08,910 [0-13] DEBUG SQLDriver - [builtinApplication.BrandAndBrochureMapping_add] FAILED to execute SQL update in 'RTGRIM' using connection'763698666'
Comment