开发者

Relationships between Spring, Hibernate, JDBC

开发者 https://www.devze.com 2023-01-20 17:01 出处:网络
I just start reading Sun\'s JDBC tutorial. I installed MySQL Connector/J and was just skimming through its menu, then came across this statement:

I just start reading Sun's JDBC tutorial. I installed MySQL Connector/J and was just skimming through its menu, then came across this statement:

"Although JDBC is useful by itself, we would hope that if you are not familiar with JDBC that after reading the first few sections of this manual, that you would avoid using naked JDBC for all but the most trivial problems and consider using one of the popular persistence frameworks such as Hibernate, Spring's JDBC templates or Ibatis SQL Maps to do the majority of repetitive work and heavier lifting that is some开发者_如何转开发times required with JDBC"

So what are the relationships between Spring, Hibernate, JDBC? What does the statement mean by saying "avoid using naked JDBC"?

Thanks,

Sarah


If you use Hibernate, Spring's JDBC templates or Ibatis SQL Maps, you're still using JDBC, but you don't have to deal with it directly. They're doing it for you, and to a degree, insulate you from some difficulties in the use of JDBC.

Hibernate is an object-relational-mapping framework.

MyBatis, formerly known as iBatis, is a data mapping framework.

Spring is a wide-ranging set of web framework components, and includes templating subsystems that allow integration with JDBC, Hibernate, or iBatis and abstract away some of the details of dealing with any of them.

You should indeed learn JDBC, but also (eventually) learn some of these others and try to avoid using JDBC directly for anything very complex.

These ideas are also (especially Hibernate) closely related to the Java Persistence API (JPA), which is also certainly worth learning.

You might also want to look at Java Data Objects (JDO).

Don't try to learn it all at once, though.

Starting with JDBC is a good idea. Staying with it is not.


Alphabets > Words > Sentences.

That is how we learn (natural) language.

Similarly, I see:

JDBC API > JDBC API with Connection Pooling > Spring JDBC Template > ORM/JPA/JDO


"avoid using naked JDBC" - Don't use the JDBC API directly.

Hibernate - A database persistence framework. It lets you store Java objects in databases. Pretty nifty.

Spring - It's actually a web development framework. The JDBC templates are an abstraction to JDBC, I think.

0

精彩评论

暂无评论...
验证码 换一张
取 消