Ok, I have created 2 cfg.xml files, the first is named xops_hibernate.cfg.xml the next is nations_hibernate.cfg.xml the code in each is as follows:
Code:
<hibernate-configuration>
<session-factory name="java:hibernate/Nations">
<!-- properties -->
<property name="connection.username">user</property>
<property name="connection.url">jdbc:microsoft:sqlserver://sqldev:1433;DatabaseName=nations_robin</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="connection.password">pass</property>
<property name="connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<!-- mapping files -->
<mapping resource="com/nationsholding/xOps/common/model/OrderNumber.hbm.xml"/>
</session-factory>
</hibernate-configuration>
and
Code:
<hibernate-configuration>
<session-factory name="java:hibernate/xOps">
<!-- properties -->
<property name="connection.username">user</property>
<property name="connection.url">jdbc:microsoft:sqlserver://sqldev:1433;DatabaseName=xOps</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="connection.password">pass</property>
<property name="connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<!-- mapping files -->
<mapping resource="com/nationsholding/xOps/common/model/ApplicationProducts.hbm.xml"/>
<mapping resource="com/nationsholding/xOps/common/model/CustomerOrder.hbm.xml"/>
<mapping resource="com/nationsholding/xOps/common/model/EntityType.hbm.xml"/>
<mapping resource="com/nationsholding/xOps/common/model/OrderActivty.hbm.xml"/>
<mapping resource="com/nationsholding/xOps/common/model/SubProducts.hbm.xml"/>
<mapping resource="com/nationsholding/xOps/common/model/XopsCustomer.hbm.xml"/>
</session-factory>
</hibernate-configuration>
I have a HibernateUtil class that gets the session factory:
Code:
public class HibernateUtil {
private static final Log LOG = LogFactory.getLog(HibernateUtil.class);
private static final ThreadLocal threadSession = new ThreadLocal();
private static final ThreadLocal threadTransaction = new ThreadLocal();
static{
try{
new Configuration().configure("xops_hibernate.cfg.xml").buildSessionFactory();
}catch (Throwable ex){
LOG.error(ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory(){
SessionFactory sessions = null;
try{
Context ctx = new InitialContext();
String jndiName = "hibernate/xOps";
sessions = (SessionFactory)ctx.lookup(jndiName);
}catch(NamingException ne){
LOG.error(ne);
}
return sessions;
}
......
When I try to get a session factory I get this error message.
Hibernate 3.0rc1
- hibernate.properties not found
- using CGLIB reflection optimizer
- using JDK 1.4 java.sql.Timestamp handling
- configuring from resource: /hibernate.cfg.xml
- Configuration resource: /hibernate.cfg.xml
- /hibernate.cfg.xml not found
- org.hibernate.HibernateException: /hibernate.cfg.xml not found
I dont understand why I am getting this. In my Util class I have told hibernate to use a different cfg.xml. Can someone please help me?
Thanks
Tim