Community

Binding a SessionFactory

reply from Lulseged Zerfu in JNDI and Naming - View the full discussion

Hi

 

I have added session factory name. It needs hibernate.jndi.class in hibernate.properties.

 

<?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="java:comp/env/jdbc/resource-list">

 

        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.password">ddbuser</property>
        <property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/ddb</property>
        <property name="hibernate.connection.username">ddbuser</property>
        <property name="hibernate.default_schema">ddb</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>

 

        <property name="hibernate.format_sql">true</property>
        <property name="hibernate.show_sql">true</property>
        <property name="current_session_context_class">thread</property>
        <property name="hibernate.max_fetch_depth">3</property>
        <property name="hibernate.generate_statistics">true</property>
        <property name="hibernate.connection.pool_size">10</property>

 


        <mapping resource="hbm/ResourceListUser.hbm.xml" />
        <mapping resource="hbm/ResourceList.hbm.xml" />
        <mapping resource="hbm/ResourceListType.hbm.xml" />
        <mapping resource="hbm/ResourceListEntry.hbm.xml" />
        <mapping resource="hbm/ResourceListEntryReference.hbm.xml" />
        <mapping resource="hbm/ResourceListExternal.hbm.xml" />
        <mapping resource="hbm/Subscription.hbm.xml" />

 

    </session-factory>
</hibernate-configuration>

 

#hibernate.properties

 

hibernate.generate_statistics=true
hibernate.cache.use_query_cache=true
hibernate.cache.use_structured_entries=true
hibernate.cache.provider_class=net.sf.ehcache.hibernate.SingletonEhCacheProvider
hibernate.use_sql_comments=true
hibernate.cache.use_second_level_cache=true

 

hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=1800
hibernate.c3p0.max_statements=50

 

hibernate.jndi.class=com.ericsson.ims.pag.xdms.resource.list.session.SessionFactoryContext

 

 

package com.ericsson.ims.pag.xdms.resource.list.session;

 

import java.util.Hashtable;

 

import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.spi.InitialContextFactory;

 

public class SessionFactoryContext implements InitialContextFactory
{

 

    public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException
    {
        return new InitialContext(environment);
    }
}

 

 

Lulseged

Reply to this message by going to Community

Start a new discussion in JNDI and Naming at Community