Skip to content

Liferay – Hibernate

June 24, 2008

On using transaction Manager provided by Spring


Unable to resolve the issue of Hibernate session not bound to thread in Liferay when creating a new persistence class extending basePersistence. Guess I would need to read up on spring hibernate configuration for tx mgmt.

Until then would use PortalJNDIUtil for the DataSource.

Really I thought I could solve the Hibernate issue – but its been almost a day now and no solution found,. Need to move on – would come back on this later:

<!--  my service class - Implementation class --><!--  my transaction wrapper over service implementation -->
    <!-- bean id="" class="" lazy-init="true"/>
    <bean id="" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" lazy-init="true">
<property name="transactionManager">
            <ref bean="liferayTransactionManager" />
<property name="target">
            <ref bean="" />
<property name="transactionAttributes">
<prop key="*">PROPAGATION_SUPPORTS,readOnly</prop>
    </bean> -->

    <!-- bean id="" class="" lazy-init="true"/>
<property name="dataSource">
            <ref bean="liferayDataSource" />
<property name="sessionFactory">
            <ref bean="liferaySessionFactory" />

    </bean> -->

The configuration of Service classes and Persistence classes in portal-spring.xml is as follows:
LSLocal.iLS.mpl – nothing
LSLocal.Tx – TxMgr,Target (LSLocal.impl),TxAttr
LSFactory – svc – LSLocal.Tx
LS.Tx – LS.impl
LSFactory – svc LS.Tx
LSPersis.Tx – Target – LSPersis.impl

To show the tags in the journal content portlet:(Code from liferay forum)


#set ($tagsService = $serviceLocator.findService(“com.liferay.portlet.tags.service.TagsAssetLocalService”))
#set ($journalArticleResourceService = $serviceLocator.findService(“com.liferay.portlet.journal.service.JournalArticleResourceLocalService”))

#set ($longGroupId = $getterUtil.getLong($groupId))
#set ($articleResourcePK = $journalArticleResourceService.getArticleResourcePrimKey($longGroupId, $
#set ($tagsAsset = $tagsService.getAsset(“com.liferay.portlet.journal.model.JournalArticle”, $articleResourcePK))
#set ($tagsEntries = $tagsAsset.getEntries())

#foreach( $entry in $tagsEntries )
#set ($tag = $entry.getName())
#if($velocityCount!=1), #end

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: