2012-05-04 2 views
1

내가 PostgreSQL을에 RECS 테이블에 RECS 모델 매핑, 일부 필드는이 같은 errorr 던졌다, 내가 코드를 실행할 때, 설정하는 선언이 있습니다이 컬렉션을 초기화 할 수 없습니다

org.hibernate.exception.SQLGrammarException: could not initialize a collection: Recs._recsDetailName 
caused by: org.postgresql.util.PSQLException: ERROR: relation "recs__recsdetailname" does not exist 

내 RECS 모델 :

@Entity 
@Table(name = "RECS", uniqueConstraints = @UniqueConstraint(columnNames = "id")) 
public class Recs implements Serializable, Cloneable { 

    /** 
    * Serialized version unique identifier. 
    */ 
    private static final long serialVersionUID = -7316874431882307750L; 

    @Id 
    @Column(name = "id") 
    private int _id; 

    @Basic 
    @Column(name = "recs_num") 
    private int _recsNum; 

    @Basic 
    @Column(name = "details") 
    private String _details; 

    @Column(name = "d_stamp") 
    private Date _timeStamp; 

    @ElementCollection(fetch = FetchType.EAGER) 
    @Column(name = "recs_detail_name") 
    private Set<String> _recsDetailName; 

    .. 

내 테이블 :

 Column   |   Type    | Modifiers       
-----------------------+-----------------------------+------------------------------- 
id     | integer      | not null default 
recs     | xml       | 
recs_num    | integer      | 
details    | character varying(300)  | 
d_stamp    | timestamp without time zone | default now() 
recs_detail_name  | text[]     

|

DB를에서 샘플 recs_detail_name은 다음과 같이이다 :

{"TeleNav GPS Navigator","Photobucket for BlackBerry","Cellfire Mobile Coupons"} 

사람이 무슨 일을 수 있습니다 알고 ??? 감사합니다

답변

1

ElementCollection은 집합이 직렬화되는 단일 열에 매핑되지 않습니다. String (recs_detail_name)에 대한 열과 소유 테이블의 기본 키를 참조하는 외래 키 열을 포함하는 추가 테이블을 사용하여 매핑됩니다. 이것은 물론 hibernate documentation에 설명되어 있습니다.

Set를 단일 열로 매핑하려면 사용자 정의 사용자 유형을 사용해야합니다.

관련 문제