- 浏览: 99991 次
文章分类
最新评论
-
jXee:
lgs0626 写道求源码,兄弟给共享下吧 "jee ...
jee6 学习笔记 4 - CRUD 2: View Details, Primefaces row selection -
lgs0626:
求源码,兄弟给共享下吧
jee6 学习笔记 4 - CRUD 2: View Details, Primefaces row selection
1. What is a transaction?
A transaction groups units of work and save the them all at once, or at any failure, roll back all the changes.
2. What are the features of a transaction?
ACID: Atomicity, Consistency, Isolation and Durability.
3. What are the major issues in app development regarding transaction?
3.1 Atomicity: if necessary, group several updates into one transaction to make sure the changes are either all saved or rolled back.
3.2 Consistency: when multiple threads accessing same record, make sure no changes/updates are lost.
4. What is the usual isolation most RDBMS databases have?
Read-Commit: a SELECT query only sees data committed before the query began.
This prevents Dirty Read(reading uncommitted data), but there may be Non-Repeatable Read (reading the same record might return different data in same transaction) and Phantom Read (ie, newly committed data becomes visible to the query that were not visible earlier in the transaction).
5. When a transaction starts?
When an application connects to a database and executes some query, a transaction starts.
6. What is the java API that represents a database transaction?
A jdbc connection represents a database transaction. Normally when you get a connection, the transaction starts; when you close the connection, the transaction ended.
7. What is the default commit mode for jdbc connection?
jdbc connection commit mode defaults to true. this means after a query completes, by default the transaction would try to commit.
8. What represents a transaction task in Java EE?
A transaction task is represented by a method that performs a database query. Typically, an EJB method is by default transaction aware and normally represents a transaction task.
9. What is local transaction?
Local transaction involves only one local database/resource manager.
10. What is global/distributed transaction?
Global/distributed transactions may involve more than one databases/resource managers. If global/distributed transactions involves more than one databases, it'll use Two-Phase commit.
11. What is jdbc transaction?
jdbc transaction by interface java.sql.Connection and can only work on one single database.
12. What is JTA (Java Transaction API)
JTA is java's transaction API for global/distributed transactions.
13. What is data source
Data source is used to manage database connections. Usually a pool of connections would be created for an application deployed to JEE containers. javax.sql.Datasource: A factory for connections to the physical data source that this DataSource object represents.
14. What is transaction management service provided by JEE containers?
Transaction management service is one of the most important services provided by most JEE compliant application servers. This service would monitor any objects/components that participate in a transaction and decides in the end if the transaction should commit or roll back. For a local JTA transaction, the transaction management service would make sure that the jdbc connection would be the same one for any objects that gets connection from configured data source.
15. What is implicit transaction management in app development?
Also called Container Managed Transactions(CMT). With the transaction management service provided by JEE containers, programming object don't need to manually start/commit a transaction manually. For instance, with the EJB technology, any ejb method implicitly start a transaction and the transaction would commit when the method completes.
16. What is explicit transaction management in app development?
Developers in their code manually start/commit a transaction. For EJBs, it must be of Bean Managed Transactions(BMT).
For jdbc connections:
connection.setAutoCommit(false);
....... // tasks to perform
connection.commit();
For JTA, it has an interface javax.transaction.UserTransaction:
// it can be injected with @Resource
@Resource UserTansaction utx;
// if in ejb, can get from ejb context
@Resource SessionContext ejbContext;
UserTransaction utx = ejbContext.getUserTransaction();
utx.begin();
...... // tasks to perform
utx.commit();
17. What is JEE transaction scope?
JEE transaction scope refers to the objects that participate in a transaction. For instance, session EJBs, entity beans etc.
18 What is JEE transaction scope propagation?
The same transaction (connection) would be passed(propagated) to all the participants of a transaction. This includes objects such as the EJBs that are called by the first EJB that starts the transaction and objects that have jdbc methods to access databases, and injected persistent context and etc. This provides Atomicity in that all the changes would be committed or rolled back.
19. What is default transaction attribute for EJBs?
default is Required: when an EjB method is called, if there's already a transaction available, this transaction would be used; otherwise, a new transaction would be started. The same transaction would be passed to any other EJBs, objects that need access to the database.
Support: if a transaction available, the ejb join the transaction.
RequiresNew: the ejb would start a new transaction. if a transaction already exists, the transaction would be suspended and resume after the ejb's transaction completes.
20 What is Optimistic Locking?
Optimistic Locking is commonly used to ensure data Consistency when there are concurrent access to same record. It assumes no other threads would update the same record. Add a version column to the table in question, morally a numeric type, like long/integer etc. Before commit update, check this column has the same value as that of last read. If they match, the update would be successful and transaction committed. If they don't match, then the record has been modified by some other thread and an OptimisticException should be raised and depends on requirement, it can re-try or just notifies client program components or end users.
Manual implementation: A typical update statement thus becomes(assume latest version=12345):
update student set name='john', version = version + 1
where id=120 and version=12345;
JPA implementation: use annotation @Version on the column. This property does not means to be updated by your code. JPA would manage the column automatically for you. When a non-relationship persistent field or property is changed, OR when a relationship attribute owned by the entity is modified, JPA will increment the version value.
21. What is JBoss no-tx-datasource?
When you configure a datasource like this in JBoss, you don't have JBoss' transaction management service available. You virtually said this: "I would like to manage transactions by myself". Why people want this? no idea.
22. What is JBoss local-tx-datasource?
This is the local JTA datasource configuration for JBoss and the transaction management service is turned on. This is the most commonly used datasource configuration if your application interacts with only one database.
22. What is JBoss xa-datasource?
If your application interacts with more than one databases, you need Two-Phase commit and this xa datasource configuration will do that.
23 System exception and Application exception
System exceptions represents unknown errors. System exceptions include java.lang.RuntimeException and its subclasses. EJBException is a subclass of RuntimeExcpetion and thus a system exception. When a System Exception is thrown, transaction would be rolled back.
Application exceptions are on the other hand part of your business logic and always delivered directly to client and would not cause a transaction to roll back, so that client code would have opportunity to catch the exception and recover from it based on business requirement. Application exceptions can be created by developers and normally extends java.lang.Exception.
24. What are the roll back API methods?
For Container Managed Transactions(CMT), it would catch any application exception interested and use EJBContext.setRollbackOnly() to roll back the transaction.
For Bean Managed Transactions(BMT), it would catch any application exception interested and use javax.transaction.UserTransaction.rollback().
A transaction groups units of work and save the them all at once, or at any failure, roll back all the changes.
2. What are the features of a transaction?
ACID: Atomicity, Consistency, Isolation and Durability.
3. What are the major issues in app development regarding transaction?
3.1 Atomicity: if necessary, group several updates into one transaction to make sure the changes are either all saved or rolled back.
3.2 Consistency: when multiple threads accessing same record, make sure no changes/updates are lost.
4. What is the usual isolation most RDBMS databases have?
Read-Commit: a SELECT query only sees data committed before the query began.
This prevents Dirty Read(reading uncommitted data), but there may be Non-Repeatable Read (reading the same record might return different data in same transaction) and Phantom Read (ie, newly committed data becomes visible to the query that were not visible earlier in the transaction).
5. When a transaction starts?
When an application connects to a database and executes some query, a transaction starts.
6. What is the java API that represents a database transaction?
A jdbc connection represents a database transaction. Normally when you get a connection, the transaction starts; when you close the connection, the transaction ended.
7. What is the default commit mode for jdbc connection?
jdbc connection commit mode defaults to true. this means after a query completes, by default the transaction would try to commit.
8. What represents a transaction task in Java EE?
A transaction task is represented by a method that performs a database query. Typically, an EJB method is by default transaction aware and normally represents a transaction task.
9. What is local transaction?
Local transaction involves only one local database/resource manager.
10. What is global/distributed transaction?
Global/distributed transactions may involve more than one databases/resource managers. If global/distributed transactions involves more than one databases, it'll use Two-Phase commit.
11. What is jdbc transaction?
jdbc transaction by interface java.sql.Connection and can only work on one single database.
12. What is JTA (Java Transaction API)
JTA is java's transaction API for global/distributed transactions.
13. What is data source
Data source is used to manage database connections. Usually a pool of connections would be created for an application deployed to JEE containers. javax.sql.Datasource: A factory for connections to the physical data source that this DataSource object represents.
14. What is transaction management service provided by JEE containers?
Transaction management service is one of the most important services provided by most JEE compliant application servers. This service would monitor any objects/components that participate in a transaction and decides in the end if the transaction should commit or roll back. For a local JTA transaction, the transaction management service would make sure that the jdbc connection would be the same one for any objects that gets connection from configured data source.
15. What is implicit transaction management in app development?
Also called Container Managed Transactions(CMT). With the transaction management service provided by JEE containers, programming object don't need to manually start/commit a transaction manually. For instance, with the EJB technology, any ejb method implicitly start a transaction and the transaction would commit when the method completes.
16. What is explicit transaction management in app development?
Developers in their code manually start/commit a transaction. For EJBs, it must be of Bean Managed Transactions(BMT).
For jdbc connections:
connection.setAutoCommit(false);
....... // tasks to perform
connection.commit();
For JTA, it has an interface javax.transaction.UserTransaction:
// it can be injected with @Resource
@Resource UserTansaction utx;
// if in ejb, can get from ejb context
@Resource SessionContext ejbContext;
UserTransaction utx = ejbContext.getUserTransaction();
utx.begin();
...... // tasks to perform
utx.commit();
17. What is JEE transaction scope?
JEE transaction scope refers to the objects that participate in a transaction. For instance, session EJBs, entity beans etc.
18 What is JEE transaction scope propagation?
The same transaction (connection) would be passed(propagated) to all the participants of a transaction. This includes objects such as the EJBs that are called by the first EJB that starts the transaction and objects that have jdbc methods to access databases, and injected persistent context and etc. This provides Atomicity in that all the changes would be committed or rolled back.
19. What is default transaction attribute for EJBs?
default is Required: when an EjB method is called, if there's already a transaction available, this transaction would be used; otherwise, a new transaction would be started. The same transaction would be passed to any other EJBs, objects that need access to the database.
Support: if a transaction available, the ejb join the transaction.
RequiresNew: the ejb would start a new transaction. if a transaction already exists, the transaction would be suspended and resume after the ejb's transaction completes.
20 What is Optimistic Locking?
Optimistic Locking is commonly used to ensure data Consistency when there are concurrent access to same record. It assumes no other threads would update the same record. Add a version column to the table in question, morally a numeric type, like long/integer etc. Before commit update, check this column has the same value as that of last read. If they match, the update would be successful and transaction committed. If they don't match, then the record has been modified by some other thread and an OptimisticException should be raised and depends on requirement, it can re-try or just notifies client program components or end users.
Manual implementation: A typical update statement thus becomes(assume latest version=12345):
update student set name='john', version = version + 1
where id=120 and version=12345;
JPA implementation: use annotation @Version on the column. This property does not means to be updated by your code. JPA would manage the column automatically for you. When a non-relationship persistent field or property is changed, OR when a relationship attribute owned by the entity is modified, JPA will increment the version value.
21. What is JBoss no-tx-datasource?
When you configure a datasource like this in JBoss, you don't have JBoss' transaction management service available. You virtually said this: "I would like to manage transactions by myself". Why people want this? no idea.
22. What is JBoss local-tx-datasource?
This is the local JTA datasource configuration for JBoss and the transaction management service is turned on. This is the most commonly used datasource configuration if your application interacts with only one database.
22. What is JBoss xa-datasource?
If your application interacts with more than one databases, you need Two-Phase commit and this xa datasource configuration will do that.
23 System exception and Application exception
System exceptions represents unknown errors. System exceptions include java.lang.RuntimeException and its subclasses. EJBException is a subclass of RuntimeExcpetion and thus a system exception. When a System Exception is thrown, transaction would be rolled back.
Application exceptions are on the other hand part of your business logic and always delivered directly to client and would not cause a transaction to roll back, so that client code would have opportunity to catch the exception and recover from it based on business requirement. Application exceptions can be created by developers and normally extends java.lang.Exception.
24. What are the roll back API methods?
For Container Managed Transactions(CMT), it would catch any application exception interested and use EJBContext.setRollbackOnly() to roll back the transaction.
For Bean Managed Transactions(BMT), it would catch any application exception interested and use javax.transaction.UserTransaction.rollback().
发表评论
-
ActiveMQ and Spring JMS Framework Message Loss
2019-06-28 07:15 29Java Message Service (JMS) prov ... -
how to proxy to k8s web console
2018-06-28 07:16 567### how to access k8s web conso ... -
Call Stored Procedure with JPA 2.1
2018-06-27 10:57 668JPA 2.1 introduces APIs to call ... -
Send response and then process - async processing
2017-10-12 09:35 558If your request processing take ... -
java 8 time api test
2017-08-29 05:40 480public class ParseUtcDateTime ... -
Setup ApiKey in header with Swagger generated client code
2017-08-23 06:41 479@Value("${api.base.path} ... -
Simple tool to monitor jvm memory usage and garbage collection
2016-10-13 06:06 362JDK has built-in tool to moni ... -
Externalize Application Config properties with JBoss 7.1
2017-06-02 12:09 338If you have configuration pro ... -
JPA native query does not support setting list parameters
2014-03-27 06:45 1013you might want to do the ... -
Owning Side and Inverse Side of JPA entity relationships
2013-09-10 07:08 811Entity relationships may be b ... -
avoid setParameter for "order by" in JPQL
2013-03-07 05:55 780you might want to create a JP ... -
JPA Path Expression, operator IN and Collection properties
2013-01-23 16:25 1399If we want to select the Orde ... -
与JEE6/EJB3.1相比, Spring framework 丧失了几乎所有的优势
2013-01-19 13:13 1038The Spring framework was a ma ... -
Simple EasyMock tutorial
2012-12-20 11:57 674http://veerasundar.com/blog/20 ... -
Servlet 3.0 @WebFilter and @WebServlet
2012-12-04 07:09 2696Servlet 3.0 provides new annota ... -
Why JSF2 @ViewScoped not working?
2012-12-03 06:55 1371javax.faces.bean.ViewScoped sai ... -
When to configure an XA datasource?
2012-11-16 12:58 1265If you ever came across this wa ... -
pass params to primefaces confirmation dialog box
2012-09-28 19:30 1337<p:dataTable id="idStuD ... -
Handle Big Dataset with Real Pagination with Primefaces 3.3 LazyDataModel
2012-09-21 13:41 5624If you have millions of record ... -
why Oracle sequence not working with JPA entity ID?
2012-09-19 08:08 971Suppose you have an Oracle seq ...
相关推荐
Java EE Application Assembly and Deployment 17 Packaging Applications 17 Development Roles 19 Java EE 6 APIs 22 Java EE 6 APIs in the Java Platform, Standard Edition 6.0 31 GlassFish Server Tools...
事务处理:概念与技术 英文版pdf,本书列举了大量成功的商业和研究系统的实例,此外,列出了许多事务处理算法的可编译的C代码片段。本书对于那些对实现分布式系统或客户-服务器结构感兴趣的人来说,是值得一读的。...
《Java EE 6 Tutorial: Basic Concepts, Fourth Edition》是一本面向新手及中级Java开发者的指南书籍,旨在帮助他们深入理解Java平台企业版6(Java EE 6)的各项特性与技术。本书由Oracle公司Java EE 6文档团队成员...
《Transaction Processing Concepts and Techniques》是一本数据库领域的经典著作,作者以深入浅出的方式阐述了数据库事务处理的理论和实践。这本书对于理解分布式系统和客户-服务器架构中的事务管理至关重要。 在...
JimGray大神事务神作,数据库从业人员必备书籍,本版本是英文原版djvu版本,大家可自己转换为PDF。
transaction-processing-concepts-and-techniques
在"Java EE technologies and migrating Java EE"的主题中,我们关注的是如何利用这些技术以及如何将现有的Java EE应用迁移到新的架构或平台。Java EE的发展历程中,经历了多次重大更新,例如从Java EE 6到Java EE 8...
5. **JNDI(Java Naming and Directory Interface)**:JNDI在Java EE中用于查找和绑定资源,如数据源或EJB。开发者会学习如何使用JNDI查找服务并进行依赖注入。 6. **JTA(Java Transaction API)**:在多组件协作...
Java EE(Java Platform, Enterprise Edition)是Oracle公司提供的一个企业级应用开发平台,它构建在Java SE(标准版)的基础上,为开发和部署分布式、多层的企业级应用程序提供了丰富的API和工具支持。Java EE旨在...
涵盖了Java EE核心技术如JSF(JavaServer Faces)、CDI(Contexts and Dependency Injection)、EJB(Enterprise JavaBeans)、JPA(Java Persistence API)、JTA(Java Transaction API)的讲解,并且对于Java EE中...
Java EE,全称为Java Platform, Enterprise Edition,是Java平台针对企业级应用开发的版本,它提供了丰富的组件和服务,用于构建分布式、多层架构的企业应用程序。本资料包包含"精通Java EE:精通Java EE 整合应用...
JAVA EE,全称为Java Platform, Enterprise Edition,是Java平台企业版的简称,是Oracle公司推出的一种用于构建企业级分布式应用程序的框架。它为开发者提供了在服务器端开发应用程序的一系列标准和API,包括Web组件...
7. **JTA (Java Transaction API)**: 事务管理是Java EE应用中不可或缺的一部分。JTA用于管理分布式事务,确保数据的一致性和完整性。你需要知道ACID属性,并理解如何配置和使用JTA进行事务控制。 8. **JPA (Java ...
Java EE(Java Platform, Enterprise Edition)是Oracle公司提供的一个企业级应用开发平台,它构建在Java SE基础之上,为开发和部署分布式、多层的企业级应用程序提供了丰富的API和工具。本教程旨在帮助读者全面理解...
7. **CDI(Contexts and Dependency Injection)**:CDI为Java EE应用提供依赖注入和上下文管理,简化组件之间的依赖关系和生命周期管理。 8. **WS(Web Services)**:Java EE支持SOAP和RESTful两种类型的Web服务...
Java EE(Java Platform, Enterprise Edition),也常被称为J2EE,是Java技术在企业级应用开发中的核心框架。它提供了一系列标准和API,用于构建分布式、多层的企业级应用程序,涵盖了从数据库连接、Web服务到安全...
10. **CDI(Contexts and Dependency Injection)**:CDI是Java EE的依赖注入框架,它提供了管理对象生命周期和依赖关系的能力,使得应用更易于测试和维护。 11. **JAX-RS(Java API for RESTful Web Services)**...
8. **Transaction Management**:Java EE 5提供了事务管理机制,确保在分布式环境中数据的一致性和完整性。开发者可以通过声明式或编程式的方式来控制事务。 9. **Security**:Java EE 5包含一套全面的安全模型,...