<session-factory name="foo:/hibernate/SessionFactory">
<property name="dialect">net.sf.hibernate.dialect.HSQLDialect</property>
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.username">ADMIN</property>
<property name="connection.password">ADMIN</property>
<property name="connection.url">jdbc:hsqldb:build/webapps/root/WEB-INF/db/database</property>
<property name="connection.pool.size">1</property>
<property name="statement_cache.size">25</property>
<property name="jdbc.fetch_size">50</property>
<property name="jdbc.batch_size">30</property>
<property name="show_sql">true</property>
<property
name="transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
<property name="dbcp.minIdle">1</property>
<property name="cache.use_query_cache">true</property>
</session-factory>
我透過JNDI沒辦法訪問到
Context ctx = new InitialContext();
SessionFactory sf = (SessionFactory) ctx.lookup("foo:/hibernate/SessionFactory");
不知道是為什麼?
我看的一個例子上是這樣子的。我按照例子寫的。但是不行.我用的是jetty
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration
-2.0.dtd">
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory name="foo:/hibernate/SessionFactory">
<!-- properties -->
<property
name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="connection.username">brian</property>
<property name="connection.password">arses</property>
<property name="connection.url">jdbc:mysql://localhost:3306/
mydata</property>
<property
name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="show_sql">true</property>
<property name="use_outer_join">true</property>
<property
name="transaction.factory_class">net.sf.hibernate.transaction.JDBCTra
nsactionFactory</property>
<property name="dbcp.minIdle">1</property>
<property name="cache.use_query_cache">true</property>
<!-- mapping files -->
<mapping resource="com/sparrow/om/Arse.hbm.xml"/>
</session-factory>
</hibernate-configuration>
and in struts config..
<plug-in className="edu.arbor.util.plugin.HibernatePlugIn">
<set-property property="storedInServletContext" value="true"/>
</plug-in>
..
in struts action
..
Context ctx = new InitialContext();
SessionFactory sf = (SessionFactory) ctx.lookup("foo:/hibernate/
SessionFactory");
hibSession = sf.openSession();
<p class="indent">
|