Answer the question
In order to leave comments, you need to log in
Hibernate. What are link collections for?
Hey Habr!
When rummaging through someone else's code, I often see a similar structure ( here , for example):
<set name="busses" lazy="false">
<key column="route_id"/>
<one-to-many class="logic.Bus"/>
</set>
* This source code was highlighted with Source Code Highlighter.
Answer the question
In order to leave comments, you need to log in
Before learning Hibernate, it is better to first get acquainted with SQL itself, then it will become much clearer to you, and Hibernate has a decent manual, which is more than enough to start working as a framework
In order for Hibernate to do joins and subqueries for you. Those. you work with objects as always:
call route.getBusses() to get a list of buses on the current route, then you can change this Set as required by the business logic - everything will be automatically saved in the database. That is, such mappings are a common practice for ORM.
Instead of calling a separate DAO method that will pull out a list of buses by route id and then save possible modifications to this list again by calling another method.
You can work without these connections - but then why do you need an ORM? If you think that Hibernate does “too much” for you, I advise you to pay attention to myBatis www.mybatis.org/ , an introductory series of articlesjava.dzone.com/articles/getting-started-ibatis-mybatis
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question