-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Where to place hibernate.cfg.xml when deploying to appserver
PostPosted: Tue Jul 18, 2006 6:11 pm 
Newbie

Joined: Thu Jun 22, 2006 3:23 pm
Posts: 12
Hi All,
I have written code to access stored procedures in hibernate.I have accessed stored procedure using session.connection.prepareCall().Since i have used perpareCall() i didn't write hbm files.I have tested this application without deploying to appserver and it worked fine.Now i want to deploy to Oracle appserver.My code is as follows:

hibernate.cfg.xml

<hibernate-configuration>
<session-factory name="java:/comp/env/hibernate/SessionFactory" >
<property name="connection.datasource">java:comp/env/jdbc/OracleDS</property>
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.OrionTransactionManagerLookup</property>
<property name="current_session_context_class">jta</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.OracleDialect </property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->

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

Hibernate DAO:

public LookupList getAssetTypeGroupLookupList(){

Session session = null;
CallableStatement cs = null;
ResultSet cursor = null;

try{

session = HibernateStagingUtil.currentSession();
String queryName = "{call CAI_REFERENCE_DATA.GET_ASSET_TYPE_GROUP_LIST(?,?)}";
Transaction tx = session.beginTransaction();
cs = session.connection().prepareCall(queryName);
cs.registerOutParameter(1,OracleTypes.CURSOR);
cs.registerOutParameter(2,OracleTypes.VARCHAR);
cs.execute();
cursor = ((OracleCallableStatement)cs).getCursor(1);
String errorMessage = cs.getString(2);
LookupList lookupList = new LookupList();
ArrayList<LookupListEntry> listEntry = new ArrayList<LookupListEntry>();
while(cursor.next()){
LookupListEntry lookup = new LookupListEntry();
lookup.setKeyValue(cursor.getString(1));
lookup.setDisplayValue(cursor.getString(2));
listEntry.add(lookup);
}
tx.commit();
lookupList.setLookupList(listEntry);
return lookupList;
}

I have created a war file placing compiled classes in WEB-INF/classes.I am unable to understand where to put my hibernate.cfg.xml file.Can anyone suggest me please.This is urgent please reply.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 18, 2006 6:14 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
That depends on how you configured your seession factory. Assuming that you used the default Configuration.configure().buildSessionFactory(), then hibernate.cfg.xml should be at the root of your classpath. For a standard tomcat setup, that would be in WEB-INF/classes.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.