What is the use of collection mappings and association mappings?

纵然是瞬间 提交于 2019-12-12 06:19:56

问题


I am working On Hibernate With Spring

If first i created database and i used Hibernate DAOs layer along with DAOsImpl.

and i simply mapped my model classes to database tables with simple mapping.then what is the use of Collection Mapping,Association Mapping????

without collection mapping and association mapping i can do my work whatever i want.

please give me any good explanation.


回答1:


When you are mapping your model classes you are mapping the entities to the database, specifying types of fields, primary keys ...

But when you are using Collection mapping you are defining the way these entities are related to each others, you are simply mapping the relationships/associations between entities. (specifying foreign keys, join tables, ...).

Take a look at the Collection mapping Documentation for further information.

For example for the given association:

You need Collection mapping to specify the type of relation between an author and a book.



来源:https://stackoverflow.com/questions/31747083/what-is-the-use-of-collection-mappings-and-association-mappings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!