최대 절전 모드 특수 효과로 발을 찾는데 도움이 될만한 문제가 발생했습니다.최대 절전 모드 문제 - "매핑되지 않은 클래스를 대상으로 @OneToMany 또는 @ManyToMany 사용"
두 개의 엔티티 인 Section과 ScopeTopic이 있습니다. 섹션에는 List 클래스 멤버가 있으므로 일대 다 관계가됩니다. @OneToMany 또는 @ManyToMany가 매핑되지 않은 클래스를 대상으로의
사용 : : 내 단위 테스트를 실행할 때 나는이 예외를 얻고있다 com.xxx.domain.Section.scopeTopic [com.xxx.domain.ScopeTopic]
나는이 오류가 내 ScopeTopic 엔티티가 테이블에 매핑되어 있지 않다는 것을 의미한다고 생각합니까? 내가 잘못했을 때 나는 볼 수 없다. 다음은 엔티티 클래스는 다음과 같습니다
@Entity
public class Section {
private Long id;
private List<ScopeTopic> scopeTopics;
public Section() {}
@Id
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@OneToMany
@JoinTable(name = "section_scope", joinColumns = {@JoinColumn(name="section_id")},
inverseJoinColumns = {@JoinColumn(name="scope_topic_id")})
public List<ScopeTopic> getScopeTopic() {
return scopeTopic;
}
public void setScopeTopic(List<ScopeTopic> scopeTopic) {
this.scopeTopic = scopeTopic;
}
}
@Entity
@Table(name = "scope_topic")
public class ScopeTopic {
private Long id;
private String topic;
public ScopeTopic() {}
@Id
public Long getId() {
return id;
}
public void setId() {
this.id = id;
}
public String getTopic() {
return topic;
}
public void setTopic(String topic) {
this.topic = topic;
}
}
나는 그렇게 몇 가지 지침이 좋은 것 잘못 이해 내 자신의 부족, 덕분 확신합니다!
아 삼았
hibernate.cfg.xml
에Entity
클래스를 추가 감사가 필요하지 않은! Point 2가 핵심이었고, SessionFactory, n00b 오류를 만들 때 annotatedClasses 속성 목록에 ScopeTopic을 넣는 것을 잊었습니다! – C0deAttack포인트 1이 나를위한 열쇠였습니다 : D thanks –
그냥이 코멘트를 치는 사람들에게. org.hibernate.annotations.Entity는 Hibernate 4에서 더 이상 사용되지 않는다. Point 1은 더 이상 적용되지 않는다. – gspatel