简体   繁体   中英

Hibernate and CRUDRepository Spring Boot

I am new to Hibernate and Spring boot. I understand that hibernate is ORM tool so that you can map objects to database and just use save() to save obj into the database automatically. In Spring Boot, I would do something like

public interface CourseRepository extends CrudRepository<Course, String>{
}

and somehow I will get all the CRUD operations like save and findAll etc.

From another tutorial of hibernate, it says that session is required to save the object to the database. However, I don't see any form of sessionfactory or session being implemented in Spring boot and I am still able to do the save and findAll operations etc.

How is this happening and what relations does this have with hibernate? Where exactly should I start to find out more about hibernate, stuff like @OneToMany and basically understand the details of the whole application to database operations in spring boot? Thanks

Spring Boot takes care of all the session management. Refer to this question for better understanding:

Spring Boot & Spring Data: how are Hibernate Sessions managed?

there are two things crudRepository and sessionFactory. try to find out difference between them and also try to read what is JPA and Hibernate.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM