XML configuration of more than one by one to many foreign keys can be configured the same, but Anno not very good, more this is finished, one side with a Mappedby "" in the other side of the property "on it, or to build an intermediate table. XML Mappedby because the foreign key has been configured, just to determine whether to maintain the relationship. Two-way Association is the correspondence, one is the object of a party with one, and the second one has a set of more than one party. Once the relationship is not maintained by oneself, then one party sets a set of more than one set to its own set, but many of the parties do not save their own objects, so that a save, more than the other side of the foreign key is not related to the primary key of one party, but not more tables or something, Do not want to annotation remove mappedby after the build more tables.
In fact, the XML configuration, one side of the configuration of a set out, just for hibernate to know how to parse the corresponding relationship, the storage and reading can find the database data and object properties of the corresponding, or only a party get one side, not one party get many side.
Hibernate XML format and anno format Mappedby