> How about giving us a hint what was wrong with the existing 
> implementation. No-one else has ever complained.

Sure, sorry.
The code generated by Middlegen is doing this:

 net.sf.hibernate.SessionFactory factory =
  (net.sf.hibernate.SessionFactory)ctx.lookup("java:comp/env/AirlineHibernateFactory");
 net.sf.hibernate.Session session = factory.openSession();

But that just results in a null being returned and the log file messages:

2004-04-02 15:55:43 Apr 2, 2004 3:55:43 PM 
net.sf.hibernate.impl.SessionFactoryObjectFactory getInstance
WARNING: Not found: Shareable

Poking around, I noticed that SessionFactoryObjectFactory never
actually creates a SessionFactory. When getObjectInstance() is
called, that's what Tomcat expects - for a SessionFactory instance
to be created.

The only place a SessionFactoryObjectFactory seems to be deal with
an actual SessionFactory instance is when SessionFactoryImpl calls
SessionFactoryObjectFactory.addInstance(). But when Tomcat calls
getObjectInstance() there is no SessionFactoryImpl around. Tomcat
expects SessionFactoryObjectFactory to create what it needs to.

Maybe nobody else has complained since they've bitten the bullet
and are creating and configuring hibernate directly.
I have not found on the Hibernate website or this list's archives,
or anywhere, a solution using Resource/ResourceParms in one's
Context element for Tomcat. If I am missing something, please tell me.

My BasicSessionFactoryObjectFactory makes Tomcat work without
changing the simple Middlegen style of code, or having to manage
a SessionFactory in your applicaton context (to e.g. use the singleton
HibernateSession), and without the problems of JndiSessionFactoryImpl,
both noted on:
http://www.hibernate.org/114.html

Perhaps JndiSessionFactoryImpl could have been modified to work, but I
chose to work with SessionFactoryObjectFactory.

Make sense? What am I missing?

John Allison
[EMAIL PROTECTED]


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to