Project

General

Profile

Download (19.7 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2008 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*/
6

    
7
package eu.etaxonomy.cdm.test.integration;
8

    
9
import java.sql.ResultSet;
10
import java.sql.SQLException;
11
import java.util.ArrayList;
12
import java.util.HashMap;
13
import java.util.List;
14
import java.util.Map;
15

    
16
import org.apache.log4j.Logger;
17
import org.springframework.transaction.TransactionStatus;
18

    
19
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
20
import eu.etaxonomy.cdm.common.AccountStore;
21
import eu.etaxonomy.cdm.database.CdmDataSource;
22
import eu.etaxonomy.cdm.database.DbSchemaValidation;
23
import eu.etaxonomy.cdm.database.ICdmDataSource;
24
import eu.etaxonomy.cdm.io.common.Source;
25
import eu.etaxonomy.cdm.model.agent.AgentBase;
26
import eu.etaxonomy.cdm.model.common.CdmBase;
27
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
28
import eu.etaxonomy.cdm.model.common.LanguageString;
29
import eu.etaxonomy.cdm.model.common.Representation;
30
import eu.etaxonomy.cdm.model.common.TermVocabulary;
31
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
32
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
33
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
34
import eu.etaxonomy.cdm.model.reference.Reference;
35

    
36
/**
37
 * @author a.babadshanjan
38
 * @since 15.09.2008
39
 */
40
public class TestCdmDbComparator {
41

    
42
	private static final String sourceDbOne = "cdm_test_jaxb";
43
	private static final String sourceDbTwo = "cdm_test_jaxb2";
44

    
45
	private static final ICdmDataSource sourceOne = TestCdmDbComparator.CDM_DB(sourceDbOne);
46
	private static final ICdmDataSource sourceTwo = TestCdmDbComparator.CDM_DB(sourceDbTwo);
47

    
48
	private static final String server = "192.168.2.10";
49
	private static final String username = "edit";
50

    
51
	public static ICdmDataSource CDM_DB(String dbname) {
52

    
53
	String password = AccountStore.readOrStorePassword(dbname, server, username, null);
54
	ICdmDataSource datasource = CdmDataSource.NewMySqlInstance(server, dbname, username, password);
55
	return datasource;
56
	}
57

    
58
    private final int MAX_ROWS = 60000;
59
    private final int MAX_TABLES = 150;
60

    
61
    private static final Logger logger = Logger.getLogger(TestCdmDbComparator.class);
62

    
63
	private static final String[] table_list = {
64
//			"Address",
65
			"Agent",
66
//			"Agent_Agent",
67
//			"Agent_Annotation",
68
//			"Agent_DefinedTermBase",
69
//			"Agent_Extension",
70
//			"Agent_InstitutionalMembership",
71
//			"Agent_Marker",
72
//			"Agent_Media",
73
//			"Agent_OriginalSource",
74
//			"Agent_Rights",
75
			"Annotation",
76
//			"CDM_VIEW",
77
//			"CDM_VIEW_CDM_VIEW",
78
//			"Collection",
79
//			"Collection_Annotation",
80
//			"Collection_Extension",
81
//			"Collection_Marker",
82
//			"Collection_Media",
83
//			"Collection_OriginalSource",
84
//			"Collection_Rights",
85
//			"Contact",
86
			"DefinedTermBase",
87
//			"DefinedTermBase_DefinedTermBase",
88
//			"DefinedTermBase_Media",
89
//			"DefinedTermBase_Representation",
90
//			"DefinedTermBase_TermVocabulary",
91
//			"DerivationEvent",
92
//			"DerivationEvent_Annotation",
93
//			"DerivationEvent_Marker",
94
			"DescriptionBase",
95
//			"DescriptionBase_Annotation",
96
//			"DescriptionBase_DefinedTermBase",
97
//			"DescriptionBase_DescriptionElementBase",
98
//			"DescriptionBase_Extension",
99
//			"DescriptionBase_Marker",
100
//			"DescriptionBase_OriginalSource",
101
//			"DescriptionBase_Rights",
102
			"DescriptionElementBase",
103
//			"DescriptionElementBase_Annotation",
104
//			"DescriptionElementBase_DefinedTermBase",
105
//			"DescriptionElementBase_LanguageString",
106
//			"DescriptionElementBase_Marker",
107
//			"DescriptionElementBase_Media",
108
//			"DescriptionElementBase_StatisticalMeasurementValue",
109
//			"DeterminationEvent",
110
//			"DeterminationEvent_Annotation",
111
//			"DeterminationEvent_Marker",
112
//			"Extension",
113
			"FeatureNode",
114
			"FeatureTree",
115
//			"FeatureTree_Representation",
116
//			"GatheringEvent",
117
//			"GatheringEvent_Annotation",
118
//			"GatheringEvent_Marker",
119
			"HomotypicalGroup",
120
//			"HomotypicalGroup_Annotation",
121
//			"HomotypicalGroup_Marker",
122
//			"HybridRelationship",
123
//			"HybridRelationship_Annotation",
124
//			"HybridRelationship_Marker",
125
//			"InstitutionalMembership",
126
			"LanguageString",
127
//			"Locus",
128
			"Marker",
129
			"Media",
130
			"MediaRepresentation",
131
			"MediaRepresentationPart",
132
//			"Media_Annotation",
133
//			"Media_Marker",
134
//			"Media_Rights",
135
//			"Media_Sequence",
136
//			"MediaKey_CoveredTaxon",
137
			"NameRelationship",
138
//			"NameRelationship_Annotation",
139
//			"NameRelationship_Marker",
140
			"NomenclaturalStatus",
141
//			"NomenclaturalStatus_Annotation",
142
//			"NomenclaturalStatus_Marker",
143
			"OriginalSource",
144
//			"OriginalSource_Annotation",
145
//			"OriginalSource_Marker",
146
//			"Person_Keyword",
147
			"Reference",
148
//			"ReferenceBase_Annotation",
149
//			"ReferenceBase_Extension",
150
//			"ReferenceBase_Marker",
151
//			"ReferenceBase_Media",
152
//			"ReferenceBase_OriginalSource",
153
//			"ReferenceBase_Rights",
154
//			"RelationshipTermBase_inverseRepresentation",
155
			"Representation",
156
//			"Rights",
157
//			"Sequence",
158
//			"Sequence_Annotation",
159
//			"Sequence_Extension",
160
//			"Sequence_Marker",
161
//			"Sequence_Media",
162
//			"Sequence_OriginalSource",
163
//			"Sequence_ReferenceBase",
164
//			"Sequence_Rights",
165
			"SpecimenOrObservationBase",
166
//			"SpecimenOrObservationBase_Annotation",
167
//			"SpecimenOrObservationBase_DerivationEvent",
168
//			"SpecimenOrObservationBase_Extension",
169
//			"SpecimenOrObservationBase_Marker",
170
//			"SpecimenOrObservationBase_Media",
171
//			"SpecimenOrObservationBase_OriginalSource",
172
//			"SpecimenOrObservationBase_Rights",
173
//			"StateData",
174
//			"StateData_DefinedTermBase",
175
//			"StatisticalMeasurementValue",
176
//			"StatisticalMeasurementValue_DefinedTermBase",
177
			"TaxonBase",
178
//			"TaxonBase_Annotation",
179
//			"TaxonBase_Extension",
180
//			"TaxonBase_Marker",
181
//			"TaxonBase_OriginalSource",
182
//			"TaxonBase_Rights",
183
			"TaxonName",
184
//			"TaxonName_Annotation",
185
//			"TaxonName_Extension",
186
//			"TaxonName_HybridRelationship",
187
//			"TaxonName_Marker",
188
//			"TaxonName_NomenclaturalStatus",
189
//			"TaxonName_OriginalSource",
190
//			"TaxonName_Rights",
191
//			"TaxonName_TypeDesignationBase",
192
			"TaxonRelationship",
193
//			"TaxonRelationship_Annotation",
194
//			"TaxonRelationship_Marker",
195
			"TermVocabulary",
196
//			"TermVocabulary_Representation",
197
			"TypeDesignationBase",
198
//			"TypeDesignationBase_Annotation",
199
//			"TypeDesignationBase_Marker",
200
	};
201

    
202
//	@Autowired
203
//	@Qualifier("cdmDao")
204
//	private ICdmEntityDao cdmDao;
205

    
206
//	@Autowired
207
//	protected void setDao(ICdmEntityDao dao) {
208
//		logger.debug("setting DAO");
209
//		this.cdmDao = dao;
210
//	}
211

    
212
//	@Autowired
213
//	private SessionFactory factory;
214
//
215
//	protected Session getSession(){
216
//	Session session = factory.getCurrentSession();
217
//	return session;
218
//}
219

    
220
//    public ResultSet getResultSet (String query){
221
//    	ResultSet rs;
222
//    	try {
223
//            this.getConnection(); //establish connection
224
//        	if (query == null){
225
//        		return null;
226
//        	}
227
//            mStmt = mConn.createStatement();
228
//            rs = mStmt.executeQuery(query);
229
//            return rs;
230
//        }catch(SQLException e){
231
//            logger.error("Problems when creating Resultset for query \n  " + query + " \n" + "Exception: " + e);
232
//            return null;
233
//        }
234
//    }
235

    
236
	private Map<String, List<String>> doLoadDataFromDb(String dbname, Source source) {
237

    
238
		Map<String, List<String>> dbTables = new HashMap<String, List<String>>();
239

    
240
		logger.info("Loading data from DB " + dbname);
241

    
242
		CdmApplicationController appCtr = null;
243

    
244

    
245
		String password = AccountStore.readOrStorePassword(dbname, server, username, null);
246

    
247
		DbSchemaValidation dbSchemaValidation = DbSchemaValidation.VALIDATE;
248
		ICdmDataSource datasource = CdmDataSource.NewMySqlInstance(server, dbname, username, password);
249
		appCtr = CdmApplicationController.NewInstance(datasource, dbSchemaValidation, true);
250

    
251

    
252
    	TransactionStatus txStatus = appCtr.startTransaction(true);
253

    
254
    	// get data from DB
255

    
256
    	try {
257

    
258
    		dbTables = retrieveAllTables(appCtr);
259

    
260
    	} catch (Exception e) {
261
    		logger.error("error setting data");
262
    		e.printStackTrace();
263
    	}
264
    	appCtr.commitTransaction(txStatus);
265
    	appCtr.close();
266

    
267
    	return dbTables;
268

    
269
    }
270

    
271
	private Map<String, List<CdmBase>> doLoadDataFromDb_(String dbname) {
272

    
273
		Map<String, List<CdmBase>> dbTables = new HashMap<String, List<CdmBase>>();
274

    
275
		logger.info("Loading data from DB " + dbname);
276

    
277
		CdmApplicationController appCtr = null;
278

    
279

    
280
		String password = AccountStore.readOrStorePassword(dbname, server, username, null);
281

    
282
		DbSchemaValidation dbSchemaValidation = DbSchemaValidation.VALIDATE;
283
		ICdmDataSource datasource = CdmDataSource.NewMySqlInstance(server, dbname, username, password);
284
		appCtr = CdmApplicationController.NewInstance(datasource, dbSchemaValidation, true);
285

    
286

    
287
    	TransactionStatus txStatus = appCtr.startTransaction(true);
288

    
289
    	// get data from DB
290

    
291
    	try {
292

    
293
    		dbTables = retrieveAllTables_(appCtr);
294

    
295
    	} catch (Exception e) {
296
    		logger.error("error setting data");
297
    		e.printStackTrace();
298
    	}
299
    	appCtr.commitTransaction(txStatus);
300
    	appCtr.close();
301

    
302
    	return dbTables;
303

    
304
    }
305

    
306
	private Map<String, List<String>> doLoadDataFromDb__(String dbname, Source source) {
307

    
308
		Map<String, List<String>> dbTables = new HashMap<String, List<String>>();
309

    
310
		logger.info("Loading data from DB " + dbname);
311

    
312
    	try {
313

    
314
    		dbTables = retrieveAllTables__(source);
315

    
316
    	} catch (Exception e) {
317
    		logger.error("error setting data");
318
    		e.printStackTrace();
319
    	}
320
    	return dbTables;
321

    
322
    }
323

    
324
    private Map<String, List<CdmBase>> retrieveAllTables_(CdmApplicationController appCtr) {
325

    
326
		Map<String, List<CdmBase>> tables_ = new HashMap<String, List<CdmBase>>(table_list.length);
327

    
328
		List<String> tableRows = new ArrayList<String>(MAX_ROWS);
329

    
330
		//List<Agent> agents = appCtr.getAgentService().getAllAgents(MAX_ROWS, 0);
331

    
332
		try {
333
			//get data from database
334
			for (int i = 0; i < table_list.length; i++) {
335

    
336
	    		logger.debug("Retrieving table '" + table_list[i] + "'");
337
	    		System.out.println("Retrieving table '" + table_list[i] + "'");
338

    
339
				List<CdmBase> rows = new ArrayList<CdmBase>(MAX_ROWS);
340

    
341
				rows = appCtr.getMainService().rows(table_list[i], MAX_ROWS, 0);
342

    
343
    			tables_.put(table_list[i], rows);
344

    
345
			}
346

    
347
		} catch (Exception e) {
348
    		logger.error("error retrieving data");
349
    		e.printStackTrace();
350
		}
351
//		return tables;
352
		return tables_;
353
    }
354

    
355
    private Map<String, List<String>> retrieveAllTables___(Source source) {
356

    
357
		Map<String, List<String>> tables = new HashMap<String, List<String>>(table_list.length);
358
		List<String> tableRows = new ArrayList<String>(MAX_ROWS);
359

    
360
		try {
361
			//get data from database
362
			for (int i = 0; i < table_list.length; i++) {
363

    
364
				List<String> rows = new ArrayList<String>(MAX_ROWS);
365

    
366
//					Session session = factory.getCurrentSession();
367

    
368
//					if ( sessionObject != null ) {
369
//						session.update(sessionObject);
370
//					}
371
//					Query query = session.createQuery("select term from DefinedTermBase term join fetch term.representations representation where representation.label = :label");
372
//					query.setParameter("label", queryString);
373

    
374
//					Query query = session.createQuery("select from " + table_list[i]);
375
//				    rows = query.list();
376

    
377
				//FIXME: NullPointerException (cdmDao is null)
378
				    //rows = cdmDao.list(MAX_ROWS, 0);
379
					tables.put(table_list[i], rows);
380

    
381
				}
382

    
383
		} catch (Exception e) {
384
    		logger.error("error retrieving data");
385
    		e.printStackTrace();
386
		}
387
		return tables;
388
    }
389

    
390
    private Map<String, List<String>> retrieveAllTables__(Source source) {
391

    
392
//		IImportConfigurator config = new BerlinModelImportConfigurator;
393
//		BerlinModelImportConfigurator bmiConfig = (BerlinModelImportConfigurator)config;
394
//		Source source = bmiConfig.getSource();
395
//		ResultSet rs = berlinModelSource.getResultSet();
396

    
397
		Map<String, List<String>> tables = new HashMap<String, List<String>>(table_list.length);
398
		List<String> tableRows = new ArrayList<String>(MAX_ROWS);
399

    
400
		try {
401
			//get data from database
402
			for (int i = 0; i < table_list.length; i++) {
403
				String strQuery =
404
					" SELECT * FROM " + table_list[i];
405
				logger.debug("SQL Statement: " +  strQuery);
406
				//ResultSet rs = berlinModelSource.getResultSet();
407
				//ResultSet rs = source.getResultSet(strQuery) ;
408
				ResultSet rs = source.getResultSet(strQuery) ;
409
				List<String> rows = new ArrayList<String>(MAX_ROWS);
410

    
411
				while (rs.next()) {
412
					rows.add(rs.toString());
413
				}
414
				tables.put(table_list[i], rows);
415
			}
416
		} catch (SQLException e) {
417
			logger.error("SQLException:" +  e);
418
		}
419
		return tables;
420
    }
421

    
422
    private Map<String, List<String>> retrieveAllTables(CdmApplicationController appCtr) {
423

    
424
		Map<String, List<String>> tables = new HashMap<String, List<String>>(table_list.length);
425

    
426
		List<String> agentTableContent = new ArrayList<String>(MAX_ROWS);
427
		List<? extends AgentBase> agents = appCtr.getAgentService().list(null,MAX_ROWS, 0,null,null);
428
		for (AgentBase agent: agents ) {
429
			//TODO: Want the entire row as string not just toString() of the object.
430
			agentTableContent.add(agent.toString());
431
		}
432
		tables.put("agents", agentTableContent);
433

    
434
		//List<Annotation> annotations = appCtr.getTermService().getAllAnnotations(MAX_ROWS, 0);
435

    
436
		List<String> definedTermBaseTableContent = new ArrayList<String>(MAX_ROWS);
437
		List<DefinedTermBase> definedTermBases = appCtr.getTermService().list(null,MAX_ROWS, 0,null,null);
438
		for (DefinedTermBase definedTermBase: definedTermBases ) {
439
			definedTermBaseTableContent.add(definedTermBase.toString());
440
		}
441
		tables.put("definedTermBases", definedTermBaseTableContent);
442

    
443
		//List<DescriptionBase> descriptionBases = appCtr.getDescriptionService().getAllDescriptionBases(MAX_ROWS, 0);
444
		//List<DescriptionElementBase> descriptionElementBases = appCtr.getDescriptionService().getAllDescriptionElementBases(MAX_ROWS, 0);
445
		//List<HomotypicalGroup> homotypicalGroups = appCtr.getNameService().getAllHomotypicalGroups(MAX_ROWS, 0);
446
		List<LanguageString> languageStrings = appCtr.getTermService().getAllLanguageStrings(MAX_ROWS, 0);
447
		//List<Marker> markers = appCtr.getTermService().getAllMarkers(MAX_ROWS, 0);
448
		//List<NameRelationship> nameRelationships = appCtr.getNameService().getAllNameRelationships(MAX_ROWS, 0);
449
		List<NomenclaturalStatus> nomenclaturalStatus = appCtr.getNameService().getAllNomenclaturalStatus(MAX_ROWS, 0);
450
		//List<OriginalSource> originalSources = appCtr.getNameService().getAllOriginalSources(MAX_ROWS, 0);
451
		List<Reference> references = appCtr.getReferenceService().list(null,MAX_ROWS, 0,null,null);
452
		List<Representation> representations = appCtr.getTermService().getAllRepresentations(MAX_ROWS, 0);
453
		List<SpecimenOrObservationBase> specimenOrObservationBases = appCtr.getOccurrenceService().list(null,MAX_ROWS, 0,null,null);
454
//		List<TaxonBase> taxonBases = appCtr.getTaxonService().getAllTaxa(MAX_ROWS, 0);
455
//		List<TaxonName> taxonNames = appCtr.getNameService().getAllNames(MAX_ROWS, 0);
456
		//List<TaxonRelationship> taxonRelationships = appCtr.getTaxonService().getAllTaxonRelationships(MAX_ROWS, 0);
457
		List<TermVocabulary> termVocabularies = appCtr.getVocabularyService().list(null,MAX_ROWS, 0,null,null);
458
		List<TypeDesignationBase> typeDesignationBases = appCtr.getNameService().getAllTypeDesignations(MAX_ROWS, 0);
459

    
460
		return tables;
461
	}
462

    
463
     private void compareTables(String tableName, List<CdmBase> tablesDbOne, List<CdmBase> tablesDbTwo) {
464

    
465
		int tableOneSize = tablesDbOne.size();
466
		int tableTwoSize = tablesDbTwo.size();
467
		int tableMinSize = 0;
468
		int tableMaxSize = 0;
469

    
470
		if (tableOneSize != tableTwoSize) {
471
			logger.warn("Table '" + tableName + "', Rows differ: " + tablesDbOne.size() + ", " + tablesDbTwo.size());
472
            tableMinSize = Math.min(tableOneSize, tableTwoSize);
473
            tableMaxSize = Math.max(tableOneSize, tableTwoSize);
474
		} else {
475
			logger.info("Table '" + tableName + "': " + tablesDbOne.size());
476
		}
477

    
478
		int different = 0;
479

    
480
		try {
481
		for (int i = 0; i < tableMinSize; i++) {
482

    
483
			CdmBase obj1 = tablesDbOne.get(i);
484
			CdmBase obj2 = tablesDbTwo.get(i);
485

    
486
			// This compares only whether both tables contain the same objects.
487
			// It doesn't check whether all field values are the same.
488
			logger.debug("Row # " + i + ":");
489
			if (obj1.equals(obj2) != true) {
490
				different++;
491
				logger.debug("Table 1 = " + obj1);
492
				logger.debug("Table 2 = " + obj2);
493
			} else {
494
				logger.debug("Entry = " + obj1);
495
			}
496
		}
497
		if (different > 0) {
498
			logger.info("# Rows identical: " + (tableMaxSize - different));
499
			logger.warn("# Rows different: " + different);
500
		}
501
		} catch (org.hibernate.LazyInitializationException e){
502
			logger.error("LazyInitializationException");
503
		}
504
	}
505

    
506
    	private void doCompareDatabases(Map<String, List<CdmBase>> tablesDbOne, Map<String, List<CdmBase>> tablesDbTwo) {
507
//        public void doCompareDatabases(Map<String, List<String>> tablesDbOne, Map<String, List<String>> tablesDbTwo) {
508

    
509
		logger.debug("# Tables in DB 1: " + tablesDbOne.size());
510
		logger.debug("# Tables in DB 2: " + tablesDbTwo.size());
511

    
512
		for (String tableName: tablesDbOne.keySet()) {
513

    
514
			logger.info("Comparing table '" + tableName + "'");
515

    
516
//			List<String> dbOneTableRows = new ArrayList<String>();
517
//			List<String> dbTwoTableRows = new ArrayList<String>();
518
			List<CdmBase> dbOneTableRows = new ArrayList<CdmBase>();
519
			List<CdmBase> dbTwoTableRows = new ArrayList<CdmBase>();
520

    
521
			dbOneTableRows = tablesDbOne.get(tableName);
522
			dbTwoTableRows = tablesDbTwo.get(tableName);
523

    
524
//			Collections.sort(dbOneTableRows);
525
//			Collections.sort(dbTwoTableRows);
526

    
527
			int different = 0;
528
			int tableSize = dbOneTableRows.size();
529

    
530
			for (int i = 0; i < tableSize; i++) {
531

    
532
//				String str1 = dbOneTableRows.get(i);
533
//				String str2 = dbTwoTableRows.get(i);
534
				CdmBase str1 = dbOneTableRows.get(i);
535
				CdmBase str2 = dbTwoTableRows.get(i);
536

    
537
				if (str1.equals(str2) != true) {
538

    
539
					different++;
540
					logger.debug("Rows differ:");
541
					logger.debug("Table 1 Row = " + str1);
542
					logger.debug("Table 2 Row = " + str2);
543

    
544
				}
545
				i++;
546
			}
547
			if (different > 0) {
548
				logger.info("Compared table '" + tableName + "':");
549
				logger.info("# Rows total: " + tableSize);
550
				logger.info("# Rows identical: " + (tableSize - different));
551
				logger.warn("# Rows different: " + different);
552
			}
553
		}
554
		logger.info("End database comparison");
555
	}
556

    
557
//	private void test_(){
558
//
559
//		Map<String, List<CdmBase>> tablesDbOne = doLoadDataFromDb_(sourceDbOne);
560
//		Map<String, List<CdmBase>> tablesDbTwo = doLoadDataFromDb_(sourceDbTwo);
561
//	    doCompareDatabases(tablesDbOne, tablesDbTwo);
562
//
563
//	}
564

    
565
	private void test(){
566

    
567
		CdmApplicationController appCtrOne = null;
568
		CdmApplicationController appCtrTwo = null;
569
		logger.info("Comparing '" + sourceDbOne + "' and '" + sourceDbTwo + "'");
570

    
571
		try {
572
			appCtrOne = CdmApplicationController.NewInstance(sourceOne, DbSchemaValidation.VALIDATE, true);
573
			appCtrTwo = CdmApplicationController.NewInstance(sourceTwo, DbSchemaValidation.VALIDATE, true);
574

    
575
		} catch (Exception e) {
576
			logger.error("Error creating application controller");
577
			e.printStackTrace();
578
			System.exit(1);
579
		}
580

    
581
		try {
582
			//get data from database
583
	    	TransactionStatus txStatOne = appCtrOne.startTransaction(true);
584
	    	TransactionStatus txStatTwo = appCtrTwo.startTransaction(true);
585
			for (int i = 0; i < table_list.length; i++) {
586

    
587
				List<CdmBase> rowsDbOne = new ArrayList<CdmBase>(MAX_ROWS);
588
				List<CdmBase> rowsDbTwo = new ArrayList<CdmBase>(MAX_ROWS);
589
				rowsDbOne = appCtrOne.getMainService().rows(table_list[i], MAX_ROWS, 0);
590
				rowsDbTwo = appCtrTwo.getMainService().rows(table_list[i], MAX_ROWS, 0);
591
				compareTables(table_list[i], rowsDbOne, rowsDbTwo);
592
			}
593
	    	appCtrTwo.commitTransaction(txStatTwo);
594
	    	appCtrOne.commitTransaction(txStatOne);
595
	    	//java.lang.IllegalStateException: Cannot deactivate transaction synchronization - not active
596
	    	appCtrOne.close();
597
	    	appCtrTwo.close();
598
			logger.info("End database comparison");
599

    
600
		} catch (Exception e) {
601
    		logger.error("Error retrieving or comparing data");
602
    		e.printStackTrace();
603
		}
604
	}
605

    
606
	/**
607
	 * @param args
608
	 */
609
	public static void  main(String[] args) {
610
		TestCdmDbComparator diff = new TestCdmDbComparator();
611
    	diff.test();
612
	}
613
}
    (1-1/1)