두 JPA 엔티티간에 단방향 일대 다 매핑을 생성하려고합니다. 내 ChatRoom
클래스에서 에 User
을 나타내는 Vector<User>
유형의 개체가 있습니다. userId
(User
클래스)을 기반으로 일대 다 매핑을 만들려고합니다. 여기EclipseLink/JPA @OneToMany Backpointer 카디널리티 오류
@Entity
public class ChatRoom {
@Id
@GeneratedValue
private int chatRoomID;
@OneToMany(mappedBy="userID")
private Vector<User> users;
// A no-argument constructor is required for EclipseLink to instantiate the persistence object properly.
public ChatRoom() {}
// Getter/Setter section
}
사용자 클래스입니다 : 여기 내 예제 코드는
@Entity
public class User {
@Id
@GeneratedValue
private int userID;
private String username;
// Getter/Setter section
}
이클립스에서 이러한 실체에서 테이블을 생성하려고, 나는 다음과 같은 오류 얻을 :
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [ChatJPA] failed.
Internal Exception: Exception [EclipseLink-7244] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.ValidationException
Exception Description: An incompatible mapping has been encountered between [class iosoa.entity.ChatRoom] and [class iosoa.entity.User]. This usually occurs when the cardinality of a mapping does not correspond with the cardinality of its backpointer.
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:126)
을
이 문제를 해결하는 방법에 대한 아이디어가 있습니까? 당신의 도움을 주셔서 감사합니다.
[링크] (http://stackoverflow.com/questions/3515756/unidirectional-relationship-inentent-bean-jpa)에는 @JoinTable을 사용하는 방법에 대한 답변이 포함되어 있지만 제 경우에는 다음 오류가 발생합니다. 예외 설명 : [users] 속성은 ValueHolderInterface 유형으로 선언되지 않았지만 해당 매핑은 간접 참조를 사용합니다. 매핑 : org.eclipse.persistence.mappings.UnidirectionalOneToManyMapping [users]' –