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.
|