@@MarcoCodes Thank you for the great content! I purchased your Spring course and I loved it! Unfortunately, I'm unable to buy a Maven one, as Russia got locked out from the whole world and Visa/Mastercard no longer work. No Marco, no Udemy, no Coursera😭 Hope pointless war ends soon...
best thing about this video is that it puts the knowledge into context of other apis and frameworks, so now I know where and what to look for if I need extra information.
I found your video by searching “hibernate crash course” and it was great! Just what I was looking for, especially the sections on JPA and Spring. Thanks!
I like the style of how fast this turtorial comes to the point and covers the essentials. How would the world look like if everyone would do such kind of high quality tutorials? 😄 Great teaching skills Marco, thumbs up 👍
Was reading in to spring and decided to take a minute too understand its jpa features origin and differences between jpa and hibernate. Answered a lot of questions and contains good amount of easy to consume informations. :)
Great video! I loved how everything was explained, it was super easy to digest. It helped me so much to refresh all my knowledge about this topic, in fact I think I have it way more clear now than when I studied it in college 😂
I was looking for a quick overview of hibernate that we will cover this week, and this fit perfectly. I like the clarity and "to the point" , practical approach of your tutorial. If I see a course on Udemy by you, I will definetely buy it!
This was amazing!! Currently i got my first job as software developer and my company mainly uses springboot and this video helped me clear a lot of thoughts, thanks
i like to watch tutorials side by side with an running IDE - i have a wish: for every video episode i would like to have a starting Github Repo - (and maybe a result repo) - or and initial commit or branch and an final commit or branch to the repo - then i also can compare my repo with the final repo if i miss some setting while replay your steps in the IDE
Your wish is already fulfilled: github.com/marcobehlerjetbrains/hibernate-tutorial.git . I just forgot to add the repo to the description, but usually all my videos come with the repo. Let me know if that helps.
@@MarcoCodes thanks a lot - i was not aware that you have an additional dedicated marcobehlerjetbrains account :) i searched in the wrong user space :)
It's a good question. I.e. you could probably leave out @Entity specifying the class directly in hibernate.cfg.xml - however, in most real life applications you'll have some sort of package scan/component scan, and then you definitely need @Entity to make it work - as opposed to specifying every class manually. Give it a try and see what Hibernate does!
Thanks a lot for this! Clear and concise you really helped me understand what's going on. Is 2nd edition book recommended, or will the 1st edition from 2007 be enough to start? (few € for older vs many € for 2nd)
What about the newer version of the book "Java Persistence with Spring Data and Hibernate", do you recommend that one? Or did you specifically put in the old one because of quality reasons? (nevermind, the book I mentioned was released AFTER your video)
My java ee application uses an EntityManager throughout, so when I am writing unit tests I need to create an EntityManager configured to use a test database to give to my application code. I created a hibernate.cfg.xml file in src/test/resources. I have a problem though that my entities are not being scanned correctly. In the config file there is a packagesToScan property which lists the package where entities are in my application. However, those packages are in src/main/java, while my tests are in src/test/java. This is causing the problem that when I create a query with the name of my entity, I get an exception which says my entity is not mapped. How do I tell hibernate to scan a package in a different directory?
19:30 - Generated Sources User_ They are not recognized by IntelliJ out of the box. I need to right tap at "target/generated-sources" node and select "Mark Directory as ..." / "Generated Sources Root" to be able to have an Import Option with the User_ class. But somehow this feels cheating if i have to setup something in the IDE after git checkout. I think this should be somehow in some settings files. i found some "howto" with a Gradle file. but this project is not using Gradle. How is the right way to setup the generated sources?
Have a look at the pom.xml file from the sample project. There's a "build-helper-maven-plugin" specified, which does add the sources automatically to your IntelliJ.
So what will happen if you create an entity class and you forget the empty constructor ? Btw if we assume that you have a constructor with all parameters why hibernate cant manage to create an object and to save it successfully
If I remember correctly, if you're missing the (implicit or explicit) no-arg constructor, you'll simply get an exception thrown, but you'll need to try it out :) As for your second question, I suppose there are a multitude of reasons, i.e. that afaik the reflections API doesn't easily work with constructors, that having super-long constructors for classes/tables with tons of fields is akward etc etc, but don't take it as the final say :D
My googling tells me that JPA is a specification and that Hibernate is an implementation for that specification. That being said, I'm worried that I'll be confused if I read through the Java Persistence with Hibernate book when I go to work with JPA in for example Spring Boot. Is there no JPA specific book you could recommend?
No need to worry: 99% (oversimplified) of the time when you use JPA in a Spring Boot application, it's with Hibernate as the "persistence provider". And the book gives you a perfect foundation for both, the JPA spec + Hibernate - there is no such thing as "just a JPA book", because as you said, it's just a specification.
@@MarcoCodes Thank you for the quick reply. One thing I’d like to highlight is that the same author/authors are releasing a new book called “Java Persistence with Spring Data and Hibernate” listed on Amazon with a release date on the 14th of February 2023. I wonder if that will act as an upgrade/replacement for the book recommended in this video. I’m thinking of simply waiting for this new book. Any thoughts? My current situation is I’m doing a two year Java degree. I’m in my second year and I’m starting a Volvo internship in february where they use Java/Spring Boot.
Two things: Working through the book will realistically take you months, so it's basically always better to have started yesterday :) Plus, Spring Data comes,essentially, on top of Hibernate/JPA and everything that is in the second edition will still be valid. I.e. I would start working through the book now, and then additionally do the Spring Data once it's released, as sort of a refresher + expansion of knowledge :)
hi. i'm trying to set up the hibernate meta model generation in my spring boot application. how do I generate the sources? jaxb-runtime doesn't seem to be wokring. PS. I'm new to java, so i'm not exactly knowledgeable in configuring pom.xml and all. Also, I'm using VS code.
@@MarcoCodes I know. But no worries. It seemed like I needed to reload vscode after putting the maven plugin. It's working now. 👍 Just took four hours to figure that out.
Long story, but short answer: If you don't explicitly open up the transaction yourself, your database will anyway open an implicit transaction. There are plenty of threads on this on stackoverflow, if you search around.
I respect you but this course is very lacking, i know the hibernate framework is complex, but usually when i see crash crouse or a youtube video it means i'm struggling with documentation, you can't just say "go read a book" when you reach important notes. This video is kind of useless. Thank you for your efforts tho.
Hi, very helpful video. I followed your tutorial but now I receive this error: org.hibernate.query.sqm.UnknownEntityException: Could not resolve root entity 'Usuario'. This is the query that I'm doing: Query query = session.createQuery("SELECT u FROM Usuario u", Usuario.class); entities = query.getResultList(); And this is the entity in question: @Entity @Table(name = "Usuario") public abstract class Usuario I really have no idea of what is wrong, could you help me?
@@MarcoCodes Doesn't work either, seems to be something related to the mapping configuration, but I cannot find a solution. The NativeQuery works so I am using that at the moment. Thanks for the comment