我有這樣的POJO映射到我的MySQL數據庫:幫助,在Hibernate例外
@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;
}
}
而且每次我試圖執行與Hibernate任何操作,啓動此異常:
Initial SessionFactory creation failed.org.hibernate.AnnotationException: Collection has neither generic type or OneToMany.targetEntity() defined: com.bytecode.entities.Evento.participantespresentes
任何幫助?
此致敬禮, 瓦爾特恩裏克。
這似乎是與參與問題Evento類。你能告訴我們Evento課嗎? – Puce 2011-03-23 14:33:01
順便說一下,最好將代碼(類名,方法名,變量名等)保留爲英文。 – Puce 2011-03-23 14:34:10