Direction between JDBC and Hibernate?

We recently introduced Hibernate as a replacement for JDBC.

I like not always write instructions SELECT, UPDATE, INSERTand the codes associated with them PreparedStatementand ResultSet.

However, we struggled with random bizarre behavior ( Example A ), which is difficult for me to understand and solve due to all the different configuration parameters / functions and related to Hibernate behavior. I find some of the features like caching, lazy loading, etc., etc. Very cool, but much more than I need and end up confusing.

Is there a better middle ground for someone just trying to avoid the tediousness of JDBC, but who doesn't need all the features of Hibernate?

+3
source share
2 answers

doesn't completely avoid jdbc, but ... my suggestion is to use the jbdc support provided by the spring framework. You still need to write your choice, update and insertions, but spring wraps it beautifully, so you usually don't need a result set, closing connections, clearing your code, etc.

See this chapter from the spring documentation for details. You can create a whole dao layer that will display just like the hibernate dao layer, but the internal implementation is different. The RowMapper interface allows you to handle the conversion from result sets to objects very beautifully. In general, this provides a clean separation of problems.

( - iBATIS O/R , , sql Java ).

+5

Hibernate ( TopLink) JPA. IMO , JPA, , ORM /, Hibernate , - "" Hibernate .

0

Source: https://habr.com/ru/post/1731705/


All Articles