Java EE (9) -- JDBC & JTA

本文深入探讨了数据库连接的隔离级别,包括 TRANSACTION_NONE 到 TRANSACTION_SERIALIZABLE 的各种选项,以及 Javax.ejb.TransactionAttributeType 枚举中定义的企业级Bean事务属性,如 MANDATORY、NEVER、NOT_SUPPORTED、REQUIRED 和 REQUIRES_NEW。文章旨在为开发者提供全面理解事务管理和企业应用上下文中的事务处理策略。

Connection接口中定义了5中隔离级别常量

Connection.TRANSACTION_NONE  --  不支持事务

Connection.TRANSACTION_READ_UNCOMMITTED  -- 脏读(事务回滚造成别的事务读取到的数据不准确),不可重复读和幻读均可发生

Connection.TRANSACTION_READ_COMMITTED  -- 不可重复读和幻读均可发生

Connection.TRANSACTION_REPEATABLE_READ – 幻读发生(表一记录学生,表二记录表一统计信息。)

Connection.TRANSACTION_SERIALIZABLE  -- 可串行化事务

Javax.ejb.TransactionAttributeType枚举中定义的事务属性:

TransactionAttributeType.MANDATORY

If a client invokes the enterprise bean's method while the client is associated with a transaction context, the container invokes the enterprise bean's method in the client's transaction context.

TransactionAttributeType.NEVER

The client is required to call without a transaction context, otherwise an exception is thrown.

TransactionAttributeType.NOT_SUPPORTED

The container invokes an enterprise bean method whose transaction attribute NOT_SUPPORTED with an unspecified transaction context.

TransactionAttributeType.REQUIRED

If a client invokes the enterprise bean's method while the client is associated with a transaction context, the container invokes the enterprise bean's method in the client's transaction context.

TransactionAttributeType.REQUIRES_NEW

The container must invoke an enterprise bean method whose transaction attribute is set to REQUIRES_NEW with a new transaction context.

TransactionAttributeType.SUPPORTS

If the client calls with a transaction context, the container performs the same steps as described in the REQUIRED case.

转载于:https://www.cnblogs.com/thlzhf/p/4863488.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值