2011-05-03 84 views
38

我似乎在Hibernate中映射List有問題。在我們的項目中,有一個類Card,其中包含AnswerAnswer,其中包含List<String>休眠,列表<String>

是Hibernate使用註釋可映射的List<String>?我的意思是,因爲它沒有@Entity註釋?

問候

回答

3

嘗試

@org.hibernate.annotations.CollectionOfElements(
     targetElement = java.lang.String.class 
    ) 
    @JoinTable(
     name = "foo", 
     joinColumns = @JoinColumn(name = "foo_id") 
    ) 
    @org.hibernate.annotations.IndexColumn(
     name = "POSITION", base = 1 
    ) 
    @Column(name = "baz", nullable = false) 
    private List<String> arguments = new ArrayList<String>(); 

或看到this detail example

+6

['@deprecated use @ ElementCollection'](http://docs.jboss.org/hibernate/core/3.6/javadocs/index.html?org/hibernate/annotations/CollectionOfElements.html) – 2011-05-03 08:56:18