Pessoal estou tentando criar uma aplicação usando Flex+Java+blazeDs+Hibernate até ai tudo bem acredito que tenha configurado o projeto da forma correta
entretanto meu método inserir do meu repositório usando hibernate não funciona. Agradeço ajuda por que ele me mostra umas mensagens de Info mas não
to sabendo identificar o erro. Agradeço ajuda segue os códigos. Outra coisa para usar hibernete em um projeto web necessáriamente preciso de spring??
agradeço muito ajuda.
hibernate.cfg.xml está na pasta source do projeto
[code]
<?xml version="1.0" encoding="UTF-8"?> org.postgresql.Driver postgres jdbc:postgresql://localhost:5432/pesquisa postgres org.hibernate.dialect.PostgreSQLDialect <!-- Mapping -->
<mapping class="br.com.formpesquisa.business.entity.FuncionarioTeste" />
</session-factory>
[/code]
Minha classe createSessionFactory realiza o controle da minha sessionfactory para que só possa ser obitida uma instância seguindo o padrão singoton
public class CreateSessionFactory {
private static SessionFactory sessionfactory;
private CreateSessionFactory() {
init();
}
private static void init() {
AnnotationConfiguration acfg = new AnnotationConfiguration()
.configure();
sessionfactory = acfg.buildSessionFactory();
}
private static SessionFactory getSessionFactory() {
if (sessionfactory == null) {
init();
}
return sessionfactory;
}
public static Session openSession() {
Session sess = getSessionFactory().openSession();
return sess;
}
}
Meu repositorio com o método Inserir que não insere nada chama meu método openSession para obter a instância de sessionFactory
import br.com.formpesquisa.business.entity.FuncionarioTeste;
import org.hibernate.Session;
public class RepositorioFuncionario //implements IrepositorioFuncionario
{
public RepositorioFuncionario() {
}
public void inserirFuncionario(FuncionarioTeste f) {
Session session = CreateSessionFactory.openSession();
session.save(f);
session.close();
}
public void removerFuncionario(String cpf) {
Session session = CreateSessionFactory.openSession();
session.delete(cpf);
session.close();
}
public void atualizarFuncionarioTeste(String cpf, FuncionarioTeste f) {
// TODO Auto-generated method stub
}
public FuncionarioTeste consultarFuncionario(String cpf) {
// TODO Auto-generated method stub
return null;
}
}
E finalmente meu main onde quando vou executar minha aplicação web eu clico com o direito e peço para executar como uma java aplication
[code]
public class Teste {
public static void main(String[] args) {
FuncionarioTeste f = new FuncionarioTeste("Antônio", "12345678963","1234567", 50);
RepositorioFuncionario r = new RepositorioFuncionario();
r.inserirFuncionario(f);
}
}[/code]
E as mensagens de Info são essas
1 [main] INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.4.0.CR1
13 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.0.CR1
28 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
31 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : cglib
36 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
81 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.1.0.CR1
83 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
83 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
251 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
303 [main] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.com.formpesquisa.business.entity.FuncionarioTeste
335 [main] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.com.formpesquisa.business.entity.FuncionarioTeste on table funcionarios
373 [main] INFO org.hibernate.cfg.AnnotationConfiguration - Hibernate Validator not found: ignoring
415 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
415 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
416 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
425 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost:5432/pesquisa
425 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=postgres, password=****}
499 [main] INFO org.hibernate.cfg.SettingsFactory - RDBMS: PostgreSQL, version: 8.4.6
499 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.3 JDBC3 with SSL (build 604)
510 [main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.PostgreSQLDialect
514 [main] INFO org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
515 [main] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
515 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
515 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
515 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
515 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
515 [main] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
516 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): disabled
516 [main] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
516 [main] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
516 [main] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
516 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
516 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
516 [main] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
518 [main] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
518 [main] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
518 [main] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
518 [main] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
518 [main] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
518 [main] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
518 [main] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
518 [main] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
522 [main] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
522 [main] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
522 [main] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
523 [main] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
557 [main] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
724 [main] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured