Spring’s JPA extension especially the declarative annotation makes the transaction management super convenient for developers, however, our RESTful application’s design need make the transaction boundary to as minimal as possible to avoid long running transaction and unnecessary transaction.
One common mistake that a lot Java developers take for granted that if I catch exception then the exception will be hidden for ever, that is totally false, and we should not overuse exception to manage our business workflow. This blog I will talk why should not let expected exceptions to be managed across JPA transactions.
Mockito and Powermock are most popular test frameworks in testing driven development world. In this blog, I will summary the 2 mock frameworks, and talk about some key technical fundamentals.
JPA entity is very commonly used in Hibernate involved Java applications, like Spring. Usually you can define DOs (data objects) to manage the database operations in some ORM way, but lots developers do not use the DOs property, one of the very common bad practice is the use the DOs across JPA transactions or outside JPA transactions.
I am sure that among Spring/Hibernate developers, there are a lot confuses about the concepts of JPA transaction, Hibernate sessions and JDBC connections and even DB transactions, sometimes these kind of confuses can impact the application design and issues investigation, so let’s make some clarification about these concepts.
Hibernate ORM is a very complicated framework as one most popular JPA implementer in Java world, explore it thoroughly really takes much time, I want use this article to quickly summarize the basic data load process and major software components.
I am sure there are always other better ways of avoid and fix the leak use of InheritableThreadLocal especially when we talk about this in more specific use scenarios, the above talking and solutions are pretty some generic ones. Once we are clarified about the root cause of theInheritableThreadLocal leak issues, we can use what ever solution we like for better protect or improve our software system.