pissike 16 de mar. de 2010
INFO: autocommit mode: false ?
TheKill 16 de mar. de 2010
procurei no hibernate.properties por essa informação,
e nao encontrei… também tinha reparado isso
onde altera?
att. Jonas
TheKill 16 de mar. de 2010
Consegui colocar autocomit true , mas também nao adiantou
Alguem pode ajudar?
TheKill 16 de mar. de 2010
Alguma alma solidária para ajudar? SHdiuAHSDUIashidu
Help-me xD~
Hebertbc 16 de mar. de 2010
Mais qualé o erro… num vi nenhum
TheKill 16 de mar. de 2010
Nao gera a tabela, na verdade parece nao fazer nada…
Fica aquele monte de msg ali, só que “nao faz nada” …
no hibernate.properts ta assim:
hibernate.dialect org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc:mysql://localhost:3306/caelum
hibernate.connection.username root
hibernate.connection.password
hibernate.show_sql true
hibernate.hbm2ddl.auto create
hibernate.connection.autocommit true
e no sysout ali, nao aparece nem o SQL
Hebertbc 16 de mar. de 2010
Estranho sempre criei tabelas assim e acredito que a mensagem é a mesma… vou testar aki
TheKill 16 de mar. de 2010
Hum, por favor, poste os resultados…
Estou indignado jah, não sei porque não esta criando as tabelas…
e tipo, eu defino ali… hibernate.show_sql = true…
e não mostra a !@ @#! do maldito SQL
SAHdiuHDSIushAIDusaIDUhusAID
att. jonas
TheKill 16 de mar. de 2010
classe produto
package br.com.caelum.hibernate ;
import java.util.Calendar ;
import javax.persistence.GeneratedValue ;
import javax.persistence.Id ;
import org.hibernate.annotations.Entity ;
@Entity
public class Produto {
@Id
@GeneratedValue
private Long id ;
private String nome ;
private double preco ;
private Calendar dataInicioVenda ;
public Long getId () {
return id ;
}
public void setId ( Long id ) {
this . id = id ;
}
public String getNome () {
return nome ;
}
public void setNome ( String nome ) {
this . nome = nome ;
}
public double getPreco () {
return preco ;
}
public void setPreco ( double preco ) {
this . preco = preco ;
}
public Calendar getDataInicioVenda () {
return dataInicioVenda ;
}
public void setDataInicioVenda ( Calendar dataInicioVenda ) {
this . dataInicioVenda = dataInicioVenda ;
}
}
classe para criar a tabela… talvez ajude para entenderem melhor
public class GeraTabelas {
public static void main ( String [] args ) {
// Cria uma configuração para a classe Produto
AnnotationConfiguration cfg = new AnnotationConfiguration ();
cfg . addAnnotatedClass ( Produto . class );
SchemaExport se = new SchemaExport ( cfg );
se . create ( true , true );
}
}
Hebertbc 16 de mar. de 2010
TheKill:
Hum, por favor, poste os resultados…
Estou indignado jah, não sei porque não esta criando as tabelas…
e tipo, eu defino ali… hibernate.show_sql = true…
e não mostra a !@ @#! do maldito SQL
SAHdiuHDSIushAIDusaIDUhusAID
att. jonas
Tae resultado.
(Edit) Coloquei pra mostrar o sql tbm mais como pode ver apareceu nda ñ.
INFO : autocommit mode : false
16 /03/ 2010 10 : 17 : 56 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : using driver : com . mysql . jdbc . Driver at URL : jdbc : mysql :// localhost / joficina
16 /03/ 2010 10 : 17 : 56 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : connection properties : { user = root }
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : RDBMS : MySQL , version : 5.1 . 41
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC driver : MySQL - AB JDBC Driver , version : mysql - connector - java - 5.1 . 6 ( Revision : $ { svn . Revision } )
16 /03/ 2010 10 : 17 : 56 org . hibernate . dialect . Dialect & lt ; init & gt ;
INFO : Using dialect : org . hibernate . dialect . MySQLDialect
16 /03/ 2010 10 : 17 : 56 org . hibernate . transaction . TransactionFactoryFactory buildTransactionFactory
INFO : Using default transaction strategy ( direct JDBC transactions )
16 /03/ 2010 10 : 17 : 56 org . hibernate . transaction . TransactionManagerLookupFactory getTransactionManagerLookup
INFO : No TransactionManagerLookup configured ( in JTA environment , use of read - write or transactional second - level cache is not recommended )
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Automatic flush during beforeCompletion (): enabled
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Automatic session close at end of transaction : enabled
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC batch size : 15
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC batch updates for versioned data : disabled
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Scrollable result sets : enabled
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC3 getGeneratedKeys (): enabled
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Connection release mode : auto
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Maximum outer join fetch depth : 2
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Default batch fetch size : 1
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Generate SQL with comments : disabled
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Order SQL updates by primary key : disabled
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Order SQL inserts for batching : disabled
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory createQueryTranslatorFactory
INFO : Query translator : org . hibernate . hql . ast . ASTQueryTranslatorFactory
16 /03/ 2010 10 : 17 : 56 org . hibernate . hql . ast . ASTQueryTranslatorFactory & lt ; init & gt ;
INFO : Using ASTQueryTranslatorFactory
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Query language substitutions : {}
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JPA - QL strict compliance : disabled
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Second - level cache : enabled
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Query cache : disabled
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory createCacheProvider
INFO : Cache provider : org . hibernate . cache . NoCacheProvider
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Optimize cache for minimal puts : disabled
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Structured second - level cache entries : disabled
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Echoing all SQL to stdout
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Statistics : disabled
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Deleted entity synthetic identifier rollback : enabled
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Default entity - mode : pojo
16 /03/ 2010 10 : 17 : 56 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Named query checking : enabled
16 /03/ 2010 10 : 17 : 56 org . hibernate . impl . SessionFactoryImpl & lt ; init & gt ;
INFO : building session factory
16 /03/ 2010 10 : 17 : 57 org . hibernate . impl . SessionFactoryObjectFactory addInstance
INFO : Not binding factory to JNDI , no JNDI name configured
16 /03/ 2010 10 : 17 : 57 org . hibernate . tool . hbm2ddl . SchemaExport execute
INFO : Running hbm2ddl schema export
16 /03/ 2010 10 : 17 : 57 org . hibernate . tool . hbm2ddl . SchemaExport execute
INFO : exporting generated schema to database
16 /03/ 2010 10 : 18 : 00 org . hibernate . tool . hbm2ddl . SchemaExport execute
INFO : schema export complete
TheKill 16 de mar. de 2010
porque não consigo os resultados positivos do projeto??
Se tivece um erro, ao menos eu saberia por onde procurar
TheKill 16 de mar. de 2010
pode postar seu hibernat.properts para eu ver?
sei la, nao sei oque pode ser
Hebertbc 16 de mar. de 2010
Tava olhando sua classe produto faltou as anotações dos outros campos…
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- -->
<property name= "hibernate.dialect" > org.hibernate.dialect.MySQLDialect</property>
<property name= "hibernate.connection.driver_class" > com.mysql.jdbc.Driver</property>
<property name= "hibernate.connection.url" > jdbc:mysql://localhost/joficina</property>
<property name= "hibernate.connection.username" > root</property>
<property name= "hibernate.use_identifier_rollback" > true</property>
<property name= "hibernate.transaction.auto_close_session" > true</property>
<property name= "hibernate.transaction.flush_before_completion" > true</property>
<property name= "hibernate.bytecode.use_reflection_optimizer" > true</property>
<mapping class= "com.joficina.base.Agendamento" />
<mapping class= "com.joficina.base.Cliente" />
<mapping class= "com.joficina.base.Fornecedor" />
<mapping class= "com.joficina.base.Movimento" />
<mapping class= "com.joficina.base.MovimentoCaixa" />
<mapping class= "com.joficina.base.Orcamento" />
<mapping class= "com.joficina.base.Produto" />
<mapping class= "com.joficina.base.RelacaoCaixa" />
<mapping class= "com.joficina.base.RelacaoOrcamento" />
<mapping class= "com.joficina.base.TipoPagamento" />
<mapping class= "com.joficina.base.Usuario" />
<mapping class= "com.joficina.base.Veiculo" />
</session-factory>
</hibernate-configuration>
TheKill 16 de mar. de 2010
é que estou tentando aprender… omg…
como assim faltou anotações?
Hebertbc 16 de mar. de 2010
Como sou preguiçoso… sempre mando gerar pelo netbeans a classe… mais acredito que falte o mapeamento de sua classe no hibernate…
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.joficina ;
import java.io.Serializable ;
import java.util.Date ;
import javax.persistence.Basic ;
import javax.persistence.Column ;
import javax.persistence.Entity ;
import javax.persistence.GeneratedValue ;
import javax.persistence.GenerationType ;
import javax.persistence.Id ;
import javax.persistence.NamedQueries ;
import javax.persistence.NamedQuery ;
import javax.persistence.Table ;
import javax.persistence.Temporal ;
import javax.persistence.TemporalType ;
/**
*
* @author suporte
*/
@Entity
@Table ( name = "produtox" )
@NamedQueries ({
@NamedQuery ( name = "ProdutoX.findAll" , query = "SELECT p FROM ProdutoX p" ),
@NamedQuery ( name = "ProdutoX.findById" , query = "SELECT p FROM ProdutoX p WHERE p.id = :id" ),
@NamedQuery ( name = "ProdutoX.findByNome" , query = "SELECT p FROM ProdutoX p WHERE p.nome = :nome" ),
@NamedQuery ( name = "ProdutoX.findByPreco" , query = "SELECT p FROM ProdutoX p WHERE p.preco = :preco" ),
@NamedQuery ( name = "ProdutoX.findByData" , query = "SELECT p FROM ProdutoX p WHERE p.data = :data" )})
public class ProdutoX implements Serializable {
private static final long serialVersionUID = 1L ;
@Id
@GeneratedValue ( strategy = GenerationType . IDENTITY )
@Basic ( optional = false )
@Column ( name = "id" )
private Integer id ;
@Basic ( optional = false )
@Column ( name = "nome" )
private String nome ;
@Basic ( optional = false )
@Column ( name = "preco" )
private double preco ;
@Basic ( optional = false )
@Column ( name = "data" )
@Temporal ( TemporalType . DATE )
private Date data ;
public ProdutoX () {
}
public ProdutoX ( Integer id ) {
this . id = id ;
}
public ProdutoX ( Integer id , String nome , double preco , Date data ) {
this . id = id ;
this . nome = nome ;
this . preco = preco ;
this . data = data ;
}
public Integer getId () {
return id ;
}
public void setId ( Integer id ) {
this . id = id ;
}
public String getNome () {
return nome ;
}
public void setNome ( String nome ) {
this . nome = nome ;
}
public double getPreco () {
return preco ;
}
public void setPreco ( double preco ) {
this . preco = preco ;
}
public Date getData () {
return data ;
}
public void setData ( Date data ) {
this . data = data ;
}
@Override
public int hashCode () {
int hash = 0 ;
hash += ( id != null ? id . hashCode () : 0 );
return hash ;
}
@Override
public boolean equals ( Object object ) {
// TODO: Warning - this method won't work in the case the id fields are not set
if ( ! ( object instanceof ProdutoX )) {
return false ;
}
ProdutoX other = ( ProdutoX ) object ;
if (( this . id == null && other . id != null ) || ( this . id != null && ! this . id . equals ( other . id ))) {
return false ;
}
return true ;
}
@Override
public String toString () {
return "com.joficina.ProdutoX[id=" + id + "]" ;
}
}
TheKill 16 de mar. de 2010
é ta complicado essa coisa… eu fiz as anotações da classe…
Mas continua nao funcionando, estava seguindo a apostila da Caelum…
Hebertbc 16 de mar. de 2010
Me explique passo a passo como vc está fazendo… vamos achar o erro.
TheKill 16 de mar. de 2010
certo, vamos lá
vou começar… cheguei agora beleza?? ta por ai?
TheKill 16 de mar. de 2010
Se você tiver Gtalk podemos conversar lá…
é o unico mensageiro que posso usar em serviço… [email removido]
TheKill 16 de mar. de 2010
começo pelo BuildPatch… Segue abaixo os Librarys
em anexo
TheKill 16 de mar. de 2010
E aqui abaixo em anexo, a classe Produto e GeraTabelas…
Tá foda, hibernate até pegar o jeito é abusadinho
TheKill 16 de mar. de 2010
Alguem se habilita a ajudar?
Porque tão complicado u.u
rogelgarcia 16 de mar. de 2010
Tenta colocar isso
hibernate.hbm2ddl.auto=update
Nas properties do hibernate…
O problema é só que nao tá criando a tabela né?! mas o mapeamento funcionou…
rogelgarcia 16 de mar. de 2010
(só um parânteses que eu faço em todo tópico onde é pertinente falar do next …
No next…
pra configurar o hibernate voce só precisa de um arquivo connection.properties com o seguinte
driver=org.postgresql.Driver
url=jdbc:postgresql://localhost/app
username=postgres
password=123456
E se quiser criar o banco automaticamente um hibernate.properties
hibernate.hbm2ddl.auto=update
Acabou a configuração do hibernate… já vai estar tudo funcionando… com dialeto e tudo mais… e as classes serao detectadas automaticamente… os sqls serao mostrados no console
fim dos parenteses)
TheKill 16 de mar. de 2010
uhm… já tentei com update, mas nada funciona…
ja estou meio perdido
rogelgarcia 16 de mar. de 2010
Talvez o hibernate nao esteja lendo sua classe…
Experimente fazer uma query…
from Produto e veja o erro que dá… e posta aqui
TheKill 16 de mar. de 2010
Tipo, aqui no topico tem todas classes utilizadas…
Eu só to querendo montar um projeto para ter como base de estudos…
Projeto simples de CRUD… Create, Read, Updade, Delete…
Só que não está saindo direito isso =/
Att. Jonas
rogelgarcia 16 de mar. de 2010
Ignora o fato de nao ter criado a tabela…
Cria uma session do hibernate…
e com essa session execute a seguinte query:
E poste aqui os resultados…
TheKill 16 de mar. de 2010
Exception in thread “main” org.hibernate.hql.ast.QuerySyntaxException: Produto is not mapped [from Produto]
rogelgarcia 16 de mar. de 2010
Haaaaaammmm
Então foi o que eu previ …
O hibernate nao tá mapeando suas classes…
Se nao tá mapeando… nao tem como criar as tabelas…
Agora vamos ver porque nao tá mapeando… apesar de já ter postado uma vez…
Posta o seu main aí… e os xmls e uma classe pra gente ver…
TheKill 16 de mar. de 2010
vou começar com a classe produto em questão:
package br.com.caelum.hibernate ;
import javax.persistence.Basic ;
import javax.persistence.Column ;
import javax.persistence.GeneratedValue ;
import javax.persistence.GenerationType ;
import javax.persistence.Id ;
import javax.persistence.Table ;
import org.hibernate.annotations.Entity ;
@Entity
@Table ( name = "produtos" )
public class Produto {
@Id
@GeneratedValue ( strategy = GenerationType . IDENTITY )
@Basic ( optional = false )
@Column ( name = "id" )
private Long id ;
@Basic ( optional = false )
@Column ( name = "nome" )
private String nome ;
@Basic ( optional = false )
@Column ( name = "preco" )
private double preco ;
@Basic ( optional = false )
@Column ( name = "quantidade" )
private int quantidade ;
public Long getId () {
return id ;
}
public void setId ( Long id ) {
this . id = id ;
}
public String getNome () {
return nome ;
}
public void setNome ( String nome ) {
this . nome = nome ;
}
public double getPreco () {
return preco ;
}
public void setPreco ( double preco ) {
this . preco = preco ;
}
public int getQuantidade () {
return quantidade ;
}
public void setQuantidade ( int quantidade ) {
this . quantidade = quantidade ;
}
}
TheKill 16 de mar. de 2010
agora o main e properties
package br.com.caelum.hibernate ;
import org.hibernate.Session ;
import org.hibernate.cfg.AnnotationConfiguration ;
import org.hibernate.tool.hbm2ddl.SchemaExport ;
public class GeraTabelas {
public static void main ( String [] args ) {
// Cria uma configuração para a classe Produto
AnnotationConfiguration cfg = new AnnotationConfiguration ();
cfg . addAnnotatedClass ( Produto . class );
SchemaExport se = new SchemaExport ( cfg );
se . create ( true , true );
Session session = new HibernateUtil (). getSession ();
session . createQuery ( "from Produto" );
/*Produto p = new Produto();
p.setNome("Nome aqui");
p.setPreco(100.50);
p.setQuantidade(3);
Session session = new HibernateUtil().getSession();
session.save(p);
System.out.println("ID do produto: " + p.getId());
session.close();*/
}
}
& lt ;? xml version = "1.0" encoding = "UTF-8" ?& gt ;
& lt ;! DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd" & gt ;
& lt ; hibernate-configuration & gt ;
& lt ; session-factory & gt ;
& lt ; property name = "hibernate.dialect" & gt ; org . hibernate . dialect . MySQLDialect & lt ;/ property & 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 / caelum & lt ;/ property & gt ;
& lt ; property name = "hibernate.connection.username" & gt ; root & lt ;/ property & gt ;
& lt ; property name = "hibernate.connection.password" & gt ; root & lt ;/ property & gt ;
& lt ; property name = "hibernate.use_identifier_rollback" & gt ; true & lt ;/ property & gt ;
& lt ; property name = "hibernate.transaction.auto_close_session" & gt ; true & lt ;/ property & gt ;
& lt ; property name = "hibernate.transaction.flush_before_completion" & gt ; true & lt ;/ property & gt ;
& lt ; property name = "hibernate.bytecode.use_reflection_optimizer" & gt ; true & lt ;/ property & gt ;
& lt ; mapping class = "br.com.caelum.hibernate.Produto" /& gt ;
& lt ;/ session-factory & gt ;
& lt ;/ hibernate-configuration & gt ;
hibernate.dialect org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc:mysql://localhost:3306/caelum
hibernate.connection.username root
hibernate.connection.password root
hibernate.show_sql true
hibernate.format_sql true
hibernate.hbm2dll.auto update
TheKill 16 de mar. de 2010
e o HibernateUtil
package br.com.caelum.hibernate ;
import org.hibernate.Session ;
import org.hibernate.SessionFactory ;
import org.hibernate.cfg.AnnotationConfiguration ;
public class HibernateUtil {
private static SessionFactory factory ;
static {
AnnotationConfiguration cfg = new AnnotationConfiguration ();
cfg . addAnnotatedClass ( Produto . class );
factory = cfg . buildSessionFactory ();
}
public Session getSession () {
return factory . openSession ();
}
}
rogelgarcia 16 de mar. de 2010
Esse cfg.addAnnotatedClass(Produto.class); voce colocou agora, ou já tinha??
Se colocou agora… experimenta rodar denovo e poste os resultados
outra coisa… no seu hibernate.properties cade o sinal de igual ???
hibernate.dialect[b]=[/b]org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class[b]=[/b]com.mysql.jdbc.Driver
hibernate.connection.url[b]=[/b]jdbc:mysql://localhost:3306/caelum
hibernate.connection.username=root
hibernate.connection.password=root
hibernate.show_sql=true
hibernate.format_sql=true
hibernate.hbm2dll.auto=update No seu arquivo tem o igual?
TheKill 16 de mar. de 2010
Sim… já tinha vou postar os resultados
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . annotations . Version & lt ; clinit & gt ;
INFO : Hibernate Annotations 3.5.0 - CR -2
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : Hibernate 3.5.0 - CR -2
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : loaded properties from resource hibernate . properties : { hibernate . connection . password =**** , hibernate . jdbc . batch_versioned_data = true , hibernate . query . substitutions = yes 'Y' , no 'N' , hibernate . cache . region_prefix = hibernate . test , hibernate . show_sql = true , hibernate . proxool . pool_alias = pool1 , hibernate . bytecode . use_reflection_optimizer = true , hibernate . hbm2ddl . auto = validate , hibernate . hbm2dll . auto = update , hibernate . jdbc . use_streams_for_binary = true , hibernate . max_fetch_depth = 1 , hibernate . format_sql = true , hibernate . connection . pool_size = 1 , hibernate . connection . username = root , hibernate . connection . driver_class = com . mysql . jdbc . Driver , hibernate . cache . provider_class = org . hibernate . cache . HashtableCacheProvider , hibernate . dialect = org . hibernate . dialect . MySQLDialect , hibernate . connection . url = jdbc : mysql : //localhost:3306/caelum}
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : using java . io streams to persist binary types
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : using bytecode reflection optimizer
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . Environment buildBytecodeProvider
INFO : Bytecode provider name : javassist
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : using JDK 1.4 java . sql . Timestamp handling
16 / 03 / 2010 17 : 13 : 27 org . hibernate . annotations . common . Version & lt ; clinit & gt ;
INFO : Hibernate Commons Annotations 3.2.0 - SNAPSHOT
16 / 03 / 2010 17 : 13 : 27 org . hibernate . dialect . Dialect & lt ; init & gt ;
INFO : Using dialect : org . hibernate . dialect . MySQLDialect
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . AnnotationConfiguration applyHibernateValidatorLegacyConstraintsOnDDL
INFO : Hibernate Validator not found : ignoring
16 / 03 / 2010 17 : 13 : 27 org . hibernate . tool . hbm2ddl . SchemaExport execute
INFO : Running hbm2ddl schema export
16 / 03 / 2010 17 : 13 : 27 org . hibernate . tool . hbm2ddl . SchemaExport execute
INFO : exporting generated schema to database
16 / 03 / 2010 17 : 13 : 27 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : Using Hibernate built - in connection pool ( not for production use ! )
16 / 03 / 2010 17 : 13 : 27 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : Hibernate connection pool size : 1
16 / 03 / 2010 17 : 13 : 27 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : autocommit mode : false
16 / 03 / 2010 17 : 13 : 27 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : using driver : com . mysql . jdbc . Driver at URL : jdbc : mysql : //localhost:3306/caelum
16 / 03 / 2010 17 : 13 : 27 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : connection properties : { user = root , password =**** }
16 / 03 / 2010 17 : 13 : 27 org . hibernate . tool . hbm2ddl . SchemaExport execute
INFO : schema export complete
16 / 03 / 2010 17 : 13 : 27 org . hibernate . connection . DriverManagerConnectionProvider close
INFO : cleaning up connection pool : jdbc : mysql : //localhost:3306/caelum
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . search . HibernateSearchEventListenerRegister enableHibernateSearch
INFO : Unable to find org . hibernate . search . event . FullTextIndexEventListener on the classpath . Hibernate Search is not enabled .
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . AnnotationConfiguration applyHibernateValidatorLegacyConstraintsOnDDL
INFO : Hibernate Validator not found : ignoring
16 / 03 / 2010 17 : 13 : 27 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : Using Hibernate built - in connection pool ( not for production use ! )
16 / 03 / 2010 17 : 13 : 27 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : Hibernate connection pool size : 1
16 / 03 / 2010 17 : 13 : 27 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : autocommit mode : false
16 / 03 / 2010 17 : 13 : 27 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : using driver : com . mysql . jdbc . Driver at URL : jdbc : mysql : //localhost:3306/caelum
16 / 03 / 2010 17 : 13 : 27 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : connection properties : { user = root , password =**** }
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : RDBMS : MySQL , version : 5.1.33 - community
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC driver : MySQL - AB JDBC Driver , version : mysql - connector - java -5.1.12 ( Revision : $ { bzr . revision - id } )
16 / 03 / 2010 17 : 13 : 27 org . hibernate . dialect . Dialect & lt ; init & gt ;
INFO : Using dialect : org . hibernate . dialect . MySQLDialect
16 / 03 / 2010 17 : 13 : 27 org . hibernate . engine . jdbc . JdbcSupportLoader useContextualLobCreation
INFO : Disabling contextual LOB creation as JDBC driver reported JDBC version [ 3 ] less than 4
16 / 03 / 2010 17 : 13 : 27 org . hibernate . transaction . TransactionFactoryFactory buildTransactionFactory
INFO : Using default transaction strategy ( direct JDBC transactions )
16 / 03 / 2010 17 : 13 : 27 org . hibernate . transaction . TransactionManagerLookupFactory getTransactionManagerLookup
INFO : No TransactionManagerLookup configured ( in JTA environment , use of read - write or transactional second - level cache is not recommended )
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Automatic flush during beforeCompletion () : disabled
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Automatic session close at end of transaction : disabled
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC batch size : 15
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC batch updates for versioned data : enabled
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Scrollable result sets : enabled
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC3 getGeneratedKeys () : enabled
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Connection release mode : auto
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Maximum outer join fetch depth : 1
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Default batch fetch size : 1
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Generate SQL with comments : disabled
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Order SQL updates by primary key : disabled
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Order SQL inserts for batching : disabled
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory createQueryTranslatorFactory
INFO : Query translator : org . hibernate . hql . ast . ASTQueryTranslatorFactory
16 / 03 / 2010 17 : 13 : 27 org . hibernate . hql . ast . ASTQueryTranslatorFactory & lt ; init & gt ;
INFO : Using ASTQueryTranslatorFactory
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Query language substitutions : { yes = 'Y' , no = 'N' }
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JPA - QL strict compliance : disabled
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Second - level cache : enabled
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Query cache : disabled
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory createRegionFactory
INFO : Cache region factory : org . hibernate . cache . impl . bridge . RegionFactoryCacheProviderBridge
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cache . impl . bridge . RegionFactoryCacheProviderBridge & lt ; init & gt ;
INFO : Cache provider : org . hibernate . cache . HashtableCacheProvider
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Optimize cache for minimal puts : disabled
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Cache region prefix : hibernate . test
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Structured second - level cache entries : disabled
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Echoing all SQL to stdout
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Statistics : disabled
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Deleted entity synthetic identifier rollback : disabled
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Default entity - mode : pojo
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Named query checking : enabled
16 / 03 / 2010 17 : 13 : 27 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Check Nullability in Core ( should be disabled when Bean Validation is on ) : enabled
16 / 03 / 2010 17 : 13 : 27 org . hibernate . impl . SessionFactoryImpl & lt ; init & gt ;
INFO : building session factory
16 / 03 / 2010 17 : 13 : 27 org . hibernate . impl . SessionFactoryObjectFactory addInstance
INFO : Not binding factory to JNDI , no JNDI name configured
16 / 03 / 2010 17 : 13 : 27 org . hibernate . tool . hbm2ddl . SchemaValidator validate
INFO : Running schema validator
16 / 03 / 2010 17 : 13 : 27 org . hibernate . tool . hbm2ddl . SchemaValidator validate
INFO : fetching database metadata
Exception in thread "main" org . hibernate . hql . ast . QuerySyntaxException : Produto is not mapped [ from Produto ]
at org . hibernate . hql . ast . util . SessionFactoryHelper . requireClassPersister ( SessionFactoryHelper . java : 181 )
at org . hibernate . hql . ast . tree . FromElementFactory . addFromElement ( FromElementFactory . java : 111 )
at org . hibernate . hql . ast . tree . FromClause . addFromElement ( FromClause . java : 93 )
at org . hibernate . hql . ast . HqlSqlWalker . createFromElement ( HqlSqlWalker . java : 313 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . fromElement ( HqlSqlBaseWalker . java : 3353 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . fromElementList ( HqlSqlBaseWalker . java : 3237 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . fromClause ( HqlSqlBaseWalker . java : 724 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . query ( HqlSqlBaseWalker . java : 575 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . selectStatement ( HqlSqlBaseWalker . java : 292 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . statement ( HqlSqlBaseWalker . java : 235 )
at org . hibernate . hql . ast . QueryTranslatorImpl . analyze ( QueryTranslatorImpl . java : 254 )
at org . hibernate . hql . ast . QueryTranslatorImpl . doCompile ( QueryTranslatorImpl . java : 185 )
at org . hibernate . hql . ast . QueryTranslatorImpl . compile ( QueryTranslatorImpl . java : 136 )
at org . hibernate . engine . query . HQLQueryPlan . & lt ; init & gt ;( HQLQueryPlan . java : 101 )
at org . hibernate . engine . query . HQLQueryPlan . & lt ; init & gt ;( HQLQueryPlan . java : 80 )
at org . hibernate . engine . query . QueryPlanCache . getHQLQueryPlan ( QueryPlanCache . java : 98 )
at org . hibernate . impl . AbstractSessionImpl . getHQLQueryPlan ( AbstractSessionImpl . java : 156 )
at org . hibernate . impl . AbstractSessionImpl . createQuery ( AbstractSessionImpl . java : 135 )
at org . hibernate . impl . SessionImpl . createQuery ( SessionImpl . java : 1760 )
at br . com . caelum . hibernate . GeraTabelas . main ( GeraTabelas . java : 18 )
rogelgarcia 16 de mar. de 2010
Altera o seu main pra ficar assim:
package br.com.caelum.hibernate ;
import org.hibernate.Session ;
import org.hibernate.cfg.AnnotationConfiguration ;
import org.hibernate.tool.hbm2ddl.SchemaExport ;
public class GeraTabelas {
public static void main ( String [] args ) {
// Cria uma configuração para a classe Produto
//AnnotationConfiguration cfg = new AnnotationConfiguration();
//cfg.addAnnotatedClass(Produto.class);
//SchemaExport se = new SchemaExport(cfg);
// se.create(true, true);
Session session = new HibernateUtil (). getSession ();
session . createQuery ( "from Produto" );
/*Produto p = new Produto();
p.setNome("Nome aqui");
p.setPreco(100.50);
p.setQuantidade(3);
Session session = new HibernateUtil().getSession();
session.save(p);
System.out.println("ID do produto: " + p.getId());
session.close();*/
}
}
TheKill 16 de mar. de 2010
Resultado com Main alterado:
16 / 03 / 2010 17 : 18 : 16 org . hibernate . cfg . annotations . Version & lt ; clinit & gt ;
INFO : Hibernate Annotations 3.5.0 - CR -2
16 / 03 / 2010 17 : 18 : 16 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : Hibernate 3.5.0 - CR -2
16 / 03 / 2010 17 : 18 : 16 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : loaded properties from resource hibernate . properties : { hibernate . connection . password =**** , hibernate . jdbc . batch_versioned_data = true , hibernate . query . substitutions = yes 'Y' , no 'N' , hibernate . cache . region_prefix = hibernate . test , hibernate . show_sql = true , hibernate . proxool . pool_alias = pool1 , hibernate . bytecode . use_reflection_optimizer = true , hibernate . hbm2ddl . auto = validate , hibernate . hbm2dll . auto = update , hibernate . jdbc . use_streams_for_binary = true , hibernate . max_fetch_depth = 1 , hibernate . format_sql = true , hibernate . connection . pool_size = 1 , hibernate . connection . username = root , hibernate . connection . driver_class = com . mysql . jdbc . Driver , hibernate . cache . provider_class = org . hibernate . cache . HashtableCacheProvider , hibernate . dialect = org . hibernate . dialect . MySQLDialect , hibernate . connection . url = jdbc : mysql : //localhost:3306/caelum}
16 / 03 / 2010 17 : 18 : 16 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : using java . io streams to persist binary types
16 / 03 / 2010 17 : 18 : 16 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : using bytecode reflection optimizer
16 / 03 / 2010 17 : 18 : 16 org . hibernate . cfg . Environment buildBytecodeProvider
INFO : Bytecode provider name : javassist
16 / 03 / 2010 17 : 18 : 16 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : using JDK 1.4 java . sql . Timestamp handling
16 / 03 / 2010 17 : 18 : 16 org . hibernate . annotations . common . Version & lt ; clinit & gt ;
INFO : Hibernate Commons Annotations 3.2.0 - SNAPSHOT
16 / 03 / 2010 17 : 18 : 16 org . hibernate . cfg . search . HibernateSearchEventListenerRegister enableHibernateSearch
INFO : Unable to find org . hibernate . search . event . FullTextIndexEventListener on the classpath . Hibernate Search is not enabled .
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . AnnotationConfiguration applyHibernateValidatorLegacyConstraintsOnDDL
INFO : Hibernate Validator not found : ignoring
16 / 03 / 2010 17 : 18 : 17 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : Using Hibernate built - in connection pool ( not for production use ! )
16 / 03 / 2010 17 : 18 : 17 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : Hibernate connection pool size : 1
16 / 03 / 2010 17 : 18 : 17 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : autocommit mode : false
16 / 03 / 2010 17 : 18 : 17 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : using driver : com . mysql . jdbc . Driver at URL : jdbc : mysql : //localhost:3306/caelum
16 / 03 / 2010 17 : 18 : 17 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : connection properties : { user = root , password =**** }
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : RDBMS : MySQL , version : 5.1.33 - community
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC driver : MySQL - AB JDBC Driver , version : mysql - connector - java -5.1.12 ( Revision : $ { bzr . revision - id } )
16 / 03 / 2010 17 : 18 : 17 org . hibernate . dialect . Dialect & lt ; init & gt ;
INFO : Using dialect : org . hibernate . dialect . MySQLDialect
16 / 03 / 2010 17 : 18 : 17 org . hibernate . engine . jdbc . JdbcSupportLoader useContextualLobCreation
INFO : Disabling contextual LOB creation as JDBC driver reported JDBC version [ 3 ] less than 4
16 / 03 / 2010 17 : 18 : 17 org . hibernate . transaction . TransactionFactoryFactory buildTransactionFactory
INFO : Using default transaction strategy ( direct JDBC transactions )
16 / 03 / 2010 17 : 18 : 17 org . hibernate . transaction . TransactionManagerLookupFactory getTransactionManagerLookup
INFO : No TransactionManagerLookup configured ( in JTA environment , use of read - write or transactional second - level cache is not recommended )
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Automatic flush during beforeCompletion () : disabled
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Automatic session close at end of transaction : disabled
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC batch size : 15
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC batch updates for versioned data : enabled
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Scrollable result sets : enabled
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC3 getGeneratedKeys () : enabled
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Connection release mode : auto
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Maximum outer join fetch depth : 1
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Default batch fetch size : 1
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Generate SQL with comments : disabled
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Order SQL updates by primary key : disabled
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Order SQL inserts for batching : disabled
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory createQueryTranslatorFactory
INFO : Query translator : org . hibernate . hql . ast . ASTQueryTranslatorFactory
16 / 03 / 2010 17 : 18 : 17 org . hibernate . hql . ast . ASTQueryTranslatorFactory & lt ; init & gt ;
INFO : Using ASTQueryTranslatorFactory
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Query language substitutions : { yes = 'Y' , no = 'N' }
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JPA - QL strict compliance : disabled
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Second - level cache : enabled
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Query cache : disabled
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory createRegionFactory
INFO : Cache region factory : org . hibernate . cache . impl . bridge . RegionFactoryCacheProviderBridge
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cache . impl . bridge . RegionFactoryCacheProviderBridge & lt ; init & gt ;
INFO : Cache provider : org . hibernate . cache . HashtableCacheProvider
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Optimize cache for minimal puts : disabled
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Cache region prefix : hibernate . test
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Structured second - level cache entries : disabled
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Echoing all SQL to stdout
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Statistics : disabled
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Deleted entity synthetic identifier rollback : disabled
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Default entity - mode : pojo
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Named query checking : enabled
16 / 03 / 2010 17 : 18 : 17 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Check Nullability in Core ( should be disabled when Bean Validation is on ) : enabled
16 / 03 / 2010 17 : 18 : 17 org . hibernate . impl . SessionFactoryImpl & lt ; init & gt ;
INFO : building session factory
16 / 03 / 2010 17 : 18 : 17 org . hibernate . impl . SessionFactoryObjectFactory addInstance
INFO : Not binding factory to JNDI , no JNDI name configured
16 / 03 / 2010 17 : 18 : 17 org . hibernate . tool . hbm2ddl . SchemaValidator validate
INFO : Running schema validator
16 / 03 / 2010 17 : 18 : 17 org . hibernate . tool . hbm2ddl . SchemaValidator validate
INFO : fetching database metadata
Exception in thread "main" org . hibernate . hql . ast . QuerySyntaxException : Produto is not mapped [ from Produto ]
at org . hibernate . hql . ast . util . SessionFactoryHelper . requireClassPersister ( SessionFactoryHelper . java : 181 )
at org . hibernate . hql . ast . tree . FromElementFactory . addFromElement ( FromElementFactory . java : 111 )
at org . hibernate . hql . ast . tree . FromClause . addFromElement ( FromClause . java : 93 )
at org . hibernate . hql . ast . HqlSqlWalker . createFromElement ( HqlSqlWalker . java : 313 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . fromElement ( HqlSqlBaseWalker . java : 3353 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . fromElementList ( HqlSqlBaseWalker . java : 3237 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . fromClause ( HqlSqlBaseWalker . java : 724 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . query ( HqlSqlBaseWalker . java : 575 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . selectStatement ( HqlSqlBaseWalker . java : 292 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . statement ( HqlSqlBaseWalker . java : 235 )
at org . hibernate . hql . ast . QueryTranslatorImpl . analyze ( QueryTranslatorImpl . java : 254 )
at org . hibernate . hql . ast . QueryTranslatorImpl . doCompile ( QueryTranslatorImpl . java : 185 )
at org . hibernate . hql . ast . QueryTranslatorImpl . compile ( QueryTranslatorImpl . java : 136 )
at org . hibernate . engine . query . HQLQueryPlan . & lt ; init & gt ;( HQLQueryPlan . java : 101 )
at org . hibernate . engine . query . HQLQueryPlan . & lt ; init & gt ;( HQLQueryPlan . java : 80 )
at org . hibernate . engine . query . QueryPlanCache . getHQLQueryPlan ( QueryPlanCache . java : 98 )
at org . hibernate . impl . AbstractSessionImpl . getHQLQueryPlan ( AbstractSessionImpl . java : 156 )
at org . hibernate . impl . AbstractSessionImpl . createQuery ( AbstractSessionImpl . java : 135 )
at org . hibernate . impl . SessionImpl . createQuery ( SessionImpl . java : 1760 )
at br . com . caelum . hibernate . GeraTabelas . main ( GeraTabelas . java : 48 )
rogelgarcia 16 de mar. de 2010
Muito estranho esse erro… tinha que funcionar… (anterioemente já tinha que funcionar… a alteracao do main é só pra eliminar código duplicado )
rogelgarcia 16 de mar. de 2010
Há… experimenta o seguinte
na classe produto onde tem
troca por
TheKill 16 de mar. de 2010
vixi, to ferrado ehehe…
tem como vc testar o codigo ai na sua estação?
rogelgarcia 16 de mar. de 2010
Ultimo teste… vai lá…
troca o import
TheKill 16 de mar. de 2010
certo, troquei, o erro mudou…
vou postar
16 / 03 / 2010 17 : 25 : 41 org . hibernate . cfg . annotations . Version & lt ; clinit & gt ;
INFO : Hibernate Annotations 3.5 . 0 - CR - 2
16 / 03 / 2010 17 : 25 : 41 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : Hibernate 3.5 . 0 - CR - 2
16 / 03 / 2010 17 : 25 : 41 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : loaded properties from resource hibernate . properties : { hibernate . connection . password =**** , hibernate . jdbc . batch_versioned_data = true , hibernate . query . substitutions = yes 'Y' , no 'N' , hibernate . cache . region_prefix = hibernate . test , hibernate . show_sql = true , hibernate . proxool . pool_alias = pool1 , hibernate . bytecode . use_reflection_optimizer = true , hibernate . hbm2ddl . auto = validate , hibernate . hbm2dll . auto = update , hibernate . jdbc . use_streams_for_binary = true , hibernate . max_fetch_depth = 1 , hibernate . format_sql = true , hibernate . connection . pool_size = 1 , hibernate . connection . username = root , hibernate . connection . driver_class = com . mysql . jdbc . Driver , hibernate . cache . provider_class = org . hibernate . cache . HashtableCacheProvider , hibernate . dialect = org . hibernate . dialect . MySQLDialect , hibernate . connection . url = jdbc : mysql : // localhost : 3306 / caelum }
16 / 03 / 2010 17 : 25 : 41 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : using java . io streams to persist binary types
16 / 03 / 2010 17 : 25 : 41 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : using bytecode reflection optimizer
16 / 03 / 2010 17 : 25 : 41 org . hibernate . cfg . Environment buildBytecodeProvider
INFO : Bytecode provider name : javassist
16 / 03 / 2010 17 : 25 : 41 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : using JDK 1.4 java . sql . Timestamp handling
16 / 03 / 2010 17 : 25 : 41 org . hibernate . annotations . common . Version & lt ; clinit & gt ;
INFO : Hibernate Commons Annotations 3.2 . 0 - SNAPSHOT
16 / 03 / 2010 17 : 25 : 41 org . hibernate . cfg . search . HibernateSearchEventListenerRegister enableHibernateSearch
INFO : Unable to find org . hibernate . search . event . FullTextIndexEventListener on the classpath . Hibernate Search is not enabled .
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . AnnotationBinder bindClass
INFO : Binding entity from annotated class : br . com . caelum . hibernate . Produto
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . annotations . EntityBinder bindTable
INFO : Bind entity br . com . caelum . hibernate . Produto on table produtos
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . AnnotationConfiguration applyHibernateValidatorLegacyConstraintsOnDDL
INFO : Hibernate Validator not found : ignoring
16 / 03 / 2010 17 : 25 : 42 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : Using Hibernate built - in connection pool ( not for production use ! )
16 / 03 / 2010 17 : 25 : 42 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : Hibernate connection pool size : 1
16 / 03 / 2010 17 : 25 : 42 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : autocommit mode : false
16 / 03 / 2010 17 : 25 : 42 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : using driver : com . mysql . jdbc . Driver at URL : jdbc : mysql : // localhost : 3306 / caelum
16 / 03 / 2010 17 : 25 : 42 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : connection properties : { user = root , password =**** }
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : RDBMS : MySQL , version : 5.1 . 33 - community
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC driver : MySQL - AB JDBC Driver , version : mysql - connector - java - 5.1 . 12 ( Revision : $ { bzr . revision - id } )
16 / 03 / 2010 17 : 25 : 42 org . hibernate . dialect . Dialect & lt ; init & gt ;
INFO : Using dialect : org . hibernate . dialect . MySQLDialect
16 / 03 / 2010 17 : 25 : 42 org . hibernate . engine . jdbc . JdbcSupportLoader useContextualLobCreation
INFO : Disabling contextual LOB creation as JDBC driver reported JDBC version [ 3 ] less than 4
16 / 03 / 2010 17 : 25 : 42 org . hibernate . transaction . TransactionFactoryFactory buildTransactionFactory
INFO : Using default transaction strategy ( direct JDBC transactions )
16 / 03 / 2010 17 : 25 : 42 org . hibernate . transaction . TransactionManagerLookupFactory getTransactionManagerLookup
INFO : No TransactionManagerLookup configured ( in JTA environment , use of read - write or transactional second - level cache is not recommended )
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Automatic flush during beforeCompletion (): disabled
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Automatic session close at end of transaction : disabled
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC batch size : 15
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC batch updates for versioned data : enabled
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Scrollable result sets : enabled
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC3 getGeneratedKeys (): enabled
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Connection release mode : auto
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Maximum outer join fetch depth : 1
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Default batch fetch size : 1
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Generate SQL with comments : disabled
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Order SQL updates by primary key : disabled
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Order SQL inserts for batching : disabled
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory createQueryTranslatorFactory
INFO : Query translator : org . hibernate . hql . ast . ASTQueryTranslatorFactory
16 / 03 / 2010 17 : 25 : 42 org . hibernate . hql . ast . ASTQueryTranslatorFactory & lt ; init & gt ;
INFO : Using ASTQueryTranslatorFactory
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Query language substitutions : { yes = 'Y' , no = 'N' }
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JPA - QL strict compliance : disabled
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Second - level cache : enabled
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Query cache : disabled
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory createRegionFactory
INFO : Cache region factory : org . hibernate . cache . impl . bridge . RegionFactoryCacheProviderBridge
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cache . impl . bridge . RegionFactoryCacheProviderBridge & lt ; init & gt ;
INFO : Cache provider : org . hibernate . cache . HashtableCacheProvider
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Optimize cache for minimal puts : disabled
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Cache region prefix : hibernate . test
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Structured second - level cache entries : disabled
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Echoing all SQL to stdout
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Statistics : disabled
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Deleted entity synthetic identifier rollback : disabled
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Default entity - mode : pojo
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Named query checking : enabled
16 / 03 / 2010 17 : 25 : 42 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Check Nullability in Core ( should be disabled when Bean Validation is on ): enabled
Exception in thread "main" java . lang . NoClassDefFoundError : org / apache / commons / logging / LogFactory
at org . hibernate . validator . ClassValidator .& lt ; clinit & gt ;( ClassValidator . java : 52 )
at org . hibernate . validator . event . ValidateEventListener . initialize ( ValidateEventListener . java : 49 )
at org . hibernate . event . EventListeners $ 1. processListener ( EventListeners . java : 198 )
at org . hibernate . event . EventListeners . processListeners ( EventListeners . java : 181 )
at org . hibernate . event . EventListeners . initializeListeners ( EventListeners . java : 194 )
at org . hibernate . cfg . Configuration . getInitializedEventListeners ( Configuration . java : 1396 )
at org . hibernate . cfg . Configuration . buildSessionFactory ( Configuration . java : 1385 )
at org . hibernate . cfg . AnnotationConfiguration . buildSessionFactory ( AnnotationConfiguration . java : 975 )
at br . com . caelum . hibernate . HibernateUtil .& lt ; clinit & gt ;( HibernateUtil . java : 13 )
at br . com . caelum . hibernate . GeraTabelas . main ( GeraTabelas . java : 17 )
Caused by : java . lang . ClassNotFoundException : org . apache . commons . logging . LogFactory
at java . net . URLClassLoader $ 1. run ( Unknown Source )
at java . security . AccessController . doPrivileged ( Native Method )
at java . net . URLClassLoader . findClass ( Unknown Source )
at java . lang . ClassLoader . loadClass ( Unknown Source )
at sun . misc . Launcher $ AppClassLoader . loadClass ( Unknown Source )
at java . lang . ClassLoader . loadClass ( Unknown Source )
... 10 more
rogelgarcia 16 de mar. de 2010
Haaaaaaaaaammmmm denovo…
Agora tá faltando o commons-logging.jar
Deve vim na distribuiçao do hibernate… procura lá… e coloca no build path da sua aplicacao
TheKill 16 de mar. de 2010
omg, nao para os erro nunca…
ASHdiuAHDiuhAUDiSAHDsIAUSd
novo erro:
INFO : Named query checking : enabled
16 / 03 / 2010 17 : 35 : 11 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Check Nullability in Core ( should be disabled when Bean Validation is on ): enabled
17 : 35 : 11 , 500 DEBUG ClassValidator : 138 - ResourceBundle ValidatorMessages not found in Validator classloader . Delegate to org . hibernate . validator . resources . DefaultValidatorMessages
16 / 03 / 2010 17 : 35 : 11 org . hibernate . impl . SessionFactoryImpl & lt ; init & gt ;
INFO : building session factory
16 / 03 / 2010 17 : 35 : 11 org . hibernate . impl . SessionFactoryObjectFactory addInstance
INFO : Not binding factory to JNDI , no JNDI name configured
16 / 03 / 2010 17 : 35 : 11 org . hibernate . tool . hbm2ddl . SchemaValidator validate
INFO : Running schema validator
16 / 03 / 2010 17 : 35 : 11 org . hibernate . tool . hbm2ddl . SchemaValidator validate
INFO : fetching database metadata
16 / 03 / 2010 17 : 35 : 11 org . hibernate . tool . hbm2ddl . DatabaseMetadata getTableMetadata
INFO : table not found : produtos
Exception in thread "main" java . lang . ExceptionInInitializerError
at br . com . caelum . hibernate . GeraTabelas . main ( GeraTabelas . java : 15 )
Caused by : org . hibernate . HibernateException : Missing table : produtos
at org . hibernate . cfg . Configuration . validateSchema ( Configuration . java : 1171 )
at org . hibernate . tool . hbm2ddl . SchemaValidator . validate ( SchemaValidator . java : 139 )
at org . hibernate . impl . SessionFactoryImpl .& lt ; init & gt ;( SessionFactoryImpl . java : 364 )
at org . hibernate . cfg . Configuration . buildSessionFactory ( Configuration . java : 1385 )
at org . hibernate . cfg . AnnotationConfiguration . buildSessionFactory ( AnnotationConfiguration . java : 975 )
at br . com . caelum . hibernate . HibernateUtil .& lt ; clinit & gt ;( HibernateUtil . java : 13 )
... 1 more
Ps.: To resumindo o erro, aquela parte de sempre eu nao vou colar
TheKill 16 de mar. de 2010
Ps.: Eu descomentei aqueles primeiros codigos do GeraTabela, para ele tentar criar a tabela…
E conseguiu criar as tabelas, com as mudanças que agente fez…
Porem… ainda continua com o problema de Mapping, ele nao consegue mapear as classes se quise rposso postar o novo erro
rogelgarcia 16 de mar. de 2010
Fino… agora tá mapeado… antes nao tava…
Vamos então fazer o hibernate criar a tabela…
no seu hibernate.properties tem isso:
[size=18]hibernate.hbm2ddl.auto= update[/size]??
E deleta esse seu XML (move ele de lugar… pra ele nao existir mais no seu projeto)
rogelgarcia 16 de mar. de 2010
A classe produto tá mapeada… as outras eu creio que nao mesmo… acho que ele nao tá lendo esse seu XML
TheKill 16 de mar. de 2010
certo, vou tenta excluir o XML, deixo apenas o Hibernate.properties …
Certo??
TheKill 16 de mar. de 2010
Eu tirei o XML do meu projeto, vou postar o resultado
16 / 03 / 2010 17 : 43 : 53 org . hibernate . cfg . annotations . Version & lt ; clinit & gt ;
INFO : Hibernate Annotations 3.5.0 - CR -2
16 / 03 / 2010 17 : 43 : 53 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : Hibernate 3.5.0 - CR -2
16 / 03 / 2010 17 : 43 : 53 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : loaded properties from resource hibernate . properties : { hibernate . connection . password =**** , hibernate . jdbc . batch_versioned_data = true , hibernate . query . substitutions = yes 'Y' , no 'N' , hibernate . cache . region_prefix = hibernate . test , hibernate . show_sql = true , hibernate . proxool . pool_alias = pool1 , hibernate . bytecode . use_reflection_optimizer = true , hibernate . hbm2ddl . auto = validate , hibernate . hbm2dll . auto = update , hibernate . jdbc . use_streams_for_binary = true , hibernate . max_fetch_depth = 1 , hibernate . format_sql = true , hibernate . connection . pool_size = 1 , hibernate . connection . username = root , hibernate . connection . driver_class = com . mysql . jdbc . Driver , hibernate . cache . provider_class = org . hibernate . cache . HashtableCacheProvider , hibernate . dialect = org . hibernate . dialect . MySQLDialect , hibernate . connection . url = jdbc : mysql : //localhost:3306/caelum}
16 / 03 / 2010 17 : 43 : 53 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : using java . io streams to persist binary types
16 / 03 / 2010 17 : 43 : 53 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : using bytecode reflection optimizer
16 / 03 / 2010 17 : 43 : 53 org . hibernate . cfg . Environment buildBytecodeProvider
INFO : Bytecode provider name : javassist
16 / 03 / 2010 17 : 43 : 53 org . hibernate . cfg . Environment & lt ; clinit & gt ;
INFO : using JDK 1.4 java . sql . Timestamp handling
16 / 03 / 2010 17 : 43 : 53 org . hibernate . annotations . common . Version & lt ; clinit & gt ;
INFO : Hibernate Commons Annotations 3.2.0 - SNAPSHOT
16 / 03 / 2010 17 : 43 : 53 org . hibernate . dialect . Dialect & lt ; init & gt ;
INFO : Using dialect : org . hibernate . dialect . MySQLDialect
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . AnnotationBinder bindClass
INFO : Binding entity from annotated class : br . com . caelum . hibernate . Produto
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . annotations . EntityBinder bindTable
INFO : Bind entity br . com . caelum . hibernate . Produto on table produtos
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . AnnotationConfiguration applyHibernateValidatorLegacyConstraintsOnDDL
INFO : Hibernate Validator not found : ignoring
16 / 03 / 2010 17 : 43 : 54 org . hibernate . tool . hbm2ddl . SchemaExport execute
INFO : Running hbm2ddl schema export
16 / 03 / 2010 17 : 43 : 54 org . hibernate . tool . hbm2ddl . SchemaExport execute
INFO : exporting generated schema to database
16 / 03 / 2010 17 : 43 : 54 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : Using Hibernate built - in connection pool ( not for production use ! )
16 / 03 / 2010 17 : 43 : 54 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : Hibernate connection pool size : 1
16 / 03 / 2010 17 : 43 : 54 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : autocommit mode : false
16 / 03 / 2010 17 : 43 : 54 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : using driver : com . mysql . jdbc . Driver at URL : jdbc : mysql : //localhost:3306/caelum
16 / 03 / 2010 17 : 43 : 54 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : connection properties : { user = root , password =**** }
drop table if exists produtos
create table produtos (
id bigint not null auto_increment ,
nome varchar ( 255 ) not null ,
preco double precision not null ,
quantidade integer not null ,
primary key ( id )
)
16 / 03 / 2010 17 : 43 : 54 org . hibernate . tool . hbm2ddl . SchemaExport execute
INFO : schema export complete
16 / 03 / 2010 17 : 43 : 54 org . hibernate . connection . DriverManagerConnectionProvider close
INFO : cleaning up connection pool : jdbc : mysql : //localhost:3306/caelum
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . search . HibernateSearchEventListenerRegister enableHibernateSearch
INFO : Unable to find org . hibernate . search . event . FullTextIndexEventListener on the classpath . Hibernate Search is not enabled .
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . AnnotationBinder bindClass
INFO : Binding entity from annotated class : br . com . caelum . hibernate . Produto
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . annotations . EntityBinder bindTable
INFO : Bind entity br . com . caelum . hibernate . Produto on table produtos
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . AnnotationConfiguration applyHibernateValidatorLegacyConstraintsOnDDL
INFO : Hibernate Validator not found : ignoring
16 / 03 / 2010 17 : 43 : 54 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : Using Hibernate built - in connection pool ( not for production use ! )
16 / 03 / 2010 17 : 43 : 54 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : Hibernate connection pool size : 1
16 / 03 / 2010 17 : 43 : 54 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : autocommit mode : false
16 / 03 / 2010 17 : 43 : 54 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : using driver : com . mysql . jdbc . Driver at URL : jdbc : mysql : //localhost:3306/caelum
16 / 03 / 2010 17 : 43 : 54 org . hibernate . connection . DriverManagerConnectionProvider configure
INFO : connection properties : { user = root , password =**** }
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : RDBMS : MySQL , version : 5.1.33 - community
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC driver : MySQL - AB JDBC Driver , version : mysql - connector - java -5.1.12 ( Revision : $ { bzr . revision - id } )
16 / 03 / 2010 17 : 43 : 54 org . hibernate . dialect . Dialect & lt ; init & gt ;
INFO : Using dialect : org . hibernate . dialect . MySQLDialect
16 / 03 / 2010 17 : 43 : 54 org . hibernate . engine . jdbc . JdbcSupportLoader useContextualLobCreation
INFO : Disabling contextual LOB creation as JDBC driver reported JDBC version [ 3 ] less than 4
16 / 03 / 2010 17 : 43 : 54 org . hibernate . transaction . TransactionFactoryFactory buildTransactionFactory
INFO : Using default transaction strategy ( direct JDBC transactions )
16 / 03 / 2010 17 : 43 : 54 org . hibernate . transaction . TransactionManagerLookupFactory getTransactionManagerLookup
INFO : No TransactionManagerLookup configured ( in JTA environment , use of read - write or transactional second - level cache is not recommended )
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Automatic flush during beforeCompletion () : disabled
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Automatic session close at end of transaction : disabled
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC batch size : 15
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC batch updates for versioned data : enabled
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Scrollable result sets : enabled
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JDBC3 getGeneratedKeys () : enabled
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Connection release mode : auto
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Maximum outer join fetch depth : 1
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Default batch fetch size : 1
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Generate SQL with comments : disabled
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Order SQL updates by primary key : disabled
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Order SQL inserts for batching : disabled
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory createQueryTranslatorFactory
INFO : Query translator : org . hibernate . hql . ast . ASTQueryTranslatorFactory
16 / 03 / 2010 17 : 43 : 54 org . hibernate . hql . ast . ASTQueryTranslatorFactory & lt ; init & gt ;
INFO : Using ASTQueryTranslatorFactory
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Query language substitutions : { yes = 'Y' , no = 'N' }
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : JPA - QL strict compliance : disabled
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Second - level cache : enabled
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Query cache : disabled
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory createRegionFactory
INFO : Cache region factory : org . hibernate . cache . impl . bridge . RegionFactoryCacheProviderBridge
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cache . impl . bridge . RegionFactoryCacheProviderBridge & lt ; init & gt ;
INFO : Cache provider : org . hibernate . cache . HashtableCacheProvider
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Optimize cache for minimal puts : disabled
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Cache region prefix : hibernate . test
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Structured second - level cache entries : disabled
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Echoing all SQL to stdout
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Statistics : disabled
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Deleted entity synthetic identifier rollback : disabled
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Default entity - mode : pojo
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Named query checking : enabled
16 / 03 / 2010 17 : 43 : 54 org . hibernate . cfg . SettingsFactory buildSettings
INFO : Check Nullability in Core ( should be disabled when Bean Validation is on ) : enabled
17 : 43 : 54 , 828 DEBUG ClassValidator : 138 - ResourceBundle ValidatorMessages not found in Validator classloader . Delegate to org . hibernate . validator . resources . DefaultValidatorMessages
16 / 03 / 2010 17 : 43 : 54 org . hibernate . impl . SessionFactoryImpl & lt ; init & gt ;
INFO : building session factory
16 / 03 / 2010 17 : 43 : 55 org . hibernate . impl . SessionFactoryObjectFactory addInstance
INFO : Not binding factory to JNDI , no JNDI name configured
16 / 03 / 2010 17 : 43 : 55 org . hibernate . tool . hbm2ddl . SchemaValidator validate
INFO : Running schema validator
16 / 03 / 2010 17 : 43 : 55 org . hibernate . tool . hbm2ddl . SchemaValidator validate
INFO : fetching database metadata
16 / 03 / 2010 17 : 43 : 55 org . hibernate . tool . hbm2ddl . TableMetadata & lt ; init & gt ;
INFO : table found : caelum . produtos
16 / 03 / 2010 17 : 43 : 55 org . hibernate . tool . hbm2ddl . TableMetadata & lt ; init & gt ;
INFO : columns : [ id , preco , quantidade , nome ]
Exception in thread "main" org . hibernate . hql . ast . QuerySyntaxException : Produtos is not mapped [ from Produtos ]
at org . hibernate . hql . ast . util . SessionFactoryHelper . requireClassPersister ( SessionFactoryHelper . java : 181 )
at org . hibernate . hql . ast . tree . FromElementFactory . addFromElement ( FromElementFactory . java : 111 )
at org . hibernate . hql . ast . tree . FromClause . addFromElement ( FromClause . java : 93 )
at org . hibernate . hql . ast . HqlSqlWalker . createFromElement ( HqlSqlWalker . java : 313 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . fromElement ( HqlSqlBaseWalker . java : 3353 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . fromElementList ( HqlSqlBaseWalker . java : 3237 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . fromClause ( HqlSqlBaseWalker . java : 724 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . query ( HqlSqlBaseWalker . java : 575 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . selectStatement ( HqlSqlBaseWalker . java : 292 )
at org . hibernate . hql . antlr . HqlSqlBaseWalker . statement ( HqlSqlBaseWalker . java : 235 )
at org . hibernate . hql . ast . QueryTranslatorImpl . analyze ( QueryTranslatorImpl . java : 254 )
at org . hibernate . hql . ast . QueryTranslatorImpl . doCompile ( QueryTranslatorImpl . java : 185 )
at org . hibernate . hql . ast . QueryTranslatorImpl . compile ( QueryTranslatorImpl . java : 136 )
at org . hibernate . engine . query . HQLQueryPlan . & lt ; init & gt ;( HQLQueryPlan . java : 101 )
at org . hibernate . engine . query . HQLQueryPlan . & lt ; init & gt ;( HQLQueryPlan . java : 80 )
at org . hibernate . engine . query . QueryPlanCache . getHQLQueryPlan ( QueryPlanCache . java : 98 )
at org . hibernate . impl . AbstractSessionImpl . getHQLQueryPlan ( AbstractSessionImpl . java : 156 )
at org . hibernate . impl . AbstractSessionImpl . createQuery ( AbstractSessionImpl . java : 135 )
at org . hibernate . impl . SessionImpl . createQuery ( SessionImpl . java : 1760 )
at br . com . caelum . hibernate . GeraTabelas . main ( GeraTabelas . java : 18 )
rogelgarcia 16 de mar. de 2010
Ali fala Produtos is not mapped… onde tá escrito esse Produtos ?
TheKill 16 de mar. de 2010
a tabela do banco é produtos, o resto as classe sao Produto
rogelgarcia 16 de mar. de 2010
Mas em algum lugar… além do nome da tabela tá escrito Produtos
não é from Produtos
é from Produto
TheKill 16 de mar. de 2010
entendi, deu certo…
Só faltou fazer o Insert, que continua nao funcionando…
Se você puder me ajudar amanhã… ficarei muito contente…
E muito obrigado pela ajuda, vc me ajudou muito, serio mesmo… Valeu =)
rogelgarcia 16 de mar. de 2010
Depois voce pode entrar no site do meu framework http://www.nextframework.org
E fazer uma doaçao
O insert vai ser fácil… agora que tá tudo mapeado certinho… flw pro c
TheKill 17 de mar. de 2010
Voltando a reabrir o tópico e o velho problema com Hibernate
Brasileiro não desiste nunca ^^
Hoje vai xD
TheKill 17 de mar. de 2010
detalhe do erro:
Exception in thread "main" java . lang . NoSuchMethodError : org . hibernate . event . PreInsertEvent . getSource () Lorg / hibernate / engine / SessionImplementor ;
at org . hibernate . validator . event . ValidateEventListener . onPreInsert ( ValidateEventListener . java : 127 )
at org . hibernate . action . EntityIdentityInsertAction . preInsert ( EntityIdentityInsertAction . java : 159 )
at org . hibernate . action . EntityIdentityInsertAction . execute ( EntityIdentityInsertAction . java : 65 )
at org . hibernate . engine . ActionQueue . execute ( ActionQueue . java : 268 )
at org . hibernate . event . def . AbstractSaveEventListener . performSaveOrReplicate ( AbstractSaveEventListener . java : 321 )
at org . hibernate . event . def . AbstractSaveEventListener . performSave ( AbstractSaveEventListener . java : 204 )
at org . hibernate . event . def . AbstractSaveEventListener . saveWithGeneratedId ( AbstractSaveEventListener . java : 130 )
at org . hibernate . event . def . DefaultSaveOrUpdateEventListener . saveWithGeneratedOrRequestedId ( DefaultSaveOrUpdateEventListener . java : 210 )
at org . hibernate . event . def . DefaultSaveEventListener . saveWithGeneratedOrRequestedId ( DefaultSaveEventListener . java : 56 )
at org . hibernate . event . def . DefaultSaveOrUpdateEventListener . entityIsTransient ( DefaultSaveOrUpdateEventListener . java : 195 )
at org . hibernate . event . def . DefaultSaveEventListener . performSaveOrUpdate ( DefaultSaveEventListener . java : 50 )
at org . hibernate . event . def . DefaultSaveOrUpdateEventListener . onSaveOrUpdate ( DefaultSaveOrUpdateEventListener . java : 93 )
at org . hibernate . impl . SessionImpl . fireSave ( SessionImpl . java : 705 )
at org . hibernate . impl . SessionImpl . save ( SessionImpl . java : 693 )
at org . hibernate . impl . SessionImpl . save ( SessionImpl . java : 689 )
at br . com . caelum . hibernate . GeraTabelas . main ( GeraTabelas . java : 27 )
TheKill 17 de mar. de 2010
erro resolvido, versão do hibernate annotations incompatível com hibernate core…
Porém ainda não está adicionando nada ao banco.
processo:
session = new HibernateUtil (). getSession ();
Produto p = new Produto ();
p . setNome ( "Blusa Idio´s" );
p . setPreco ( 100.50 );
p . setQuantidade ( 3 );
session = new HibernateUtil (). getSession ();
session . save ( p );
System . out . println ( "ID do produto: " + p . getId ());
session . close ();
resultado:
Hibernate :
insert
into
produtos
( nome , preco , quantidade )
values
(?, ?, ?)
ID do produto : 1
TheKill 17 de mar. de 2010
Resolvido… Pessoal muito cuidado ao seguir tutorial de apostilas
hUAIDSHAUIdhiuAdhiuashdiuahdia
na classe DAO para salvar no banco deve ter uma Transaction de commit,
Porque se não, ele fica sómente incrementando seu ID e não insere no banco
Valeu pela ajuda galera…
Att. Jonas
rogelgarcia 17 de mar. de 2010
Já resolveu tudo… ehehhe
Esse cara tem o dom