rof20004 19 de nov. de 2012
Voce nao postou o codigo do seu HibernateUtil.
MiguelCP 19 de nov. de 2012
Cara tenta algo como:
EntityTransaction tx = em.getTransaction();
try{
tx.begin();
sessao.save(entity);
tx.commit();
sessao.close();
}catch .....
ou tente ver se está assim:
protected Session session ;
protected Session getSesseion () {
return HibernateUtil .getInstance () .getSession () ;
}
protected void savingPojo ( Serializable pojo ) {
Session sessao = getSesseion () ;
sessao .saveOrUpdate ( pojo ) ;
sessao .beginTransaction () .commit () ;
sessao .close () ;
}
Aliáis vai ter o aljug java day II dia 01/12/12 mais informações no blog do Aljug http://aljug.blogspot.com as inscrições www.eventick.com.br/aljugjavaday
Marcelo_de_Andrade 19 de nov. de 2012
Irei analisar quando chegar em casa, obrigado. O incrível é que desta mesma forma, funciona com outra classe.
@MiguelCP
Já estou inscrito, nos vemos por lá.
MiguelCP 19 de nov. de 2012
Ah, legal!
Quando fizer os testes posta aqui se conseguiu ou não assim qualquer coisa posso te ajudar.
Marcelo_de_Andrade 19 de nov. de 2012
Tentei das outras formas porém a mesma coisa. Até coloquei o código dentro do try/catch e mesmo assim não me retornou erro.
Esse é o HibernateUtil:
package dao ;
import org.hibernate.HibernateException ;
import org.hibernate.SessionFactory ;
import org.hibernate.cfg.Configuration ;
import org.hibernate.service.ServiceRegistry ;
import org.hibernate.service.ServiceRegistryBuilder ;
public class HibernateUtil {
private static SessionFactory sessionFactory ;
private static SessionFactory sessionFactory ()
throws HibernateException {
Configuration configuration = new Configuration ();
configuration . configure ();
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder ()
. applySettings ( configuration . getProperties ())
. buildServiceRegistry ();
sessionFactory = configuration . buildSessionFactory ( serviceRegistry );
return sessionFactory ;
}
public static SessionFactory getSessionFactory (){
return sessionFactory ();
}
}
rof20004 20 de nov. de 2012
Uma pergunta, voce utiliza que tipo de configuracao do hibernate ? hibernate.cfg.xml ? hibernate.properties ? Esta usando hibernate 4 ?
Marcelo_de_Andrade 21 de nov. de 2012
Opa! Desculpa a demora. Estou usando o cf.xml e nele eu tinha esquecido de mapear a classe Chat, porém quando a inclui ele me apresentou erro:
& lt ;! DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd" & gt ;
& lt ; hibernate-configuration & gt ;
& lt ; session-factory & gt ;
& lt ; property name = "hibernate.connection.driver_class" & gt ; com . mysql . jdbc . Driver & lt ;/ property & gt ;
& lt ; property name = "hibernate.connection.url" & gt ; jdbc : mysql :// localhost : 3306 / chat & lt ;/ property & gt ;
& lt ; property name = "hibernate.connection.user" & gt ; root & lt ;/ property & gt ;
& lt ; property name = "hibernate.connection.password" & gt ;******& lt ;/ property & gt ;
& lt ; property name = "dialect" & gt ; org . hibernate . dialect . MySQLDialect & lt ;/ property & gt ;
& lt ; property name = "show_sql" & gt ; true & lt ;/ property & gt ;
& lt ; mapping class = "model.Usuario" /& gt ;
& lt ; mapping class = "controller.Chat" /& gt ;
& lt ;/ session-factory & gt ;
& lt ;/ hibernate-configuration & gt ;
21 / 11 / 2012 01 : 51 : 52 org . apache . catalina . core . StandardWrapperValve invoke
GRAVE : Servlet . service () for servlet [ Faces Servlet ] in context with path [ / ChatApplication ] threw exception [ org . hibernate . MappingException : Could not determine type for : controller . UsuarioBean , at table : chat , for columns : [ org . hibernate . mapping . Column ( usuario_destino )]] with root cause
org . hibernate . MappingException : Could not determine type for : controller . UsuarioBean , at table : chat , for columns : [ org . hibernate . mapping . Column ( usuario_destino )]
at org . hibernate . mapping . SimpleValue . getType ( SimpleValue . java : 316 )
at org . hibernate . mapping . SimpleValue . isValid ( SimpleValue . java : 294 )
at org . hibernate . mapping . Property . isValid ( Property . java : 238 )
at org . hibernate . mapping . PersistentClass . validate ( PersistentClass . java : 469 )
at org . hibernate . mapping . RootClass . validate ( RootClass . java : 270 )
at org . hibernate . cfg . Configuration . validate ( Configuration . java : 1294 )
at org . hibernate . cfg . Configuration . buildSessionFactory ( Configuration . java : 1742 )
at dao . HibernateUtil . sessionFactory ( HibernateUtil . java : 23 )
at dao . HibernateUtil . getSessionFactory ( HibernateUtil . java : 29 )
at dao . UsuarioDao . & lt ; init & gt ;( UsuarioDao . java : 10 )
at controller . Principal . entrarSala ( Principal . java : 44 )
at sun . reflect . NativeMethodAccessorImpl . invoke0 ( Native Method )
at sun . reflect . NativeMethodAccessorImpl . invoke ( Unknown Source )
at sun . reflect . DelegatingMethodAccessorImpl . invoke ( Unknown Source )
at java . lang . reflect . Method . invoke ( Unknown Source )
at org . apache . el . parser . AstValue . invoke ( AstValue . java : 262 )
at org . apache . el . MethodExpressionImpl . invoke ( MethodExpressionImpl . java : 278 )
at com . sun . faces . facelets . el . TagMethodExpression . invoke ( TagMethodExpression . java : 105 )
at javax . faces . component . MethodBindingMethodExpressionAdapter . invoke ( MethodBindingMethodExpressionAdapter . java : 88 )
at com . sun . faces . application . ActionListenerImpl . processAction ( ActionListenerImpl . java : 102 )
at javax . faces . component . UICommand . broadcast ( UICommand . java : 315 )
at javax . faces . component . UIViewRoot . broadcastEvents ( UIViewRoot . java : 794 )
at javax . faces . component . UIViewRoot . processApplication ( UIViewRoot . java : 1259 )
at com . sun . faces . lifecycle . InvokeApplicationPhase . execute ( InvokeApplicationPhase . java : 81 )
at com . sun . faces . lifecycle . Phase . doPhase ( Phase . java : 101 )
at com . sun . faces . lifecycle . LifecycleImpl . execute ( LifecycleImpl . java : 118 )
at javax . faces . webapp . FacesServlet . service ( FacesServlet . java : 593 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 304 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 210 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 240 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 164 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 164 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 100 )
at org . apache . catalina . valves . AccessLogValve . invoke ( AccessLogValve . java : 562 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 118 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 394 )
at org . apache . coyote . http11 . Http11Processor . process ( Http11Processor . java : 243 )
at org . apache . coyote . http11 . Http11Protocol$Http11ConnectionHandler . process ( Http11Protocol . java : 188 )
at org . apache . coyote . http11 . Http11Protocol$Http11ConnectionHandler . process ( Http11Protocol . java : 166 )
at org . apache . tomcat . util . net . JIoEndpoint$SocketProcessor . run ( JIoEndpoint . java : 302 )
at java . util . concurrent . ThreadPoolExecutor$Worker . runTask ( Unknown Source )
at java . util . concurrent . ThreadPoolExecutor$Worker . run ( Unknown Source )
at java . lang . Thread . run ( Unknown Source )
package controller ;
import javax.faces.bean.ManagedBean ;
import javax.faces.bean.SessionScoped ;
import observer.Observador ;
import model.Usuario ;
@ManagedBean
@SessionScoped
public class UsuarioBean implements Observador {
private Usuario usuario ;
public UsuarioBean (){
this . usuario = new Usuario ();
}
public Usuario getUsuario () {
return usuario ;
}
public void setUsuario ( Usuario usuario ) {
this . usuario = usuario ;
}
@Override
public void atualizarMensagem ( String mensagem ) {
System . out . println ( getUsuario (). getApelido () + " : " + mensagem );
}
@Override
public String toString (){
return getUsuario (). getApelido ();
}
}
+-----------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| usuario_origem | varchar(30) | NO | | NULL | |
| usuario_destino | varchar(30)| YES | | NULL | |
| data_mensagem| datetime NO | | NULL | |
| mensagem | varchar(140) | NO | | NULL | |
+-----------------+--------------+------+-----+---------+-------+
Marcelo_de_Andrade 21 de nov. de 2012
Ainda fuçando aqui e não consigo encontrar uma solução.
Chat.java
package controller ;
import java.util.ArrayList ;
import java.util.Date ;
import java.util.List ;
import javax.faces.bean.ManagedProperty ;
import dao.ChatDao ;
import observer.Objeto ;
import observer.Observador ;
import model.ChatTable ;
public class Chat implements Objeto {
private UsuarioBean usuarioDestino ;
private Date dataHoraMensagem ;
private String mensagemPublica ;
private String mensagemPrivada ;
private UsuarioBean usuarioOrigem ;
private List & lt ; Observador & gt ; usuarioConectado ;
private static Chat instancia ;
@ManagedProperty ( value = "#{usuarioBean}" )
private UsuarioBean usuarioBean ;
public Chat (){
this . usuarioConectado = new ArrayList & lt ; Observador & gt ;();
}
public UsuarioBean getUsuarioOrigem () {
return usuarioOrigem ;
}
public void setUsuarioOrigem ( UsuarioBean usuarioOrigem ) {
this . usuarioOrigem = usuarioOrigem ;
}
public UsuarioBean getUsuarioDestino () {
return usuarioDestino ;
}
public void setUsuarioDestino ( UsuarioBean usuarioDestino ) {
this . usuarioDestino = usuarioDestino ;
}
public static Chat getInstancia (){
if ( instancia == null ){
instancia = new Chat ();
}
return instancia ;
}
public String getMensagemPrivada () {
return mensagemPrivada ;
}
public void setMensagemPrivada ( String mensagemPrivada ) {
this . mensagemPrivada = this . usuarioOrigem + " para "
+ this . usuarioDestino + " : " + mensagemPrivada ;
try {
ChatTable c = new ChatTable ();
c . setUsuarioOrigem ( this . usuarioOrigem );
c . setUsuarioDestino ( this . usuarioDestino );
c . setMensagemPrivada ( mensagemPrivada );
c . setDataHoraMensagem ( new Date ());
System . out . println ( c . getUsuarioOrigem ());
System . out . println ( c . getUsuarioDestino ());
try {
ChatDao cdao = new ChatDao ();
cdao . inserirMensagemPrivada ( c );
} catch ( Exception e ) {
// TODO: handle exception
System . out . println ( e . getMessage ());
}
} catch ( Exception e ) {
// TODO: handle exception
System . out . println ( e . getMessage ());
}
}
public String getMensagemPublica () {
return mensagemPublica ;
}
public void setMensagemPublica ( String mensagemPublica ) {
this . mensagemPublica = mensagemPublica ;
notificarObservadores ();
}
public List & lt ; Observador & gt ; getUsuarioConectado () {
return usuarioConectado ;
}
public Date getDataHoraMensagem () {
return dataHoraMensagem ;
}
public void setDataHoraMensagem ( Date dataHoraMensagem ) {
this . dataHoraMensagem = dataHoraMensagem ;
}
@Override
public void adicionarObservador ( UsuarioBean usuarioBean ) {
this . usuarioConectado . add ( usuarioBean );
}
@Override
public void removerObservador ( UsuarioBean usuarioBean ) {
this . usuarioConectado . remove ( usuarioBean );
}
@Override
public void notificarObservadores () {
for ( Observador observador : this . usuarioConectado ){
observador . atualizarMensagem ( this . usuarioOrigem + this . mensagemPublica );
}
}
}
ChatTable.java
package model ;
import java.util.Date ;
import javax.persistence.Column ;
import javax.persistence.Entity ;
import javax.persistence.GeneratedValue ;
import javax.persistence.GenerationType ;
import javax.persistence.Id ;
import javax.persistence.Table ;
import controller.UsuarioBean ;
@Entity
@Table ( name = "chat" )
public class ChatTable {
@Id
@GeneratedValue ( strategy = GenerationType . AUTO )
@Column
private int id ;
@Column ( name = "usuario_destino" )
private UsuarioBean usuarioDestino ;
@Column ( name = "usuario_origem" )
private UsuarioBean usuarioOrigem ;
@Column ( name = "data_mensagem" )
private Date dataHoraMensagem ;
@Column ( name = "mensagem" )
private String mensagemPublica ;
@Column ( name = "mensagem" )
private String mensagemPrivada ;
public int getId () {
return id ;
}
public void setId ( int id ) {
this . id = id ;
}
public UsuarioBean getUsuarioOrigem () {
return usuarioOrigem ;
}
public void setUsuarioOrigem ( UsuarioBean usuarioOrigem ) {
this . usuarioOrigem = usuarioOrigem ;
}
public UsuarioBean getUsuarioDestino () {
return usuarioDestino ;
}
public void setUsuarioDestino ( UsuarioBean usuarioDestino ) {
this . usuarioDestino = usuarioDestino ;
}
public Date getDataHoraMensagem () {
return dataHoraMensagem ;
}
public void setDataHoraMensagem ( Date dataHoraMensagem ) {
this . dataHoraMensagem = dataHoraMensagem ;
}
public String getMensagemPublica () {
return mensagemPublica ;
}
public void setMensagemPublica ( String mensagemPublica ) {
this . mensagemPublica = mensagemPublica ;
}
public String getMensagemPrivada () {
return mensagemPrivada ;
}
public void setMensagemPrivada ( String mensagemPrivada ) {
this . mensagemPrivada = mensagemPrivada ;
}
}
package controller ;
import javax.faces.bean.ManagedBean ;
import javax.faces.bean.SessionScoped ;
import observer.Observador ;
import model.Usuario ;
@ManagedBean
@SessionScoped
public class UsuarioBean implements Observador {
private Usuario usuario ;
public UsuarioBean (){
this . usuario = new Usuario ();
}
public Usuario getUsuario () {
return usuario ;
}
public void setUsuario ( Usuario usuario ) {
this . usuario = usuario ;
}
@Override
public void atualizarMensagem ( String mensagem ) {
System . out . println ( getUsuario (). getApelido () + " : " + mensagem );
}
@Override
public String toString (){
return getUsuario (). getApelido ();
}
}
Principal.java
UsuarioBean . java
package controller ;
import javax.faces.bean.ManagedBean ;
import javax.faces.bean.SessionScoped ;
import observer.Observador ;
import model.Usuario ;
@ManagedBean
@SessionScoped
public class UsuarioBean implements Observador {
private Usuario usuario ;
public UsuarioBean (){
this . usuario = new Usuario ();
}
public Usuario getUsuario () {
return usuario ;
}
public void setUsuario ( Usuario usuario ) {
this . usuario = usuario ;
}
@Override
public void atualizarMensagem ( String mensagem ) {
System . out . println ( getUsuario (). getApelido () + " : " + mensagem );
}
@Override
public String toString (){
return getUsuario (). getApelido ();
}
}
package controller ;
import java.util.Date ;
import javax.faces.bean.ManagedBean ;
import javax.faces.bean.ManagedProperty ;
import javax.faces.context.FacesContext ;
import javax.servlet.http.HttpSession ;
import model.Usuario ;
import dao.* ;
import controller.* ;
@ManagedBean
public class Principal {
@ManagedProperty ( value = "#{usuarioBean}" )
private UsuarioBean usuarioBean ;
public Chat chat ;
public Principal (){
this . chat = Chat . getInstancia ();
}
public UsuarioBean getUsuarioBean () {
return usuarioBean ;
}
public void setUsuarioBean ( UsuarioBean usuarioBean ) {
this . usuarioBean = usuarioBean ;
}
public Chat getChat () {
return chat ;
}
public void setChat ( Chat chat ) {
this . chat = chat ;
}
public String entrarSala (){
UsuarioDao udao = new UsuarioDao ();
udao . inserirUsuario ( usuarioBean . getUsuario ());
chat . adicionarObservador ( usuarioBean );
chat . setUsuarioOrigem ( usuarioBean );
return "chat" ;
}
public String sairSala (){
Usuario update = usuarioBean . getUsuario ();
update . setDataHoraSaida ( new Date ());
UsuarioDao udao = new UsuarioDao ();
udao . alterarUsuario ( update );
chat . removerObservador ( usuarioBean );
FacesContext context = FacesContext . getCurrentInstance ();
context . getExternalContext (). getSessionMap (). remove ( "#{usuarioBean}" );
HttpSession session = ( HttpSession ) FacesContext . getCurrentInstance ()
. getExternalContext (). getSession ( false );
session . invalidate ();
return "index" ;
}
}
hibernate.cfg.xml
& lt ;! DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd" & gt ;
& lt ; hibernate-configuration & gt ;
& lt ; session-factory & gt ;
& lt ; property name = "hibernate.connection.driver_class" & gt ; com . mysql . jdbc . Driver & lt ;/ property & gt ;
& lt ; property name = "hibernate.connection.url" & gt ; jdbc : mysql :// localhost : 3306 / chat & lt ;/ property & gt ;
& lt ; property name = "hibernate.connection.user" & gt ; root & lt ;/ property & gt ;
& lt ; property name = "hibernate.connection.password" & gt ; marcelo . 0201 & lt ;/ property & gt ;
& lt ; property name = "dialect" & gt ; org . hibernate . dialect . MySQLDialect & lt ;/ property & gt ;
& lt ; property name = "show_sql" & gt ; true & lt ;/ property & gt ;
& lt ; mapping class = "model.Usuario" /& gt ;
& lt ; mapping class = "model.ChatTable" /& gt ;
& lt ;/ session-factory & gt ;
& lt ;/ hibernate-configuration & gt ;
Erro:
AVISO : # { principal . entrarSala } : org . hibernate . MappingException : Could not determine type for : controller . UsuarioBean , at table : chat , for columns : [ org . hibernate . mapping . Column ( usuario_origem )]
javax . faces . FacesException : # { principal . entrarSala } : org . hibernate . MappingException : Could not determine type for : controller . UsuarioBean , at table : chat , for columns : [ org . hibernate . mapping . Column ( usuario_origem )]
at com . sun . faces . application . ActionListenerImpl . processAction ( ActionListenerImpl . java : 118 )
at javax . faces . component . UICommand . broadcast ( UICommand . java : 315 )
at javax . faces . component . UIViewRoot . broadcastEvents ( UIViewRoot . java : 794 )
at javax . faces . component . UIViewRoot . processApplication ( UIViewRoot . java : 1259 )
at com . sun . faces . lifecycle . InvokeApplicationPhase . execute ( InvokeApplicationPhase . java : 81 )
at com . sun . faces . lifecycle . Phase . doPhase ( Phase . java : 101 )
at com . sun . faces . lifecycle . LifecycleImpl . execute ( LifecycleImpl . java : 118 )
at javax . faces . webapp . FacesServlet . service ( FacesServlet . java : 593 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 304 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 210 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 240 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 164 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 164 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 100 )
at org . apache . catalina . valves . AccessLogValve . invoke ( AccessLogValve . java : 562 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 118 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 394 )
at org . apache . coyote . http11 . Http11Processor . process ( Http11Processor . java : 243 )
at org . apache . coyote . http11 . Http11Protocol$Http11ConnectionHandler . process ( Http11Protocol . java : 188 )
at org . apache . tomcat . util . net . JIoEndpoint$SocketProcessor . run ( JIoEndpoint . java : 302 )
at java . util . concurrent . ThreadPoolExecutor$Worker . runTask ( Unknown Source )
at java . util . concurrent . ThreadPoolExecutor$Worker . run ( Unknown Source )
at java . lang . Thread . run ( Unknown Source )
Caused by : javax . faces . el . EvaluationException : org . hibernate . MappingException : Could not determine type for : controller . UsuarioBean , at table : chat , for columns : [ org . hibernate . mapping . Column ( usuario_origem )]
at javax . faces . component . MethodBindingMethodExpressionAdapter . invoke ( MethodBindingMethodExpressionAdapter . java : 102 )
at com . sun . faces . application . ActionListenerImpl . processAction ( ActionListenerImpl . java : 102 )
... 22 more
Caused by : org . hibernate . MappingException : Could not determine type for : controller . UsuarioBean , at table : chat , for columns : [ org . hibernate . mapping . Column ( usuario_origem )]
at org . hibernate . mapping . SimpleValue . getType ( SimpleValue . java : 316 )
at org . hibernate . mapping . SimpleValue . isValid ( SimpleValue . java : 294 )
at org . hibernate . mapping . Property . isValid ( Property . java : 238 )
at org . hibernate . mapping . PersistentClass . validate ( PersistentClass . java : 469 )
at org . hibernate . mapping . RootClass . validate ( RootClass . java : 270 )
at org . hibernate . cfg . Configuration . validate ( Configuration . java : 1294 )
at org . hibernate . cfg . Configuration . buildSessionFactory ( Configuration . java : 1742 )
at dao . HibernateUtil . sessionFactory ( HibernateUtil . java : 23 )
at dao . HibernateUtil . getSessionFactory ( HibernateUtil . java : 29 )
at dao . UsuarioDao . & lt ; init & gt ;( UsuarioDao . java : 10 )
at controller . Principal . entrarSala ( Principal . java : 44 )
at sun . reflect . NativeMethodAccessorImpl . invoke0 ( Native Method )
at sun . reflect . NativeMethodAccessorImpl . invoke ( Unknown Source )
at sun . reflect . DelegatingMethodAccessorImpl . invoke ( Unknown Source )
at java . lang . reflect . Method . invoke ( Unknown Source )
at org . apache . el . parser . AstValue . invoke ( AstValue . java : 262 )
at org . apache . el . MethodExpressionImpl . invoke ( MethodExpressionImpl . java : 278 )
at com . sun . faces . facelets . el . TagMethodExpression . invoke ( TagMethodExpression . java : 105 )
at javax . faces . component . MethodBindingMethodExpressionAdapter . invoke ( MethodBindingMethodExpressionAdapter . java : 88 )
... 23 more
21 / 11 / 2012 12 : 19 : 04 org . apache . catalina . core . StandardWrapperValve invoke
GRAVE : Servlet . service () for servlet [ Faces Servlet ] in context with path [ / ChatApplication ] threw exception [ org . hibernate . MappingException : Could not determine type for : controller . UsuarioBean , at table : chat , for columns : [ org . hibernate . mapping . Column ( usuario_origem )]] with root cause
org . hibernate . MappingException : Could not determine type for : controller . UsuarioBean , at table : chat , for columns : [ org . hibernate . mapping . Column ( usuario_origem )]
at org . hibernate . mapping . SimpleValue . getType ( SimpleValue . java : 316 )
at org . hibernate . mapping . SimpleValue . isValid ( SimpleValue . java : 294 )
at org . hibernate . mapping . Property . isValid ( Property . java : 238 )
at org . hibernate . mapping . PersistentClass . validate ( PersistentClass . java : 469 )
at org . hibernate . mapping . RootClass . validate ( RootClass . java : 270 )
at org . hibernate . cfg . Configuration . validate ( Configuration . java : 1294 )
at org . hibernate . cfg . Configuration . buildSessionFactory ( Configuration . java : 1742 )
at dao . HibernateUtil . sessionFactory ( HibernateUtil . java : 23 )
at dao . HibernateUtil . getSessionFactory ( HibernateUtil . java : 29 )
at dao . UsuarioDao . & lt ; init & gt ;( UsuarioDao . java : 10 )
at controller . Principal . entrarSala ( Principal . java : 44 )
at sun . reflect . NativeMethodAccessorImpl . invoke0 ( Native Method )
at sun . reflect . NativeMethodAccessorImpl . invoke ( Unknown Source )
at sun . reflect . DelegatingMethodAccessorImpl . invoke ( Unknown Source )
at java . lang . reflect . Method . invoke ( Unknown Source )
at org . apache . el . parser . AstValue . invoke ( AstValue . java : 262 )
at org . apache . el . MethodExpressionImpl . invoke ( MethodExpressionImpl . java : 278 )
at com . sun . faces . facelets . el . TagMethodExpression . invoke ( TagMethodExpression . java : 105 )
at javax . faces . component . MethodBindingMethodExpressionAdapter . invoke ( MethodBindingMethodExpressionAdapter . java : 88 )
at com . sun . faces . application . ActionListenerImpl . processAction ( ActionListenerImpl . java : 102 )
at javax . faces . component . UICommand . broadcast ( UICommand . java : 315 )
at javax . faces . component . UIViewRoot . broadcastEvents ( UIViewRoot . java : 794 )
at javax . faces . component . UIViewRoot . processApplication ( UIViewRoot . java : 1259 )
at com . sun . faces . lifecycle . InvokeApplicationPhase . execute ( InvokeApplicationPhase . java : 81 )
at com . sun . faces . lifecycle . Phase . doPhase ( Phase . java : 101 )
at com . sun . faces . lifecycle . LifecycleImpl . execute ( LifecycleImpl . java : 118 )
at javax . faces . webapp . FacesServlet . service ( FacesServlet . java : 593 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 304 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 210 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 240 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 164 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 164 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 100 )
at org . apache . catalina . valves . AccessLogValve . invoke ( AccessLogValve . java : 562 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 118 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 394 )
at org . apache . coyote . http11 . Http11Processor . process ( Http11Processor . java : 243 )
at org . apache . coyote . http11 . Http11Protocol$Http11ConnectionHandler . process ( Http11Protocol . java : 188 )
at org . apache . tomcat . util . net . JIoEndpoint$SocketProcessor . run ( JIoEndpoint . java : 302 )
at java . util . concurrent . ThreadPoolExecutor$Worker . runTask ( Unknown Source )
at java . util . concurrent . ThreadPoolExecutor$Worker . run ( Unknown Source )
at java . lang . Thread . run ( Unknown Source )
Marcelo_de_Andrade 21 de nov. de 2012
rof20004 21 de nov. de 2012
org . hibernate . MappingException : Could not determine type for : controller . UsuarioBean , at table : chat , for columns : [ org . hibernate . mapping . Column ( usuario_origem )]
Ao que me parece, ta dando erro porque voce esta criando anotacao de coluna para um objeto, e no banco de dados em questao, ele nao aceita esse tipo de coluna, ou é varchar, ou byte, ou int e etc etc.
ou entao nao existe essa coluna no banco “usuario_origem”
Marcelo_de_Andrade 21 de nov. de 2012
Obrigado, rof20004. Não me atentei ao fato de que usurio_origem na minha aplicação, recebe um UsuarioBean através do @ManagedProperty
Irei tentar fazer algo para contornar o problema. Tem alguma dica?
douglas_arantes 21 de nov. de 2012
Pode ter duas colunas com o mesmo nome??
@Column ( name = "mensagem" )
private String mensagemPublica ;
@Column ( name = "mensagem" )
private String mensagemPrivada ;
Marcelo_de_Andrade 21 de nov. de 2012
douglas_arantes, nem eu sei te responder isso. Fiz dessa forma pois estava tratando duas propriedades diferentes que iriam para a mesma coluna. Mas não pode? Caso não, irei corrigir.
@edit
É não pode, fazendo algumas alterações aqui, apresentou o erro:
javax .servlet .ServletException : org .hibernate .MappingException : Repeated column in mapping for entity : model .ChatTable column : mensagem ( should be mapped with insert = "false" update = "false" )
javax .faces .webapp .FacesServlet .service ( FacesServlet .java :606 )
Já estou corrigindo.
douglas_arantes 22 de nov. de 2012
Eu sei pouquíssima coisa de Hibernate, vou estuda-lo mais a frente, mas acho que talvez um dos possíveis erros fosse ter duas tabelas com o mesmo nome.
Caso consiga resolver esse problema post aqui como contornou essa situação.
Até mais.
Marcelo_de_Andrade 22 de nov. de 2012
Obrigado pela ajuda. O problema era que eu estava tentando salvar um objeto tipo Usuario quando deveria ser String e bastou alterar para Usuario.getApelido() na coluna usuario_destino.