Hibernate faz que insere mas não insere na tabela - Resolvido

Olá Pessoal se alguém puder me dar um Help… agradeço

Estou testando o Hibernate com Mysql no Eclipse
Tuto ocorre normal, porem os dados não são efetivamente inseridos na tabela.
Ele inclusive mostra o ID do registro que inseriu mas ao abrir a tabela está vazia…

Abaixo segue o LOG:

br.com.caelum.hibernate.Produto@82ba41
10:12:27,671  INFO Version:15 - Hibernate Annotations 3.2.0.CR1
10:12:27,687  INFO Environment:479 - Hibernate 3.1.3
10:12:27,687  INFO Environment:494 - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=com.mysql.jdbc.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider, hibernate.max_fetch_depth=1, hibernate.dialect=org.hibernate.dialect.MySQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.query.substitutions=yes 'Y', no 'N', hibernate.connection.username=root, hibernate.cache.region_prefix=hibernate.test, hibernate.connection.url=jdbc:mysql://localhost/teste_java, hibernate.connection.password=****, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.pool_size=1}
10:12:27,687  INFO Environment:524 - using java.io streams to persist binary types
10:12:27,703  INFO Environment:525 - using CGLIB reflection optimizer
10:12:27,703  INFO Environment:555 - using JDK 1.4 java.sql.Timestamp handling
10:12:27,906  INFO AnnotationBinder:386 - Binding entity from annotated class: br.com.caelum.hibernate.Produto
10:12:27,953  INFO EntityBinder:325 - Bind entity br.com.caelum.hibernate.Produto on table Produto
10:12:28,109  INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
10:12:28,109  INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
10:12:28,125  INFO DriverManagerConnectionProvider:45 - autocommit mode: false
10:12:28,125  INFO DriverManagerConnectionProvider:80 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/teste_java
10:12:28,125  INFO DriverManagerConnectionProvider:86 - connection properties: {user=root, password=****}
10:12:28,343  INFO SettingsFactory:77 - RDBMS: MySQL, version: 4.1.6-gamma-nt
10:12:28,343  INFO SettingsFactory:78 - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.0.3 ( $Date: 2006-07-26 17:26:47 +0200 (Wed, 26 Jul 2006) $, $Revision: 5553 $ )
10:12:28,359  INFO Dialect:103 - Using dialect: org.hibernate.dialect.MySQLDialect
10:12:28,375  INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
10:12:28,375  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
10:12:28,375  INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
10:12:28,375  INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
10:12:28,375  INFO SettingsFactory:136 - JDBC batch size: 15
10:12:28,375  INFO SettingsFactory:139 - JDBC batch updates for versioned data: enabled
10:12:28,375  INFO SettingsFactory:144 - Scrollable result sets: enabled
10:12:28,375  INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): enabled
10:12:28,375  INFO SettingsFactory:160 - Connection release mode: auto
10:12:28,390  INFO SettingsFactory:184 - Maximum outer join fetch depth: 1
10:12:28,390  INFO SettingsFactory:187 - Default batch fetch size: 1
10:12:28,390  INFO SettingsFactory:191 - Generate SQL with comments: disabled
10:12:28,390  INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
10:12:28,390  INFO SettingsFactory:338 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
10:12:28,390  INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
10:12:28,390  INFO SettingsFactory:203 - Query language substitutions: {no='N', yes='Y'}
10:12:28,390  INFO SettingsFactory:209 - Second-level cache: enabled
10:12:28,390  INFO SettingsFactory:213 - Query cache: disabled
10:12:28,390  INFO SettingsFactory:325 - Cache provider: org.hibernate.cache.HashtableCacheProvider
10:12:28,390  INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
10:12:28,390  INFO SettingsFactory:233 - Cache region prefix: hibernate.test
10:12:28,390  INFO SettingsFactory:237 - Structured second-level cache entries: disabled
10:12:28,406  INFO SettingsFactory:264 - Statistics: disabled
10:12:28,406  INFO SettingsFactory:268 - Deleted entity synthetic identifier rollback: disabled
10:12:28,406  INFO SettingsFactory:283 - Default entity-mode: pojo
10:12:28,437  INFO SessionFactoryImpl:154 - building session factory
10:12:28,828  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
Sessão criada
10:12:28,890 DEBUG SQL:346 - insert into Produto (descri, nome, preco) values (?, ?, ?)
10:12:28,906 DEBUG StringType:80 - binding 'Desc do produto' to parameter: 1
10:12:28,906 DEBUG StringType:80 - binding 'Nome do produto' to parameter: 2
10:12:28,906 DEBUG DoubleType:80 - binding '100.1' to parameter: 3
Produto ID: 11
Conectado:true

Segue o COD:

	public static void main(String[] args) {
		
		// TODO Auto-generated method stub
		Produto produto = new Produto();
		produto.setNome("Nome do produto");
		produto.setDescricao("Desc do produto");
		produto.setPreco(100.1);
		System.out.println(produto);
		
		AnnotationConfiguration cfg = new AnnotationConfiguration();
		cfg.addAnnotatedClass(Produto.class);
		SessionFactory factory = cfg.buildSessionFactory();
		Session session = factory.openSession();

		session.save(produto);
		System.out.println("Produto ID: " + produto.getId());
		System.out.println("Conectado:" + session.isConnected());		
				
	}

Obs: De alguma forma ele está tentando gravar, pois se insiro os dados manualmente na tabela ele atribui o ID (Autoincrement) sempre com valores considerendo como se tivesse algo na tabela.
Por exemplo no log acima o Hibernate devolveu o ID 11, se eu inserir o registro manulamente será atribuido o ID 12…
Já abri a tabela em diversos modos diferentes e sempre está vazia.

Agradeço a atenção

Você não esta usando uma transação.

tenta isto.

Transaction transacao = session.beginTransaction();
   .
   .
   .
   .
   session.save(produto);
transacao.commit();

[quote=zepunk]Você não esta usando uma transação.

tenta isto.

Transaction transacao = session.beginTransaction(); . . . . session.save(produto); transacao.commit(); [/quote]

Ok. Obrigado amigo
Era isso mesmo.
Funcionando 100% agora!!