NetBeans IDE 6.7.1, GlassFish v2.1, Oracle 10g XE, JAVA 6 SE, JAVA 5 EE.엔티티 클래스 [...]의 주석 된 요소 [...]에있는 @JoinColumn이 불완전합니다.
CREATE table customer
(
cust_id NUMBER(5),
CONSTRAINT cust_pk PRIMARY KEY (cust_id),
...
)
CREATE TABLE movie
(
title VARCHAR2(50) PRIMARY KEY,
...
)
CREATE TABLE cust_rent_movie
(
title VARCHAR2(50),
cust_id NUMBER(5),
rent_date DATE DEFAULT current_date NOT NULL,
return_date DATE,
CONSTRAINT cust_rent_movie_pk PRIMARY KEY (title, cust_id, rent_date),
CONSTRAINT CustRentMovie_movie_fk FOREIGN KEY (title) REFERENCES movie ON DELETE CASCADE,
CONSTRAINT CustRentMovie_cust_fk FOREIGN KEY (cust_id) REFERENCES customer ON DELETE CASCADE
)
:
Exception Description: The @JoinColumns on the annotated element [private java.util.Collection vc.domain.Customer.rents] from the entity class [class vc.domain.Customer] is incomplete. When the source entity class uses a composite primary key, a @JoinColumn must be specified for each join column using the @JoinColumns. Both the name and the referenceColumnName elements must be specified in each such @JoinColumn.
javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.1 (Build b31g-fcs (10/19/2009))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
Exception Description: predeploy for PersistenceUnit [vc_pu] failed.
스크립트의 일부 데이터베이스를 생성하는 글래스 피쉬 V2.1.1의 출력
@ManyToMany(fetch=FetchType.EAGER)
@JoinTable(name="CUST_RENT_MOVIE", joinColumns={@JoinColumn(name="CUST_ID")}, inverseJoinColumns={@JoinColumn(name="TITLE")})
private Collection<CustRentMovie> rents = new ArrayList<CustRentMovie>();
부분 :
나는 @ManyToMany 주석에 문제가
고객 등급 코드
012 나는 영화의 클래스 CustRentMovie 대신 컬렉션 형식으로 넣어 실수로 3,516,@Entity
@Table(name = "customer")
@SequenceGenerator(name="seq", sequenceName="cust_id_seq", allocationSize=1)
public class Customer implements Serializable
{
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seq")
@Column(name="CUST_ID")
private int id;
@ManyToMany(fetch=FetchType.EAGER)
@JoinTable(name="CUST_RENT_MOVIE", joinColumns={@JoinColumn(name="CUST_ID")}, inverseJoinColumns={@JoinColumn(name="TITLE")})
private Collection<CustRentMovie> rents = new ArrayList<CustRentMovie>();
public Collection<CustRentMovie> getRents()
{
return rents;
}
public void setRents(Collection<CustRentMovie> rents)
{
this.rents = rents;
}
...
}
그래서 나는 변경된
private Collection<CustRentMovie> rents = new ArrayList<CustRentMovie>();
에
private Collection<Movie> movies = new ArrayList<Movie>();
CustomerRentMovie의 PK는 세 개의 열로 구성되어
에
변경 'Customer'와'CustRentMovie' (또는'Customer'와'Movie'의 many-to-many) 사이의 many-to-many 연관? –
Customer와 Movie 사이에 many-to-many 연관을 매핑하고 싶습니다. CustRentMovie는 조인 테이블입니다. 협회는 적색의 날과 돌아 오는 날을 특성으로 가지고 있습니다. 고객이 하나 이상의 영화를 대여 할 수 있기 때문에 red_date를 기본 키에 추가했습니다. – IVANNHS
그건 내가 생각한거야. –