持久列表<string>或设置<string>而无需注释</string> </string>

时间:2014-08-05 13:19:21

标签: java hibernate hibernate-mapping

使用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

0 个答案:

没有答案