Mais agilidade no Hibernate [Resolvido]

2 respostas
F

Oi gente, to usando o Hibernate e to achando um pouco lento os resultados dele, pois toda vez que eu gravo algo, ele parece criar toda a fabrica de sessao e configurar todos as classes que eu uso, baseado nos meus codigos abaixo, tem algo q eu esteja fazendo errado?

Console Do Tomcat

0 [http-8080-6] INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.4.0.GA
16 [http-8080-6] INFO org.hibernate.cfg.Environment - Hibernate 3.3.0.SP1
16 [http-8080-6] INFO org.hibernate.cfg.Environment - loaded properties from resource hibernate.properties: {hibernate.pool_size=3, hibernate.connection.driver_class=org.postgresql.Driver, hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect, hibernate.format_sql=true, hibernate.connection.username=postgres, hibernate.hbm2ddl.auto=create;, hibernate.connection.url=jdbc:postgresql://localhost:5432/CurriculoSDB, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, hibernate.connection.password=****}
63 [http-8080-6] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
110 [http-8080-6] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
156 [http-8080-6] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.1.0.GA
188 [http-8080-6] INFO org.hibernate.cfg.search.HibernateSearchEventListenerRegister - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
219 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Pessoas
250 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Pessoas on table Pessoas
297 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Estado
297 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Estado on table Estado
297 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Cidade
297 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Cidade on table Cidade
297 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Inspetoria
297 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Inspetoria on table Inspetoria
328 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Familia_Salesiana
406 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Familia_Salesiana on table Familia_Salesiana
406 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Comunidade
406 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Comunidade on table Comunidade
406 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Obra
500 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Obra on table Obra
500 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Comunidade_Obra
500 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Comunidade_Obra on table Hist_Comunidade_Obra
500 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Salesianos
610 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Salesianos on table Salesianos
610 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Separacao
610 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Separacao on table Separacao
610 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Separacao
703 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Separacao on table Hist_Separacao
703 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Parentesco
703 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Parentesco on table Parentesco
703 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Eventos
813 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Eventos on table Eventos
813 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Eventos
813 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Eventos on table Hist_Eventos
813 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Cursos_Especializados
906 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Cursos_Especializados on table Cursos_Especializados
906 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Cursos_Especializados
906 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Cursos_Especializados on table Hist_Cursos_Especializados
906 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Sacramentos_Ministerios
1000 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Sacramentos_Ministerios on table Sacramentos_Ministerios
1000 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Diocese
1000 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Diocese on table Diocese
1000 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Bispos
1110 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Bispos on table Bispos
1110 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Paroquia
1110 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Paroquia on table Paroquia
1110 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Diocese_Bispo
1203 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Diocese_Bispo on table Hist_Diocese_Bispo
1219 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Formacao_Religiosa
1219 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Formacao_Religiosa on table Formacao_Religiosa
1219 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Formacao_Religiosa
1313 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Formacao_Religiosa on table Hist_Formacao_Religiosa
1313 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Sistemas
1313 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Sistemas on table Sistemas
1313 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Cargo
1406 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Cargo on table Cargo
1406 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Comissao
1406 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Comissao on table Hist_Comissao
1406 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Profissoes
1516 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Profissoes on table Profissoes
1516 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Profissoes
1516 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Profissoes on table Hist_Profissoes
1516 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Tipo_Producao
1516 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Tipo_Producao on table Tipo_Producao
1610 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Producao_Intelectual
1610 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Producao_Intelectual on table Producao_Intelectual
1610 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Graduacao
1610 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Graduacao on table Graduacao
1719 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Graduacao
1719 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Graduacao on table Hist_Graduacao
1719 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Comunidade
1719 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Comunidade on table Hist_Comunidade
1813 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Salesianos_Obra
1813 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Salesianos_Obra on table Hist_Salesianos_Obra
1813 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Salesiano_Paroquia
1813 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Salesiano_Paroquia on table Hist_Salesiano_Paroquia
1906 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Sacramentos_Ministerios
1906 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Sacramentos_Ministerios on table Hist_Sacramentos_Ministerios
1953 [http-8080-6] INFO org.hibernate.cfg.annotations.CollectionBinder - Mapping collection: br.salesianos.modelo.Inspetoria.comunidade -> Comunidade
1969 [http-8080-6] INFO org.hibernate.cfg.annotations.CollectionBinder - Mapping collection: br.salesianos.modelo.Inspetoria.familiasalesiana -> Familia_Salesiana
2016 [http-8080-6] INFO org.hibernate.cfg.annotations.CollectionBinder - Mapping collection: br.salesianos.modelo.Comunidade.histComunidadeObra -> Hist_Comunidade_Obra
2016 [http-8080-6] INFO org.hibernate.cfg.annotations.CollectionBinder - Mapping collection: br.salesianos.modelo.Obra.histComunidadeObra -> Hist_Comunidade_Obra
2016 [http-8080-6] INFO org.hibernate.cfg.AnnotationConfiguration - Hibernate Validator not found: ignoring
2016 [http-8080-6] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
2110 [http-8080-6] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
2110 [http-8080-6] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
2110 [http-8080-6] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost:5432/CurriculoSDB
2110 [http-8080-6] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=postgres, password=****}
2235 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - RDBMS: PostgreSQL, version: 9.0.0
2235 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 9.0devel JDBC3 (build 800)
2250 [http-8080-6] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.PostgreSQLDialect
2250 [http-8080-6] INFO org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
2250 [http-8080-6] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
2313 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
2313 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
2313 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
2313 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
2313 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
2313 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
2313 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
2313 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
2313 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
2313 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
2422 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
2422 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
2422 [http-8080-6] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
2422 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
2422 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
2422 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
2422 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
2422 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
2516 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
2516 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
2516 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
2516 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
2516 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
2516 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
2610 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
2703 [http-8080-6] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
3516 [http-8080-6] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
Hibernate: 
    select
        estado0_.est_id as est1_1_,
        estado0_.est_nom as est2_1_,
        estado0_.est_sigla as est3_1_ 
    from
        Estado estado0_ 
    where
        estado0_.est_nom like '%%' 
    order by
        estado0_.est_nom
3719 [http-8080-6] INFO org.hibernate.cfg.search.HibernateSearchEventListenerRegister - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
3719 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Pessoas
3719 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Pessoas on table Pessoas
3719 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Estado
3719 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Estado on table Estado
3719 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Cidade
3719 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Cidade on table Cidade
3719 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Inspetoria
3828 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Inspetoria on table Inspetoria
3828 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Familia_Salesiana
3828 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Familia_Salesiana on table Familia_Salesiana
3828 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Comunidade
3922 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Comunidade on table Comunidade
3922 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Obra
3922 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Obra on table Obra
3922 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Comunidade_Obra
4031 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Comunidade_Obra on table Hist_Comunidade_Obra
4031 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Salesianos
4031 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Salesianos on table Salesianos
4031 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Separacao
4125 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Separacao on table Separacao
4125 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Separacao
4125 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Separacao on table Hist_Separacao
4125 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Parentesco
4219 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Parentesco on table Parentesco
4219 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Eventos
4219 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Eventos on table Eventos
4219 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Eventos
4328 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Eventos on table Hist_Eventos
4328 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Cursos_Especializados
4328 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Cursos_Especializados on table Cursos_Especializados
4328 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Cursos_Especializados
4422 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Cursos_Especializados on table Hist_Cursos_Especializados
4422 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Sacramentos_Ministerios
4422 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Sacramentos_Ministerios on table Sacramentos_Ministerios
4422 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Diocese
4531 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Diocese on table Diocese
4531 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Bispos
4531 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Bispos on table Bispos
4531 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Paroquia
4531 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Paroquia on table Paroquia
4625 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Diocese_Bispo
4625 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Diocese_Bispo on table Hist_Diocese_Bispo
4625 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Formacao_Religiosa
4625 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Formacao_Religiosa on table Formacao_Religiosa
4734 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Formacao_Religiosa
4734 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Formacao_Religiosa on table Hist_Formacao_Religiosa
4734 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Sistemas
4734 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Sistemas on table Sistemas
4828 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Cargo
4828 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Cargo on table Cargo
4828 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Comissao
4828 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Comissao on table Hist_Comissao
4938 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Profissoes
4938 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Profissoes on table Profissoes
4938 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Profissoes
4938 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Profissoes on table Hist_Profissoes
5031 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Tipo_Producao
5031 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Tipo_Producao on table Tipo_Producao
5031 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Producao_Intelectual
5031 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Producao_Intelectual on table Producao_Intelectual
5125 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Graduacao
5125 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Graduacao on table Graduacao
5125 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Graduacao
5125 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Graduacao on table Hist_Graduacao
5234 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Comunidade
5234 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Comunidade on table Hist_Comunidade
5234 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Salesianos_Obra
5234 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Salesianos_Obra on table Hist_Salesianos_Obra
5328 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Salesiano_Paroquia
5328 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Salesiano_Paroquia on table Hist_Salesiano_Paroquia
5328 [http-8080-6] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.salesianos.modelo.Hist_Sacramentos_Ministerios
5328 [http-8080-6] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.salesianos.modelo.Hist_Sacramentos_Ministerios on table Hist_Sacramentos_Ministerios
5438 [http-8080-6] INFO org.hibernate.cfg.annotations.CollectionBinder - Mapping collection: br.salesianos.modelo.Inspetoria.comunidade -> Comunidade
5438 [http-8080-6] INFO org.hibernate.cfg.annotations.CollectionBinder - Mapping collection: br.salesianos.modelo.Inspetoria.familiasalesiana -> Familia_Salesiana
5438 [http-8080-6] INFO org.hibernate.cfg.annotations.CollectionBinder - Mapping collection: br.salesianos.modelo.Comunidade.histComunidadeObra -> Hist_Comunidade_Obra
5438 [http-8080-6] INFO org.hibernate.cfg.annotations.CollectionBinder - Mapping collection: br.salesianos.modelo.Obra.histComunidadeObra -> Hist_Comunidade_Obra
5531 [http-8080-6] INFO org.hibernate.cfg.AnnotationConfiguration - Hibernate Validator not found: ignoring
5531 [http-8080-6] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
5531 [http-8080-6] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
5531 [http-8080-6] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
5531 [http-8080-6] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost:5432/CurriculoSDB
5641 [http-8080-6] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=postgres, password=****}
5688 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - RDBMS: PostgreSQL, version: 9.0.0
5688 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 9.0devel JDBC3 (build 800)
5688 [http-8080-6] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.PostgreSQLDialect
5688 [http-8080-6] INFO org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
5688 [http-8080-6] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
5734 [http-8080-6] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
5734 [http-8080-6] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
5734 [http-8080-6] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
5781 [http-8080-6] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
Hibernate: 
    select
        nextval ('sequence_estado')
Hibernate: 
    insert 
    into
        Estado
        (est_nom, est_sigla, est_id) 
    values
        (?, ?, ?)
12/04/2011 13:16:46 com.sun.faces.context.SessionMap put
AVISO: JSF1063: AVISO! Definindo valor de atributo não serializável em HttpSession (chave: skinBean, classe do valor: br.salesianos.efeito.SkinBean).

CriadorDeSessao.java

package br.salesianos.db;

import br.salesianos.modelo.*;

import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

/**
 *
 * @author estinfo
 */
public class CriadorDeSessao {

    public static Session getSession() throws HibernateException, MappingException {
        AnnotationConfiguration cfg = new AnnotationConfiguration();
        cfg.addAnnotatedClass(Pessoas.class);
        cfg.addAnnotatedClass(Estado.class);
        cfg.addAnnotatedClass(Cidade.class);
        cfg.addAnnotatedClass(Inspetoria.class);
        cfg.addAnnotatedClass(Familia_Salesiana.class);
        cfg.addAnnotatedClass(Comunidade.class);
        cfg.addAnnotatedClass(Obra.class);
        cfg.addAnnotatedClass(Hist_Comunidade_Obra.class);
        cfg.addAnnotatedClass(Salesianos.class);
        cfg.addAnnotatedClass(Separacao.class);
        cfg.addAnnotatedClass(Hist_Separacao.class);
        cfg.addAnnotatedClass(Parentesco.class);
        cfg.addAnnotatedClass(Eventos.class);
        cfg.addAnnotatedClass(Hist_Eventos.class);
        cfg.addAnnotatedClass(Cursos_Especializados.class);
        cfg.addAnnotatedClass(Hist_Cursos_Especializados.class);
        cfg.addAnnotatedClass(Sacramentos_Ministerios.class);
        cfg.addAnnotatedClass(Diocese.class);
        cfg.addAnnotatedClass(Bispos.class);
        cfg.addAnnotatedClass(Paroquia.class);
        cfg.addAnnotatedClass(Hist_Diocese_Bispo.class);
        cfg.addAnnotatedClass(Formacao_Religiosa.class);
        cfg.addAnnotatedClass(Hist_Formacao_Religiosa.class);
        cfg.addAnnotatedClass(Sistemas.class);
        cfg.addAnnotatedClass(Cargo.class);
        cfg.addAnnotatedClass(Hist_Comissao.class);
        cfg.addAnnotatedClass(Profissoes.class);
        cfg.addAnnotatedClass(Hist_Profissoes.class);
        cfg.addAnnotatedClass(Tipo_Producao.class);
        cfg.addAnnotatedClass(Producao_Intelectual.class);
        cfg.addAnnotatedClass(Graduacao.class);
        cfg.addAnnotatedClass(Hist_Graduacao.class);
        cfg.addAnnotatedClass(Hist_Comunidade.class);
        cfg.addAnnotatedClass(Hist_Salesianos_Obra.class);
        cfg.addAnnotatedClass(Hist_Salesiano_Paroquia.class);
        cfg.addAnnotatedClass(Hist_Sacramentos_Ministerios.class);
        
        SessionFactory fabrica = cfg.buildSessionFactory();
        Session sessao = fabrica.openSession();
        return sessao;
    }

}

GravaEstado.java

package br.salesianos.db;

import br.salesianos.dao.*;
import br.salesianos.modelo.*;
import br.salesianos.modelo.Estado;
import javax.faces.bean.ManagedBean;
import org.apache.commons.lang.WordUtils;
import org.hibernate.*;

@ManagedBean
public class GravaEstado
{
    private Integer est_id;
    private String est_nome;
    private String est_sigla;
    private Integer vazio;
    
    public String gravar()
    {

             Session sessao = CriadorDeSessao.getSession();
             Transaction tx_estado = sessao.beginTransaction();
        try
         {
             Estado obj_estado = new Estado();
                          
             if (getEst_id() != 0) {
                 //System.out.println("É sim2");
                 obj_estado.setEst_id(getEst_id());
             }
             
             obj_estado.setEst_nom(WordUtils.capitalizeFully(getEst_nome()));             
             obj_estado.setEst_sigla(getEst_sigla().toUpperCase());
             
             sessao.saveOrUpdate(obj_estado);
             
             tx_estado.commit();
             sessao.close(); 
             return "sucesso";

         }
         catch(Exception erro)
         {

             System.out.println("Problema : "+erro);
             tx_estado.rollback();
             sessao.close();
             return "erro";
         }
    }

    public String excluir()
    {

             Session sessao = CriadorDeSessao.getSession();
             Transaction tx_estado = sessao.beginTransaction();
        try
         {
             Estado obj_estado = new Estado();
             obj_estado.setEst_id(getEst_id());             

             sessao.delete(obj_estado);

             tx_estado.commit();
             sessao.close();
             return "sucesso";

         }
         catch(Exception erro)
         {

             System.out.println("Problema : "+erro);
             tx_estado.rollback();
             sessao.close();
             return "erro";
         }
    }

    /**
     * @return the est_id
     */
    public Integer getEst_id() {
        return est_id;
    }

    /**
     * @param est_id the est_id to set
     */
    public void setEst_id(Integer est_id) {
        this.est_id = est_id;
    }

    /**
     * @return the est_nome
     */
    public String getEst_nome() {
        return est_nome;
    }

    /**
     * @param est_nome the est_nome to set
     */
    public void setEst_nome(String est_nome) {
        this.est_nome = est_nome;
    }

    /**
     * @return the est_sigla
     */
    public String getEst_sigla() {
        return est_sigla;
    }

    /**
     * @param est_sigla the est_sigla to set
     */
    public void setEst_sigla(String est_sigla) {
        this.est_sigla = est_sigla;
    }



  
}

Minha classe modelo (Estado.java)

package br.salesianos.modelo;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;

@Entity
public class Estado implements Serializable
{
    @Id
    @SequenceGenerator(name="generator_estado",sequenceName="sequence_estado")
    @GeneratedValue(generator="generator_estado")
    private Integer est_id;

    @Column(length=100, insertable=true,updatable=true)
    private String est_nom;

    @Column(length=2, insertable=true,updatable=true)
    private String est_sigla;

    /**
     * @return the est_id
     */
    public Integer getEst_id() {
        return est_id;
    }

    /**
     * @param est_id the est_id to set
     */
    public void setEst_id(Integer est_id) {
        this.est_id = est_id;
    }

    /**
     * @return the est_nom
     */
    public String getEst_nom() {
        return est_nom;
    }

    /**
     * @param est_nom the est_nom to set
     */
    public void setEst_nom(String est_nom) {
        this.est_nom = est_nom;
    }

    /**
     * @return the est_sigla
     */
    public String getEst_sigla() {
        return est_sigla;
    }

    /**
     * @param est_sigla the est_sigla to set
     */
    public void setEst_sigla(String est_sigla) {
        this.est_sigla = est_sigla;
    }

    //@OneToMany(mappedBy="estado")
    //private Cidade cidade;



  
}

ListaEstado

package br.salesianos.lista;

import br.salesianos.db.*;
import java.util.List;
import javax.faces.bean.ManagedBean;
import org.hibernate.Query;
import org.hibernate.Session;

@ManagedBean
public class ListaEstado {

    private String est_nom = "";
    private List suaLista;


    public ListaEstado() {
        filtrar();
    }

    public void filtrar() {
         Session sessao = CriadorDeSessao.getSession();         
         Query listagem_query = sessao.createQuery("from Estado where est_nom like '%"+getEst_nom()+"%' order by est_nom");
         setSuaLista(listagem_query.list());
         sessao.close();
        }

    /**
     * @return the est_nom
     */
    public String getEst_nom() {
        return est_nom;
    }

    /**
     * @param est_nom the est_nom to set
     */
    public void setEst_nom(String est_nom) {
        this.est_nom = est_nom;
    }

    /**
     * @return the suaLista
     */
    public List getSuaLista() {
        return suaLista;
    }

    /**
     * @param suaLista the suaLista to set
     */
    public void setSuaLista(List suaLista) {
        this.suaLista = suaLista;
    }

    

}

2 Respostas

M

De fato, porque todas as vezes que vc acessa o metodo vc esta criando uma nova configuração…
Tente assim:

public class CriadorDeSessao {

    private static final SessionFactory factory = buildSessionFactory();

    private static SessionFactory buildSessionFactory() {
        try {           
           
			AnnotationConfiguration cfg = new AnnotationConfiguration();
			cfg.addAnnotatedClass(Pessoas.class);
			cfg.addAnnotatedClass(Estado.class);
			cfg.addAnnotatedClass(Cidade.class);
			cfg.addAnnotatedClass(Inspetoria.class);
			cfg.addAnnotatedClass(Familia_Salesiana.class);
			cfg.addAnnotatedClass(Comunidade.class);
			cfg.addAnnotatedClass(Obra.class);
			cfg.addAnnotatedClass(Hist_Comunidade_Obra.class);
			cfg.addAnnotatedClass(Salesianos.class);
			cfg.addAnnotatedClass(Separacao.class);
			cfg.addAnnotatedClass(Hist_Separacao.class);
			cfg.addAnnotatedClass(Parentesco.class);
			cfg.addAnnotatedClass(Eventos.class);
			cfg.addAnnotatedClass(Hist_Eventos.class);
			cfg.addAnnotatedClass(Cursos_Especializados.class);
			cfg.addAnnotatedClass(Hist_Cursos_Especializados.class);
			cfg.addAnnotatedClass(Sacramentos_Ministerios.class);
			cfg.addAnnotatedClass(Diocese.class);
			cfg.addAnnotatedClass(Bispos.class);
			cfg.addAnnotatedClass(Paroquia.class);
			cfg.addAnnotatedClass(Hist_Diocese_Bispo.class);
			cfg.addAnnotatedClass(Formacao_Religiosa.class);
			cfg.addAnnotatedClass(Hist_Formacao_Religiosa.class);
			cfg.addAnnotatedClass(Sistemas.class);
			cfg.addAnnotatedClass(Cargo.class);
			cfg.addAnnotatedClass(Hist_Comissao.class);
			cfg.addAnnotatedClass(Profissoes.class);
			cfg.addAnnotatedClass(Hist_Profissoes.class);
			cfg.addAnnotatedClass(Tipo_Producao.class);
			cfg.addAnnotatedClass(Producao_Intelectual.class);
			cfg.addAnnotatedClass(Graduacao.class);
			cfg.addAnnotatedClass(Hist_Graduacao.class);
			cfg.addAnnotatedClass(Hist_Comunidade.class);
			cfg.addAnnotatedClass(Hist_Salesianos_Obra.class);
			cfg.addAnnotatedClass(Hist_Salesiano_Paroquia.class);
			cfg.addAnnotatedClass(Hist_Sacramentos_Ministerios.class);
			
			return cfg.buildSessionFactory();
        }
        catch (Exception e) {           
           
            e.printStackTrace(); 
        }
    }

    public static Session getSession() {
         return factory.openSession();  
    }

}
F

Nossa, era isso mesmo, resolveu 100% o meu problema, vlw

Criado 12 de abril de 2011
Ultima resposta 12 de abr. de 2011
Respostas 2
Participantes 2