1 Reply Latest reply on Jun 7, 2008 11:27 AM by Peter Pei Guo

    DataSource with JBOSS

    leandro godoy Apprentice

      I'm using jboss 4.2 to hibernate as I make my system to integrate with the jboss in the case of transactions'm using hibernate, as a dataSource set for the jboss with hibernate and what. Jar in the classpath need for this?
      I do hibernate configuraçaõ follows:
      hibernate.cfg.xml

      
      <?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 name="">
       <property name="connection.url">jdbc:postgresql://localhost:5432/Tcc</property>
       <property name="connection.username">postgres</property>
       <property name="connection.password">512815</property>
       <property name="connection.driver_class">org.postgresql.Driver</property>
       <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
       <property name="hibernate.jdbc.batch_size">20</property>
       <!-- <property name="hibernate.cache.use_query_cache">true</property>
       Exibe no console o SQL gerado pelo hibernate-->
       <property name="show_sql">true</property>
       <mapping class="com.Lgweb.Tcc.Model.Cidade"/>
       <mapping class="com.Lgweb.Tcc.Model.Cliente"/>
       <mapping class="com.Lgweb.Tcc.Model.Condicaopagamento"/>
       <mapping class="com.Lgweb.Tcc.Model.Contaspagar"/>
       <mapping class="com.Lgweb.Tcc.Model.Contasreceber"/>
       <mapping class="com.Lgweb.Tcc.Model.DiascondicaoDias"/>
       <mapping class="com.Lgweb.Tcc.Model.Dias"/>
       <mapping class="com.Lgweb.Tcc.Model.Fornecedor"/>
       <mapping class="com.Lgweb.Tcc.Model.Numeracao"/>
       <mapping class="com.Lgweb.Tcc.Model.Pedido"/>
       <mapping class="com.Lgweb.Tcc.Model.Pedidocompra"/>
       <mapping class="com.Lgweb.Tcc.Model.Itenscompra"/>
       <mapping class="com.Lgweb.Tcc.Model.Itensvenda"/>
       <mapping class="com.Lgweb.Tcc.Model.Perfil"/>
       <mapping class="com.Lgweb.Tcc.Model.Pessoafisica"/>
       <mapping class="com.Lgweb.Tcc.Model.Pessoajuridica"/>
       <mapping class="com.Lgweb.Tcc.Model.Produto"/>
       <mapping class="com.Lgweb.Tcc.Model.Ramoatividade"/>
       <mapping class="com.Lgweb.Tcc.Model.Estado"/>
       <mapping class="com.Lgweb.Tcc.Model.Usuario"/>
       <mapping class="com.Lgweb.Tcc.Model.Formapagamento"/>
       <mapping class="com.Lgweb.Tcc.Model.ProdutoNumeracao"/>
       </session-factory>
      </hibernate-configuration>
      
      
      


      hibernateUtil:
      package com.Lgweb.Tcc.Util;
      
      import org.hibernate.Session;
      import org.hibernate.SessionFactory;
      import org.hibernate.cfg.AnnotationConfiguration;
      
      public class HibernateUtil {
       private static final SessionFactory sessionFactory;
       private static final ThreadLocal<Session> threadLocal = new ThreadLocal<Session>();
       static{
       try{
       sessionFactory = new AnnotationConfiguration().configure("hibernate.cfg.xml").buildSessionFactory();
      
       } catch(Throwable t){
       throw new ExceptionInInitializerError(t);
      
       }
       }
      
       public static Session getInstance(){
       Session session = threadLocal.get();
       session = sessionFactory.openSession();
       threadLocal.set(session);
       return session;
       }
      
       public static SessionFactory getSessionFactory() {
       return sessionFactory;
       }
      
       public static ThreadLocal<Session> getThreadLocal() {
       return threadLocal;
       }
      
       }
      
      
      
      
      
      
      
      


      What must change in my setup to work in a managed environment, where the JBOSS?
      you hugs.