We need to be careful if we are thinking about removing the JPA of our projects. Solutions to Some of the JPA/Hibernate problems We will see some tips to fix or to workaround the problems described here. In the next page we will see some solutions for the problems detailed above, the solutions could help you to avoid a huge persistence framework refactoring. Some of the JPA advantages are: database portability, save a lot of the development time, make easier to create queries, cache optimization, a huge community support, etc. JPA has a lot of advantages that will not be detailed here because this is not the post theme, JPA is a tool that is indicated for a lot of situations. Slow processing and a lot of RAM memory occupied: There are moments that JPA will lose performance at report processing, inserting a lot of entities or problems with a transaction that is opened for a long time.Īfter reading all the problems above you might be thinking: “Is JPA good in doing anything?”.A development team without a developer with a good JPA experience will lose a lot of time with JPA ‘ rules‘. Framework complexity: To create a CRUD with JPA is very simples, but problems will appear when we start to use entities relationships, inheritance, cache, PersistenceUnit manipulation, PersistenceContext with several entities, etc.If you combine those resources the JPA performance might drop and not use the table indexes, or you will not be able to use a specific database resource that could solve this problem. Complex Query: That are projects that has several queries with a high level of complexity using database resources like: SUM, MAX, MIN, COUNT, HAVING, etc.This advantage can became a disadvantage when the generated query has a poor performance and it does not use the table index that was created to optimize the queries. Generated SQL: One of the JPA advantages is the database portability, but to use this portability advantage you need to use the JPQL/HQL language.Problems with slow upload, corrupted file and loss of Internet can happen making the dev/ops team to lose more time. Imagine a project that in each new release it is necessary to update 10 customers servers across the country. The artifact size can be a problem if the developer needs to do a deploy in several remote servers with a low Internet band (or a slow upload). The Hibernate uses a lot of dependencies that will increase the size of the generated jar/war/ear. Artifact size: The artifact size will increase a lot if you are using the Hibernate implementation.Legacy Database: A project that has a lot of business rules in the database can be a problem when wee need to invoke StoredProcedures or Functions.When you use composite key several problems will might happen, and some of these problems could be implementation bugs. When we map a composite key we are adding a huge complexity to the project when we need to persist or find a object in the database. Composite Key: This, in my opinion, is the biggest headache of the JPA developers.Below you will see the JPA/Hibernate problems and in the next page you will see some solutions to these problems: There are times that JPA can do more harm than good. If you do not know I wrote a JPA book (in Portuguese only) and I do not think that JPA is the silver bullet that will solve all the problems. I am not a radical that thinks that JPA is worthless, but I do believe that we need to choose the right framework for the each situation. I have created 4 CRUDs in my github using the frameworks mentioned in this post, you will find the URL at the beginning of each page. Criteria for choosing the frameworks described here.Solutions to some of the JPA/Hibernate problems.Which alternatives do we have outside the JPA world? Today we will talk about situations in which the use of the JPA/Hibernate is not recommended.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |