【发布时间】:2011-07-21 08:54:21
【问题描述】:
我已将此 POJO 映射到我的 MySQL 数据库:
@Entity
@Table(name = "participantespresentes", catalog = "tagit")
public class Participantespresentes implements java.io.Serializable {
private ParticipantespresentesId id;
private Evento evento;
private Usuario usuario;
private boolean status;
public Participantespresentes() {
}
public Participantespresentes(ParticipantespresentesId id, Evento evento, Usuario usuario, boolean status) {
this.id = id;
this.evento = evento;
this.usuario = usuario;
this.status = status;
}
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "idUsuario", column =
@Column(name = "idUsuario", nullable = false)),
@AttributeOverride(name = "idEvento", column =
@Column(name = "idEvento", nullable = false))})
public ParticipantespresentesId getId() {
return this.id;
}
public void setId(ParticipantespresentesId id) {
this.id = id;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "idEvento", nullable = false, insertable = false, updatable = false)
public Evento getEvento() {
return this.evento;
}
public void setEvento(Evento evento) {
this.evento = evento;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "idUsuario", nullable = false, insertable = false, updatable = false)
public Usuario getUsuario() {
return this.usuario;
}
public void setUsuario(Usuario usuario) {
this.usuario = usuario;
}
@Column(name = "status", nullable = false)
public boolean isStatus() {
return this.status;
}
public void setStatus(boolean status) {
this.status = status;
}
}
每次我尝试使用休眠执行任何操作时,都会启动此异常:
Initial SessionFactory creation failed.org.hibernate.AnnotationException: Collection has neither generic type or OneToMany.targetEntity() defined: com.bytecode.entities.Evento.participantespresentes
有什么帮助吗?
最好的问候, 瓦尔特·恩里克。
【问题讨论】:
-
似乎是参加者提出了 Evento 类的问题。你能告诉我们 Evento 课程吗?
-
顺便说一句,最好将代码(类名、方法名、变量名等)保持为英文。
标签: java hibernate jsp exception