Hi,
Wondering if anyone can point out what I'm doing wrong. everything I call sessionFactory.openSession() I get a "Hibernate lazy instantiation problem".
I'm using JBoss 3.0.3, hibernate 2.1.2, oracle 8. Hiberante is deployed as a sar.
Here is a snippet from my jboss-service.xml
Code:
<mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory, name=HibernateFactory">
<depends>jboss.jca:service=RARDeployer</depends>
<depends>jboss.jca:service=LocalTxCM,name=NCPDS</depends>
<!-- Make it deploy ONLY after DataSource had been started -->
<attribute name="MapResources">/NetEngines/WEB-INF/reference.hbm.xml</attribute>
<attribute name="JndiName">java:/hibernate/HibernateFactory</attribute>
<attribute name="Datasource">java:/NCPDS</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.OracleDialect</attribute>
<attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
<attribute name="UseOuterJoin">true</attribute>
<attribute name="ShowSql">true</attribute>
<attribute name="UserTransactionName">UserTransaction</attribute>
</mbean>
And this is my single mapping file I'm testing with:
Code:
<class name="com.netengines.application.model.referees.Reference" table="REFERENCE">
<id name="id" type="string" unsaved-value="null" column="PK_ID" length="32" >
<generator class="uuid.hex"/>
</id>
<property name="referenceDate" column="REF_DATE" type="date"/>
<property name="quality" column="QUALITY" type="string" length="12" not-null="true"/>
<property name="solutionId" column="SOLUTION_ID" type="integer" length="22" not-null="true"/>
<property name="referenceFileName" column="REFERENCE_FILE_NAME" type="string" length="200" not-null="true"/>
<property name="refereeTitle" column="REFEREE_TITLE" length="8" type="string" not-null="true"/>
<property name="refereeFirstName" column="REFEREE_FIRST_NAME" length="16" type="string" not-null="true"/>
<property name="refereeSurname" column="REFEREE_SURNAME" length="16" type="string" not-null="true"/>
<property name="refereeEmail" column="REFEREE_EMAIL" length="30" type="string" not-null="true"/>
<property name="refereeTelephoneNumber" column="REFEREE_TELEPHONE_NUMBER" length="12" type="string" not-null="true"/>
</class>
The code is automatically generated for the objects using the code generator.
Hibernate gets deployed without any problems...
And this is my simple test in jboss to make see if it all works:
Code:
Context ctx = new InitialContext();
sessionFactory = (SessionFactory) ctx.lookup("java:/hibernate/HibernateFactory");
Reference reference = new Reference();
reference.setQuality("Good");
reference.setReferenceDate(new Date());
reference.setReferenceFileName("/some/file/name/dot.txt");
reference.setSolutionId(115);
reference.setRefereeEmail("test@test.com");
reference.setRefereeFirstName("Moo");
reference.setRefereeTitle("Dr");
reference.setRefereeSurname("Moo!");
reference.setRefereeTelephoneNumber("+44 0000 000 000");
Session session = sessionFactory.openSession();
session.saveOrUpdate(reference);
However on exections I get the following to the logs:
Code:
65 INFO [HibernateServiceMBean] starting service at JNDI name: java:/hibernate/HibernateFactory
65 INFO [HibernateServiceMBean] service properties: {hibernate.session_factory_name=java:/hibernate/HibernateFactory, hibern
ction.manager_lookup_class=net.sf.hibernate.transaction.JBossTransactionManagerLookup, hibernate.dialect=net.sf.hibernate.dia
eDialect, hibernate.show_sql=true, hibernate.use_outer_join=false, hibernate.transaction.factory_class=net.sf.hibernate.trans
TransactionFactory, hibernate.connection.datasource=java:/NCPDS, jta.UserTransaction=UserTransaction}
80 INFO [Configuration] Mapping resource: /NetEngines/WEB-INF/reference.hbm.xml
11 INFO [STDOUT] DEBUG [SocketListener-1] [ReferenceTest.populate:59]: There was an error: net.sf.hibernate.LazyInitializati
n: Hibernate lazy instantiation problem
Any ideas of what I'm doing wrong guys??
Thanks in advance
Jon