Hi Gordon,
If you've followd the SAR example and deployed the SAR within JBoss, then there are a couple of things you'll want to change w.r.t. how you use Hibernate from within your session bean method call.
1. You don't have to manually create the configuration and session factory. If the SAR is done properly, this all gets taken care of.
2. If I recall, the SAR example has an attribute element that defines a JNDI name for the hibernate session factory. Lets say you used an attribute value of "java:/hibernate/HibernateFactory". You can get the session factory from JNDI like this (keep in mind that this isn't production quality or anything...):
Code:
try {
InitialContext ctx = new InitialContext();
SessionFactory factory = (SessionFactory)ctx.lookup("java:/hibernate/HibernateFactory");
}
catch (Exception ex) {
//do something...
}
Once you've got the factory, you can create sessions and do the rest of your Hibernate work in the normal way.
Good luck, Gordon.