Galera…seguinte:
To tentando usar o hibernate com annotations, mas to com um erro aki q naum sei mais pra onde correr…
Eh uma classe bem simples, so com o codigo e uma descricao, que representa o genero de um filme…
@Entity
@Table(name = "genero")
@SequenceGenerator(
name = "seq_genero",
sequenceName = "seq_genero"
)
public class Genero {
private Integer codigo;
@Id(generate = GeneratorType.SEQUENCE, generator = "seq_genero")
@Column(name = "genero_id")
public Integer getCodigo() {
return codigo;
}
public void setCodigo(Integer codigo) {
this.codigo = codigo;
}
private String descricao;
@Column(name = "nome")
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
}
E no meu hibernate.cfg.xml fiz o mapeamento assim…
<mapping class="br.unifor.locadora.model.Genero" />
Mas na execuçao…tah dando o seguinte erro:
org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping clazz="br.unifor.locadora.model.Genero"/>
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1322)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1284)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1266)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1233)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1161)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1147)
at br.unifor.locadora.hibernate.util.HibernateUtil.<clinit>(HibernateUtil.java:28)
at br.unifor.locadora.dao.GenericDAO.insert(GenericDAO.java:65)
at br.unifor.locadora.struts.action.GeneroAction.insert(GeneroAction.java:45)
at br.unifor.locadora.struts.action.GeneroAction.execute(GeneroAction.java:29)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:595)
Alguem pode me dar uma luz aew???
Vlw!!