0 Replies Latest reply on Mar 20, 2013 8:41 AM by Pablo Grisafi

    How do I configure a custom session factory for hibernate in jboss5?

    Pablo Grisafi Newbie

      I work in a very conservative compay. We are finally moving from Jboss4 to Jboss5 (Yeah!)

      The company uses the same dabatase but different schemas for UAT and DEV servers.

      In order to handle that, someone developed a custom session factory.

      In the old jboss4 it was easy to use, within the har file there was a META-INF\jboss-service.xml


      <mbean code="com.twg.twglib.jmx.Hibernate" name="jboss.har:service=DRSHibernate">
      <attribute name="DatasourceName">java:jdbc/drs</attribute>
      <attribute name="SessionFactoryName">java:/hibernate/WlscDrsSessionFactory</attribute>
      <!-- etc -->



      Note the code="com.twg.twglib.jmx.Hibernate", instead of the typical code="org.jboss.hibernate.jmx.Hibernate"

      This class com.twg.twglib.jmx.Hibernate is a copy of org.jboss.hibernate.jmx.Hibernate, but uses our own custom session factory

      In the new configuration style I need to write a META-INF\service-hibernate.xml


      <hibernate-configuration xmlns="urn:jboss:hibernate-deployer:1.0">
      <session-factory name="java:/hibernate/Deals/SessionFactory"
      <property name="datasourceName">java:/hibernate/WlscDrsSessionFactory</property>
      <!-- etc -->


      And I found no way to specify a custom class...Does anyone have any ideas?

      If there is no way to do that, can I use jboss properties in my HAR inside hbm.xml files?

      Something like


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

      <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"



          <class name="............." table="TABLE_NAME" schema="${jboss-prop-table-schema-name}">


      That way I can get rid of our custom session factory, and use properties to change the environment

      Please help me move forward a little bit!


      Thanks in advance