当前位置: 动力学知识库 > 问答 > 编程问答 >

hibernate - mappedBy and inverse attributes are same?

问题描述:

I really did not get the meaning of the mappedBy attribute. Please tell me how it will effect if we not use it. If you can give the example that will be great for me.

Also, the attribute mappedBy and inverse aree the same?

网友答案:

Yes, mapped by in annotations performs the same function as inverse would in XML file.

A relationship always have 2 entities participating in it.

In case of one-one or one-many or many to one, the key will be stored in one of the entites. It does not make any sense to store it in 2 places.

It essential tells hibernate that the key is at the other end of the relationship.

So if there are entities A and B which have a one to one relationship, and you see the mappedBy attribute in A, then the foreign key (which points to A) is stored in B.

分享给朋友:
您可能感兴趣的文章:
随机阅读: