Problema com Hibernate

Olá pessoal.

Estou iniciando uma aplicação e estou tendo um problema com hibernate. Não consigo de forma alguma que através de annotations, criar as tabelas no meu DB.

Segue abaixo a saida no console após rodar a classe para criação, bem como o arquivo cfg.xml. Se alguém puder dar uma ajuda, agradeço. Abs.

[code]import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.*;

public class CreateDB {

/**
 * @param args
 */		
public static void main(String[] args) {
	Configuration configuration = new AnnotationConfiguration();
	configuration.configure();
	SchemaExport se = new SchemaExport(configuration);
	se.create(true, true);
}

}[/code]

[code]<?xml version="1.0" encoding="UTF-8"?>

com.mysql.jdbc.Driver jdbc:mysql://localhost/scn org.hibernate.dialect.MySQLDialect root_scn root_scn
    <property name="hibernate.show_sql">true</property>
	<property name="hibernate.format_sql">true</property>
	
	<property name="hibernate.c3p0.min_size">5</property>
	<property name="hibernate.c3p0.max_size">20</property>
	<property name="hibernate.c3p0.timeout">180</property>
	<property name="hibernate.c3p0.idle_test_period">100</property>  
	  	
	<mapping class="br.com.scn.bean.Login"/>
	<mapping class="br.com.scn.bean.Auditoria"/>
	<mapping class="br.com.scn.bean.Medicacao"/>
	<mapping class="br.com.scn.bean.Material"/>
	<mapping class="br.com.scn.bean.Atividade"/>
	<mapping class="br.com.scn.bean.Codigos"/>
	<mapping class="br.com.scn.bean.Empresa"/>
	<mapping class="br.com.scn.bean.Paciente"/>
	<mapping class="br.com.scn.bean.Prontuario"/>
	<mapping class="br.com.scn.bean.Tp_Cobranca"/>
	<mapping class="br.com.scn.bean.Valor"/>         
    
</session-factory>

[/code]

12:16:52,427 INFO Version:15 - Hibernate Annotations 3.3.1.GA
12:16:52,501 INFO Environment:500 - Hibernate 3.2.0
12:16:52,518 INFO Environment:533 - hibernate.properties not found
12:16:52,527 INFO Environment:667 - Bytecode provider name : cglib
12:16:52,541 INFO Environment:584 - using JDK 1.4 java.sql.Timestamp handling
12:16:52,843 INFO Configuration:1350 - configuring from resource: /hibernate.cfg.xml
12:16:52,845 INFO Configuration:1327 - Configuration resource: /hibernate.cfg.xml
12:16:53,241 INFO Configuration:1465 - Configured SessionFactory: null
12:16:53,303 INFO Dialect:141 - Using dialect: org.hibernate.dialect.MySQLDialect
12:16:53,557 INFO SchemaExport:154 - Running hbm2ddl schema export
12:16:53,558 DEBUG SchemaExport:170 - import file not found: /import.sql
12:16:53,559 INFO SchemaExport:179 - exporting generated schema to database
12:16:53,564 INFO C3P0ConnectionProvider:50 - C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/scn
12:16:53,564 INFO C3P0ConnectionProvider:51 - Connection properties: {user=root_scn, password=****}
12:16:53,565 INFO C3P0ConnectionProvider:54 - autocommit mode: false
12:16:54,789 INFO SchemaExport:196 - schema export complete

tente incluir

no seu hibernate.cfg.xml

Olá Orlando.

Já havia tentado create, update etc, mas até agora não consegui resolver. Já fiz isso algumas (Hibernate e annotations) vezes e nunca tive esse problema. Estou um pouco enferrujado com java, tô meio perdido.

Mas, valeu a dica/força.

Obrigado.

Abs,

19:22:49,497 INFO Version:15 - Hibernate Annotations 3.3.1.GA 19:22:49,528 INFO Environment:500 - Hibernate 3.2.0 19:22:49,533 INFO Environment:518 - loaded properties from resource hibernate.properties: {hibernate.bytecode.use_reflection_optimizer=false} 19:22:49,536 INFO Environment:667 - Bytecode provider name : cglib 19:22:49,543 INFO Environment:584 - using JDK 1.4 java.sql.Timestamp handling 19:22:49,687 INFO Configuration:1350 - configuring from resource: /hibernate.cfg.xml 19:22:49,688 INFO Configuration:1327 - Configuration resource: /hibernate.cfg.xml 19:22:49,872 INFO Configuration:1465 - Configured SessionFactory: null 19:22:49,899 INFO Dialect:141 - Using dialect: org.hibernate.dialect.MySQLDialect 19:22:50,159 INFO SchemaExport:154 - Running hbm2ddl schema export 19:22:50,160 INFO SchemaExport:179 - exporting generated schema to database 19:22:50,165 INFO C3P0ConnectionProvider:50 - C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/scn 19:22:50,166 INFO C3P0ConnectionProvider:51 - Connection properties: {user=root_scn, password=****} 19:22:50,166 INFO C3P0ConnectionProvider:54 - autocommit mode: false 19:22:51,229 INFO SchemaExport:238 - Executing import script: /import.sql 19:22:51,230 INFO SchemaExport:196 - schema export complete

Pessoal,

Depois de dar uma vasculhada pela net, substitui a linha import org.hibernate.annotations.Entity por import javax.persistence.Entity. Ele começou a funcionar, mas agora, estou tendo o problema por exemplo com a classe abaixo (Isso esta ocorrendo com algumas classes).

Se alguém puder ajudar, agradeço.

Abs,

[code]package br.com.scn.bean;

import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import javax.persistence.Entity;

@Entity
@Table(name=“tbl_atvid”)
public class Atividade {

@Id
@GeneratedValue
private Long id;
private String nome;
private String desc;
private Long id_cod;
private Long id_vlr;
private Long id_tp_cbrc;

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 String getDesc() {
	return desc;
}
public void setDesc(String desc) {
	this.desc = desc;
}
public Long getId_cod() {
	return id_cod;
}
public void setId_cod(Long id_cod) {
	this.id_cod = id_cod;
}
public Long getId_vlr() {
	return id_vlr;
}
public void setId_vlr(Long id_vlr) {
	this.id_vlr = id_vlr;
}
public Long getId_tp_cbrc() {
	return id_tp_cbrc;
}
public void setId_tp_cbrc(Long id_tp_cbrc) {
	this.id_tp_cbrc = id_tp_cbrc;
}	

}
[/code]

19:41:11,648 INFO Version:15 - Hibernate Annotations 3.3.1.GA
19:41:11,697 INFO Environment:500 - Hibernate 3.2.0
19:41:11,705 INFO Environment:518 - loaded properties from resource hibernate.properties: {hibernate.bytecode.use_reflection_optimizer=false}
19:41:11,707 INFO Environment:667 - Bytecode provider name : cglib
19:41:11,715 INFO Environment:584 - using JDK 1.4 java.sql.Timestamp handling
19:41:11,866 INFO Configuration:1350 - configuring from resource: /hibernate.cfg.xml
19:41:11,867 INFO Configuration:1327 - Configuration resource: /hibernate.cfg.xml
19:41:12,082 INFO Configuration:1465 - Configured SessionFactory: null
19:41:12,114 INFO Dialect:141 - Using dialect: org.hibernate.dialect.MySQLDialect
19:41:12,392 INFO AnnotationBinder:418 - Binding entity from annotated class: br.com.scn.bean.Auditoria
19:41:12,475 INFO EntityBinder:424 - Bind entity br.com.scn.bean.Auditoria on table tbl_audt
19:41:12,559 INFO AnnotationBinder:418 - Binding entity from annotated class: br.com.scn.bean.Atividade
19:41:12,560 INFO EntityBinder:424 - Bind entity br.com.scn.bean.Atividade on table tbl_atvid
19:41:12,563 INFO AnnotationBinder:418 - Binding entity from annotated class: br.com.scn.bean.Codigos
19:41:12,564 INFO EntityBinder:424 - Bind entity br.com.scn.bean.Codigos on table tbl_codgs
19:41:12,578 INFO Version:17 - Hibernate Validator 3.0.0.GA
19:41:12,676 INFO SchemaExport:154 - Running hbm2ddl schema export
19:41:12,677 INFO SchemaExport:179 - exporting generated schema to database
19:41:12,683 INFO C3P0ConnectionProvider:50 - C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/scn
19:41:12,684 INFO C3P0ConnectionProvider:51 - Connection properties: {user=root_scn, password=****}
19:41:12,684 INFO C3P0ConnectionProvider:54 - autocommit mode: false

drop table if exists tbl_atvid

19:41:13,609 DEBUG SchemaExport:303 -
drop table if exists tbl_atvid
19:41:13,624 WARN JDBCExceptionReporter:48 - SQL Warning: 1051, SQLState: 42S02
19:41:13,624 WARN JDBCExceptionReporter:49 - Unknown table ‘tbl_atvid’

drop table if exists tbl_audt

19:41:13,624 DEBUG SchemaExport:303 -
drop table if exists tbl_audt
19:41:13,625 WARN JDBCExceptionReporter:48 - SQL Warning: 1051, SQLState: 42S02
19:41:13,626 WARN JDBCExceptionReporter:49 - Unknown table ‘tbl_atvid’

drop table if exists tbl_codgs

19:41:13,626 DEBUG SchemaExport:303 -
drop table if exists tbl_codgs
19:41:13,629 WARN JDBCExceptionReporter:48 - SQL Warning: 1051, SQLState: 42S02
19:41:13,629 WARN JDBCExceptionReporter:49 - Unknown table 'tbl_atvid’
19:41:13,630 WARN JDBCExceptionReporter:48 - SQL Warning: 1051, SQLState: 42S02
19:41:13,630 WARN JDBCExceptionReporter:49 - Unknown table ‘tbl_codgs’

create table tbl_atvid (
    id bigint not null auto_increment,
    desc varchar(255),
    id_cod bigint,
    id_tp_cbrc bigint,
    id_vlr bigint,
    nome varchar(255),
    primary key (id)
)

19:41:13,631 DEBUG SchemaExport:303 -
create table tbl_atvid (
id bigint not null auto_increment,
desc varchar(255),
id_cod bigint,
id_tp_cbrc bigint,
id_vlr bigint,
nome varchar(255),
primary key (id)
)
19:41:13,652 ERROR SchemaExport:274 - Unsuccessful: create table tbl_atvid (id bigint not null auto_increment, desc varchar(255), id_cod bigint, id_tp_cbrc bigint, id_vlr bigint, nome varchar(255), primary key (id))
19:41:13,652 ERROR SchemaExport:275 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘desc varchar(255), id_cod bigint, id_tp_cbrc bigint, id_vlr bigint, nome varchar’ at line 1

create table tbl_audt (
    id bigint not null auto_increment,
    evento varchar(255),
    hr_fm datetime,
    hr_inic datetime,
    id_login bigint,
    ip_cpt bigint,
    tp_evento varchar(255),
    primary key (id)
)

19:41:13,653 DEBUG SchemaExport:303 -
create table tbl_audt (
id bigint not null auto_increment,
evento varchar(255),
hr_fm datetime,
hr_inic datetime,
id_login bigint,
ip_cpt bigint,
tp_evento varchar(255),
primary key (id)
)
19:41:13,659 WARN JDBCExceptionReporter:48 - SQL Warning: 1051, SQLState: 42S02
19:41:13,659 WARN JDBCExceptionReporter:49 - Unknown table 'tbl_atvid’
19:41:13,660 WARN JDBCExceptionReporter:48 - SQL Warning: 1051, SQLState: 42S02
19:41:13,661 WARN JDBCExceptionReporter:49 - Unknown table ‘tbl_codgs’

create table tbl_codgs (
    id bigint not null auto_increment,
    desc varchar(255),
    nome varchar(255),
    primary key (id)
)

19:41:13,661 DEBUG SchemaExport:303 -
create table tbl_codgs (
id bigint not null auto_increment,
desc varchar(255),
nome varchar(255),
primary key (id)
)
19:41:13,663 ERROR SchemaExport:274 - Unsuccessful: create table tbl_codgs (id bigint not null auto_increment, desc varchar(255), nome varchar(255), primary key (id))
19:41:13,663 ERROR SchemaExport:275 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘desc varchar(255), nome varchar(255), primary key (id))’ at line 1
19:41:13,664 INFO SchemaExport:238 - Executing import script: /import.sql
19:41:13,665 INFO SchemaExport:196 - schema export complete

Pessoal,

Após um bom café… uma boa repensada… problema obviamente na minha frente (a solução)… RESOLVIDO.

Obrigado!!!