Hi!

Will tapestry-jpa module give me one jpa session per request ?
(Or entityManger is perhaps the right word here)

I am currenlty  using JPA but not tapestry-jpa.

My DAO methods (+some bigger service methods) are JPA transaction annotated.

The problem I am phasing now is that when I make some optimizations by
changing
references in my entity beans to lazy I get lazy init exceptions in other
places.
E.g. when page template tries to display some entity properties that are
lazy loaded.

I guess what I want is the OpenSessionInView pattern ... since then the
fetching (when needed)
would be solved automatically.

My current setup is Spring, TapestrySpringFilter, JPA (annoation based),
Spring Transactions Hibernate.

In my DAO implementation classes I have

    @PersistenceContext
    protected EntityManager entityManager;

When playing around with tapestry-jpa I also encountered the JPA Maven
dependence problem ...

I guess for now I will make som dummy code to fetch lazy loaded refs when
needed. But that can get ugly
in the long run.

How do you folks solve these problems?

I.e. OpenSessionInView or not !? If not how can I optimze by lazy loading
but avoid a lot of dummy code to load data when needed.

Thanks in advance,
Gunnar Eketrapp

My current Spring persistence setup ....

<bean
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"
/>

<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"
value="${hibernate.connection.driver_class}" />
<property name="url" value="${hibernate.connection.url}" />
<property name="username" value="${hibernate.connection.username}" />
<property name="password" value="${hibernate.connection.password}" />
</bean>

<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="utskicketPersistence" />
<property name="dataSource" ref="dataSource" />
<property name="jpaDialect">
<bean class="${jpa.dialect}" />
</property>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.${jpa.vendor.adapter}">
<property name="showSql" value="${hibernate.show_sql}" />
<property name="databasePlatform" value="${hibernate.dialect}" />
<property name="generateDdl" value="false" />
</bean>
</property>
</bean>

<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
 <tx:annotation-driven transaction-manager="transactionManager" />

Reply via email to