What error are you getting?
-----Original Message-----
From: Jeffrey Schneller [mailto:[email protected]]
Sent: Wednesday, March 31, 2010 4:47 PM
To: [email protected]
Subject: Hibernate - OSIV
I think I have the OSIV filter setup correctly but I can't access any lazy
loaded properties of my objects. I am not even between requests when this
is happening. Does anyone have any ideas? I can't seem to figure this out.
I have looked at OSIV in Spring and OSIV in Wicket. I can't seem to find
any examples that will help me to determine the problem. I have included
all the code and xml configuration that I believe is relevant. Any help
would be appreciated. Also a clean example of how to setup Spring +
Hibernate OSIV in the wiki would be a big help.
Here is what I have [a very simplified example]:
@SpringBean
private IProductDao dao;
// the following two lines are in the constructor for the page
Product product = dao.findBySku(sku);
List<Option> options = product.getOptions(); // this is lazy loaded -
Yes, I know in this example I could just eager fetch it but other times I
don't need the options
// a generic dao
public abstract class GenericDao<T extends DomainObject> extends
HibernateDaoSupport
// the product dao
public class ProductDao extends GenericDao<Product> implements IProductDao {
<!-web app à
<display-name>wicket-spring-hibernate</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:resources/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</liste
ner-class>
</listener>
<filter>
<filter-name>opensessioninview</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFi
lter</filter-class>
</filter>
<filter>
<filter-name>wicket-spring-hibernate</filter-name>
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
<init-param>
<param-name>applicationFactoryClassName</param-name>
<param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-val
ue>
</init-param>
<init-param>
<param-name>applicationClassName</param-name>
<param-value>com.mycompany.WicketApplication</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>opensessioninview</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>wicket-spring-hibernate</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-application context [key pieces] à
<bean id="sessionFactory"
class="com.mycompany.hibernate.SessionFactory">
<property name="hibernateProperties">
<props>
<prop
key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<!-- connection pooling -->
<prop
key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
<prop
key="hibernate.connection.provider_class">org.hibernate.connection.C3P0Conne
ctionProvider</prop>
<prop key="hibernate.c3p0.initialPoolSize">1</prop>
<prop
key="hibernate.c3p0.idleConnectionTestPeriod">300</prop>
<prop key="hibernate.c3p0.acquire_increment">1</prop>
<prop key="hibernate.c3p0.min_size">5</prop>
<prop key="hibernate.c3p0.max_size">20</prop>
<prop key="hibernate.c3p0.timeout">1800</prop>
<prop key="hibernate.c3p0.max_statements">50</prop>
</props>
</property>
<property name="packagesToScan">
<list>
<value>com.mycompany.entities</value>
</list>
</property>
</bean>
<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<tx:annotation-driven transaction-manager="txManager" />
<bean id="ProductDao" class="com.mycompany.hibernate.dao.ProductDao"
scope="singleton">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
_______________________________________
Jeffrey A. Schneller
Envisa
End-to-End E-Commerce for the Multi-Channel Merchant
281 Pleasant Street
Framingham, MA 01701
P: (508) 405-1220 x115
C: (508) 954-8044
F: (508) 405-1219
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]