All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jodd.db.jtx.JtxDbUtil Maven / Gradle / Ivy

Go to download

Jodd DB is efficient and thin database facade; DbOom is convenient database object mapper.

There is a newer version: 6.0.0
Show newest version
// Copyright (c) 2003-2012, Jodd Team (jodd.org). All Rights Reserved.

package jodd.db.jtx;

import jodd.db.DbTransactionMode;
import jodd.jtx.JtxTransactionMode;

/**
 * Helpers for jtx db.
 */
public class JtxDbUtil {

	/**
	 * Convert JTX transaction mode to DB transaction mode.
	 */
	public static DbTransactionMode convertToDbMode(JtxTransactionMode txMode) {
		int isolation = -1;
		switch (txMode.getIsolationLevel()) {
			case ISOLATION_DEFAULT: isolation = DbTransactionMode.ISOLATION_DEFAULT; break;
			case ISOLATION_NONE: isolation = DbTransactionMode.ISOLATION_NONE; break;
			case ISOLATION_READ_COMMITTED: isolation = DbTransactionMode.ISOLATION_READ_COMMITTED; break;
			case ISOLATION_READ_UNCOMMITTED: isolation = DbTransactionMode.ISOLATION_READ_UNCOMMITTED; break;
			case ISOLATION_REPEATABLE_READ: isolation = DbTransactionMode.ISOLATION_REPEATABLE_READ; break;
			case ISOLATION_SERIALIZABLE: isolation = DbTransactionMode.ISOLATION_SERIALIZABLE; break;
		}
		DbTransactionMode result = new DbTransactionMode();
		result.setIsolation(isolation);
		result.setReadOnly(txMode.isReadOnly());
		return result;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy