使用anotation应该类似于
public class User {
private int userId;
...
@ElementCollection(fetch = FetchType.EAGER)
private Set<String> countries = new HashSet<String>();
但我需要将它映射到xml文件。我试试:
<hibernate-mapping>
<class name="com.foo.User" table="user">
...
<property name="userId" />
...
<set name="countries" table="user_country">
<key column="userId" />
<element type="string" column="country" />
</set>
...
表user_country具有userId(外键)和国家/地区是varchar