andreiribas 14 de set. de 2007
parece que um atributo da sua classe não está mapeado direito…
coloca o código da classe ou do mapeamento pra gente ajudar
trgpwild 14 de set. de 2007
Esse é o código da classe já anotada:
package equus.news.modelo;
import java.util.Collection;
import javax.persistence.Column ;
import javax.persistence.Entity ;
import javax.persistence.FetchType ;
import javax.persistence.GeneratedValue ;
import < a href = "http://javax.persistence.Id" > javax . persistence . Id </ a > ;
import javax.persistence.JoinColumn ;
import javax.persistence.JoinTable ;
import javax.persistence.ManyToMany ;
import javax.persistence.ManyToOne ;
import javax.persistence.OneToMany ;
import javax.persistence.Table ;
import javax.persistence.Transient ;
import org.hibernate.annotations.Cascade ;
import org.hibernate.annotations.CascadeType ;
import org.hibernate.annotations.Fetch ;
import org.hibernate.annotations.FetchMode ;
@Entity @Table (name=“tb_campanha”, schema=“equusletter”)
public class Campanha {
@Transient
private FetchType fetch = FetchType . LAZY ;
@Transient
private CascadeType cascade = CascadeType . ALL ;
@Id
@GeneratedValue
@Column ( name = "id_campanha" )
private int id ;
@Column ( name = "nm_campanha" , nullable = false , length = 80 , insertable = true , updatable = true )
private String nome ;
@Column ( name = "ds_corpo_campanha" , nullable = false , length = 100 , insertable = true , updatable = true )
private String corpo ;
@ManyToOne ( fetch = this . fetch )
@JoinColumn ( name = "id_newsletter" , insertable = true , updatable = true )
@Fetch ( FetchMode . JOIN )
@Cascade ( CascadeType . SAVE_UPDATE )
private NewsLetter newsLetter ;
@OneToMany ( mappedBy = "tb_campanha" , fetch = this . fetch )
@Cascade ( this . cascade )
private Collection < Agendamento > agendamento ;
@ManyToOne ( fetch = this . fetch )
@JoinColumn ( name = "id_cliente" , insertable = true , updatable = true )
@Fetch ( FetchMode . JOIN )
@Cascade ( CascadeType . SAVE_UPDATE )
private Cliente cliente ;
@ManyToMany ( fetch = this . fetch )
@JoinTable ( name = "tb_base_email_campanha" , schema = "equusletter" ,
joinColumns = @JoinColumn ( name = "id_campanha" ),
inverseJoinColumns = @JoinColumn ( name = "id_base_email" ))
private Collection < BaseEmail > baseEmail ;
public Collection < Agendamento > getAgendador () {
return agendamento ;
}
public Collection < BaseEmail > getBaseEmail () {
return baseEmail ;
}
public Cliente getCliente () {
return cliente ;
}
public String getCorpo () {
return corpo ;
}
public int getId () {
return id ;
}
public NewsLetter getNewsLetter () {
return newsLetter ;
}
public String getNome () {
return nome ;
}
public void setAgendador ( Collection < Agendamento > agendamento ) {
this . agendamento = agendamento ;
}
public void setBaseEmail ( Collection < BaseEmail > baseEmail ) {
this . baseEmail = baseEmail ;
}
public void setCliente ( Cliente cliente ) {
this . cliente = cliente ;
}
public void setCorpo ( String corpo ) {
this . corpo = corpo ;
}
public void setId ( int id ) {
this . id = id ;
}
public void setNewsLetter ( NewsLetter newsLetter ) {
this . newsLetter = newsLetter ;
}
public void setNome ( String nome ) {
this . nome = nome ;
}
}
clauber.ferreira 14 de set. de 2007
trgpwild 14 de set. de 2007
Como assim? Jah testei…
Eu fiz um teste antes com uma tabela que naum tem relacionamento com nenhuma outra do banco pois ela soh define o nivel de acesso do administrador do sistema e consegui gerar sem problemas, mas qdo tento com todas as tabelas, dah o mesmo erro.
trgpwild 14 de set. de 2007
E eu nem tenho o campo campanha na classe…
trgpwild 14 de set. de 2007
E eu nem tenho o campo campanha na classe…
trgpwild 14 de set. de 2007
Bom, eu tirei as variáveis fetch e cascade das classes e deu certo, mas agora a excessão é outra:
Exception in thread "main" org . hibernate . AnnotationException : mappedBy reference an unknown target entity property : equus . news . modelo . Agendamento . tb_campanha in equus . news . modelo . Campanha . agendamento
at org . hibernate . cfg . annotations . CollectionBinder . bindStarToManySecondPass ( CollectionBinder . java : 552 )
at org . hibernate . cfg . annotations . CollectionBinder $ 1. secondPass ( CollectionBinder . java : 517 )
at org . hibernate . cfg . CollectionSecondPass . doSecondPass ( CollectionSecondPass . java : 43 )
at org . hibernate . cfg . Configuration . secondPassCompile ( Configuration . java : 1130 )
at org . hibernate . cfg . AnnotationConfiguration . secondPassCompile ( AnnotationConfiguration . java : 316 )
at org . hibernate . cfg . Configuration . generateDropSchemaScript ( Configuration . java : 756 )
at org . hibernate . tool . hbm2ddl . SchemaExport .< init > ( SchemaExport . java : 93 )
at org . hibernate . tool . hbm2ddl . SchemaExport .< init > ( SchemaExport . java : 61 )
at equus . news . utils . GeraTabelas . main ( GeraTabelas . java : 11 )
Minhas classes:
Agendamento:
package equus.news.modelo ;
import java.util.Calendar ;
import javax.persistence.Column ;
import javax.persistence.Entity ;
import javax.persistence.FetchType ;
import javax.persistence.GeneratedValue ;
import javax.persistence.Id ;
import javax.persistence.JoinColumn ;
import javax.persistence.ManyToOne ;
import javax.persistence.Table ;
import javax.persistence.Temporal ;
import javax.persistence.TemporalType ;
import org.hibernate.annotations.Cascade ;
import org.hibernate.annotations.CascadeType ;
import org.hibernate.annotations.Fetch ;
import org.hibernate.annotations.FetchMode ;
@Entity @Table ( name = "tb_agendamento" , schema = "equusletter" )
public class Agendamento {
@Id
@GeneratedValue
@Column ( name = "id_agendamento" )
private int id ;
@Column ( name = "dt_agendamento" , nullable = false )
@Temporal ( TemporalType . TIMESTAMP )
private Calendar data ;
@ManyToOne ( fetch = FetchType . LAZY )
@JoinColumn ( name = "id_campanha" , insertable = true , updatable = true )
@Fetch ( FetchMode . JOIN )
@Cascade ( CascadeType . SAVE_UPDATE )
private Campanha campanha ;
public Agendamento [] getAgendamentos ( Cliente cliente ) {
return null ;
}
public Campanha getCampanha () {
return campanha ;
}
public Calendar getData () {
return data ;
}
public int getId () {
return id ;
}
public void setCampanha ( Campanha campanha ) {
this . campanha = campanha ;
}
public void setData ( Calendar data ) {
this . data = data ;
}
public void setId ( int id ) {
this . id = id ;
}
}
Campanha:
package equus.news.modelo ;
import java.util.Collection ;
import javax.persistence.Column ;
import javax.persistence.Entity ;
import javax.persistence.FetchType ;
import javax.persistence.GeneratedValue ;
import javax.persistence.Id ;
import javax.persistence.JoinColumn ;
import javax.persistence.JoinTable ;
import javax.persistence.ManyToMany ;
import javax.persistence.ManyToOne ;
import javax.persistence.OneToMany ;
import javax.persistence.Table ;
import org.hibernate.annotations.Cascade ;
import org.hibernate.annotations.CascadeType ;
import org.hibernate.annotations.Fetch ;
import org.hibernate.annotations.FetchMode ;
@Entity @Table ( name = "tb_campanha" , schema = "equusletter" )
public class Campanha {
@Id
@GeneratedValue
@Column ( name = "id_campanha" )
private int id ;
@Column ( name = "nm_campanha" , nullable = false , length = 80 , insertable = true , updatable = true )
private String nome ;
@Column ( name = "ds_corpo_campanha" , nullable = false , length = 100 , insertable = true , updatable = true )
private String corpo ;
@ManyToOne ( fetch = FetchType . LAZY )
@JoinColumn ( name = "id_newsletter" , insertable = true , updatable = true )
@Fetch ( FetchMode . JOIN )
@Cascade ( CascadeType . SAVE_UPDATE )
private NewsLetter newsLetter ;
@OneToMany ( mappedBy = "tb_campanha" , fetch = FetchType . LAZY )
@Cascade ( CascadeType . ALL )
private Collection < Agendamento > agendamento ;
@ManyToOne ( fetch = FetchType . LAZY )
@JoinColumn ( name = "id_cliente" , insertable = true , updatable = true )
@Fetch ( FetchMode . JOIN )
@Cascade ( CascadeType . SAVE_UPDATE )
private Cliente cliente ;
@ManyToMany ( fetch = FetchType . LAZY )
@JoinTable ( name = "tb_base_email_campanha" , schema = "equusletter" ,
joinColumns = @JoinColumn ( name = "id_campanha" ),
inverseJoinColumns = @JoinColumn ( name = "id_base_email" ))
private Collection < BaseEmail > baseEmail ;
public Collection < Agendamento > getAgendamento () {
return agendamento ;
}
public Collection < BaseEmail > getBaseEmail () {
return baseEmail ;
}
public Cliente getCliente () {
return cliente ;
}
public String getCorpo () {
return corpo ;
}
public int getId () {
return id ;
}
public NewsLetter getNewsLetter () {
return newsLetter ;
}
public String getNome () {
return nome ;
}
public void setAgendamento ( Collection < Agendamento > agendamento ) {
this . agendamento = agendamento ;
}
public void setBaseEmail ( Collection < BaseEmail > baseEmail ) {
this . baseEmail = baseEmail ;
}
public void setCliente ( Cliente cliente ) {
this . cliente = cliente ;
}
public void setCorpo ( String corpo ) {
this . corpo = corpo ;
}
public void setId ( int id ) {
this . id = id ;
}
public void setNewsLetter ( NewsLetter newsLetter ) {
this . newsLetter = newsLetter ;
}
public void setNome ( String nome ) {
this . nome = nome ;
}
}
trgpwild 14 de set. de 2007
Jah consegui resolver meu problema pessoal, valeu pela atenção.
O problema era que eu estava dizendo em mais de um lugar a mesma coisa para fazer o mapeamento.
Isso que eh framework o resto eh conversa…
Enquanto q outros sobrescreveriam a nova configuração, o hibernate diz que naum acha a nova classe que estah sendo mapeada…