Pessoal, estou tentando criar a tabela com anotation
só que não está criando a tabela, segue abaixo o resultado da operation
16/03/2010 09:04:44 org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.5.0-CR-2
16/03/2010 09:04:45 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.5.0-CR-2
16/03/2010 09:04:45 org.hibernate.cfg.Environment <clinit>
INFO: loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=com.mysql.jdbc.Driver, hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider, hibernate.max_fetch_depth=1, hibernate.dialect=org.hibernate.dialect.MySQLMyISAMDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.format_sql=true, hibernate.query.substitutions=yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=root, hibernate.cache.region_prefix=hibernate.test, hibernate.connection.url=jdbc:mysql://localhost/caelum, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, hibernate.connection.password=****, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.pool_size=1}
16/03/2010 09:04:45 org.hibernate.cfg.Environment <clinit>
INFO: using java.io streams to persist binary types
16/03/2010 09:04:45 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : javassist
16/03/2010 09:04:45 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
16/03/2010 09:04:45 org.hibernate.annotations.common.Version <clinit>
INFO: Hibernate Commons Annotations 3.2.0-SNAPSHOT
16/03/2010 09:04:45 org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLMyISAMDialect
16/03/2010 09:04:45 org.hibernate.cfg.AnnotationConfiguration applyHibernateValidatorLegacyConstraintsOnDDL
INFO: Hibernate Validator not found: ignoring
16/03/2010 09:04:45 org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: Running hbm2ddl schema export
16/03/2010 09:04:45 org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: exporting generated schema to database
16/03/2010 09:04:45 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
16/03/2010 09:04:45 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 1
16/03/2010 09:04:45 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
16/03/2010 09:04:45 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/caelum
16/03/2010 09:04:45 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=root, password=****}
16/03/2010 09:04:45 org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: schema export complete
16/03/2010 09:04:45 org.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:mysql://localhost/caelum
INFO: autocommit mode: false ?
procurei no hibernate.properties por essa informação,
e nao encontrei… também tinha reparado isso
onde altera?
att. Jonas
Consegui colocar autocomit true , mas também nao adiantou
Alguem pode ajudar?
Alguma alma solidária para ajudar? SHdiuAHSDUIashidu
Help-me xD~
Mais qualé o erro… num vi nenhum
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
Estranho sempre criei tabelas assim e acredito que a mensagem é a mesma… vou testar aki
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
Março 16, 2010, 10:56am
#10
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);
}
}
[quote=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[/quote]
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 <init>
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 <init>
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 <init>
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
Março 16, 2010, 11:01am
#12
porque não consigo os resultados positivos do projeto??
Se tivece um erro, ao menos eu saberia por onde procurar
TheKill
Março 16, 2010, 11:03am
#13
pode postar seu hibernat.properts para eu ver?
sei la, nao sei oque pode ser
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
Março 16, 2010, 11:09am
#15
é que estou tentando aprender… omg…
como assim faltou anotações?
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
Março 16, 2010, 11:16am
#17
é ta complicado essa coisa… eu fiz as anotações da classe…
Mas continua nao funcionando, estava seguindo a apostila da Caelum…
Me explique passo a passo como vc está fazendo… vamos achar o erro.
TheKill
Março 16, 2010, 12:55pm
#19
certo, vamos lá
vou começar… cheguei agora beleza?? ta por ai?
TheKill
Março 16, 2010, 12:56pm
#20
Se você tiver Gtalk podemos conversar lá…
é o unico mensageiro que posso usar em serviço… thekill87@gmail.com