Olá pessoal,
novato tentando sair do DAO para JPA fazendo uns testes
e dando erro…
Alguém já passou por essa situação onde a tabela nota fiscal tem campo auto incremento e passa esse numero para nota fiscal item vi alguns exemplos e não sei se dessa forma está certo e está dando erro …
Exception in thread "main" Local Exception Stack:
Exception [TOPLINK-7154] (Oracle TopLink Essentials - 2006.8 (Build 060830)): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: The attribute [itens] in entity class [class bar.model.NotaFiscal] has a mappedBy value of [NotaFiscal] which does not exist in its owning entity class [class bar.model.NotaFiscalItem]. If the owning entity class is a @MappedSuperclass, this is invalid, and your attribute should reference the correct subclass.
Exception in thread "main" Local Exception Stack:
Exception [TOPLINK-7154] (Oracle TopLink Essentials - 2006.8 (Build 060830)): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: The attribute [itens] in entity class [class bar.model.NotaFiscal] has a mappedBy value of [NotaFiscal] which does not exist in its owning entity class [class bar.model.NotaFiscalItem]. If the owning entity class is a @MappedSuperclass, this is invalid, and your attribute should reference the correct subclass.
se alguém puder me ajudar agradeceria…
abs
@Entity
public class NotaFiscal {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int nrnota;
private String dtemissao;
private String dtsaida;
private String nrcnpj;
@OneToMany(mappedBy="NotaFiscal", fetch = FetchType.LAZY )
private Collection<NotaFiscalItem> itens;
public int getNrnota() {
return nrnota;
}
public void setNrnota(int nrnota) {
this.nrnota = nrnota;
}
public String getDtemissao() {
return dtemissao;
}
public void setDtemissao(String dtemissao) {
this.dtemissao = dtemissao;
}
public String getDtsaida() {
return dtsaida;
}
public void setDtsaida(String dtsaida) {
this.dtsaida = dtsaida;
}
public String getNrcnpj() {
return nrcnpj;
}
public void setNrcnpj(String nrcnpj) {
this.nrcnpj = nrcnpj;
}
public Collection<NotaFiscalItem> getItens() {
return itens;
}
public void setItens(Collection<NotaFiscalItem> itens) {
this.itens = itens;
}
}
----
@Entity
public class NotaFiscalItem {
@Id
private int iditem;
private int nrnota;
private int nritemnota;
private int codproduto;
private int qtdproduto;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name="nrnota", insertable=true, updatable=true)
private NotaFiscal nota;
public int getNrnota() {
return nrnota;
}
public void setNrnota(int nrnota) {
this.nrnota = nrnota;
}
public int getNritemnota() {
return nritemnota;
}
public void setNritemnota(int nritemnota) {
this.nritemnota = nritemnota;
}
public int getCodproduto() {
return codproduto;
}
public void setCodproduto(int codproduto) {
this.codproduto = codproduto;
}
public int getQtdproduto() {
return qtdproduto;
}
public void setQtdproduto(int qtdproduto) {
this.qtdproduto = qtdproduto;
}
public int getIditem() {
return iditem;
}
public void setIditem(int iditem) {
this.iditem = iditem;
}
public NotaFiscal getNota() {
return nota;
}
public void setNota(NotaFiscal nota) {
this.nota = nota;
}
}
---
Exception in thread "main" Local Exception Stack:
Exception [TOPLINK-7154] (Oracle TopLink Essentials - 2006.8 (Build 060830)): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: The attribute [itens] in entity class [class bar.model.NotaFiscal] has a mappedBy value of [NotaFiscal] which does not exist in its owning entity class [class bar.model.NotaFiscalItem]. If the owning entity class is a @MappedSuperclass, this is invalid, and your attribute should reference the correct subclass.
at oracle.toplink.essentials.exceptions.ValidationException.noMappedByAttributeFound(ValidationException.java:1104)
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataValidator.throwNoMappedByAttributeFound(MetadataValidator.java:196)
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.RelationshipAccessor.getOwningMapping(RelationshipAccessor.java:126)
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.OneToManyAccessor.process(OneToManyAccessor.java:104)
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.RelationshipAccessor.processRelationship(RelationshipAccessor.java:250)
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.processRelationshipDescriptors(MetadataProject.java:513)
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.process(MetadataProject.java:445)
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.processAnnotations(MetadataProcessor.java:203)
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.processORMetadata(EntityManagerSetupImpl.java:993)
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:501)
at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.callPredeploy(JavaSECMPInitializer.java:145)
at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initPersistenceUnits(JavaSECMPInitializer.java:225)
at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initialize(JavaSECMPInitializer.java:240)
at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initializeFromMain(JavaSECMPInitializer.java:277)
at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.getJavaSECMPInitializer(JavaSECMPInitializer.java:80)
at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:118)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
at bar.persistence.BaseDao1.<init>(BaseDao1.java:13)
at bar.client.Client1.main(Client1.java:20)
------------