Boa noite,
Sou novo no fórum assim como usando hibernate e o vraptor. Vou realizar um curso de VRaptor final de semana que vem. Para conseguir absorver mais o que irá ser passado em aula resolvi por conta própria antecipar o aprendizado. Para isso peguei a apostila fj28 da caelum e estou estudando.
Na parte de configurar o VRpator, utilizei um tutorial encontrado na internet.
http://felipeassoline.wordpress.com/2010/02/27/configurando-projeto-netbeans-vraptor/
Bem, até aí consegui fazer tudo. O problema é que após configurar o VRaptor dessa maneiro não consigo acessar mais o banco de dados com o Hibernate. Quando executo a minha função de alterar algum elemento no banco de dados acontece os seguinte retorno (Utilizo o Netbeans).
Hibernate:
select
produto0_.id as id0_0_,
produto0_.descricao as descricao0_0_,
produto0_.nome as nome0_0_,
produto0_.preco as preco0_0_
from
Produto produto0_
where
produto0_.id=?
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [br.com.fj28.modelo.Produto#1]
at org.hibernate.impl.SessionFactoryImpl$1.handleEntityNotFound(SessionFactoryImpl.java:377)
at org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:79)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:68)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
at br.com.fj28.modelo.Produto$$EnhancerByCGLIB$$4c0b8f3c.setPreco(<generated>)
at br.com.fj28.testes.AlteracaoDeProduto.alteraProduto(AlteracaoDeProduto.java:26)
at br.com.fj28.testes.AlteracaoDeProduto.main(AlteracaoDeProduto.java:19)
Java Result: 1
CONSTRUÍDO COM SUCESSO (tempo total: 2 segundos)
Quando executo a função de remover acontece...
Hibernate:
select
produto0_.id as id2_0_,
produto0_.descricao as descricao2_0_,
produto0_.nome as nome2_0_,
produto0_.preco as preco2_0_
from
Produto produto0_
where
produto0_.id=?
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [br.com.fj28.modelo.Produto#1]
at org.hibernate.impl.SessionFactoryImpl$1.handleEntityNotFound(SessionFactoryImpl.java:377)
at org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:79)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:68)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at org.hibernate.engine.StatefulPersistenceContext.unproxyAndReassociate(StatefulPersistenceContext.java:571)
at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:68)
at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:52)
at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:766)
at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:744)
at br.com.fj28.dao.ProdutoDao.remove(ProdutoDao.java:42)
at br.com.fj28.testes.RemocaoDeProduto.main(RemocaoDeProduto.java:20)
Java Result: 1
package br.com.fj28.controllers;
import br.com.caelum.vraptor.Resource;
import br.com.fj28.dao.ProdutoDao;
import br.com.fj28.modelo.Produto;
import java.util.List;
/**
*
* @author Usuario
*/
@Resource
public class ProdutosController {
private final ProdutoDao dao;
public ProdutosController(ProdutoDao dao) {
this.dao = dao;
}
public List<Produto> lista() {
return dao.listaTudo();
}
}
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<table>
<thead>
<tr>
<th>Nome</th>
<th>Descricao</th>
<th>Preço</th>
</tr>
</thead>
<tbody>
<c:forEach items="${produtoList}" var="produto">
<tr>
<td>${produto.nome }</td>
<td>${produto.descricao }</td>
<td>${produto.praco }</td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
15/01/2011 16:23:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/fj28] appears to have started a thread named [com.google.common.base.internal.Finalizer] but has failed to stop it. This is very likely to create a memory leak.
log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.
log4j:WARN No appenders could be found for logger (br.com.caelum.vraptor.config.BasicConfiguration).
log4j:WARN Please initialize the log4j system properly.
Hibernate:
select
this_.id as id0_0_,
this_.descricao as descricao0_0_,
this_.nome as nome0_0_,
this_.preco as preco0_0_
from
Produto this_
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{HH:mm:ss,SSS} %5p [%-20c{1}] %m%n"/>
</layout>
</appender>
<category name="org.vraptor">
<priority value="INFO" />
<appender-ref ref="stdout" />
</category>
<category name="com.thoughtworks">
<priority value="INFO" />
<appender-ref ref="stdout" />
</category>
<category name="br.com.caelum.vraptor">
<priority value="DEBUG" />
<appender-ref ref="stdout" />
</category>
<category name="org.springframework">
<priority value="INFO" />
<appender-ref ref="stdout" />
</category>
<category name="org.hibernate">
<priority value="DEBUG" />
<appender-ref ref="stdout" />
</category>
</log4j:configuration>
Alguém poderia me ajudar?
Obrigado.