Skip to content

Liferay – Hibernate

June 24, 2008

On using transaction Manager provided by Spring

http://nerdnotes.wordpress.com/2007/03/30/basic-transactions-in-spring-using-transactionproxyfactorybean/

ServiceBuilder

http://wiki.liferay.com/index.php/Services%2C_entities%2C_and_ServiceBuilder

http://www.javalobby.org/articles/thread-safe/index.jsp

http://www.sleberknight.com/blog/sleberkn/

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="com.liferay.co.AppAuthService.impl" class="com.liferay.co.AppAuthServiceImpl" lazy-init="true"/>
    <bean id="com.liferay.co.AppAuthService.transaction" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" lazy-init="true">
<property name="transactionManager">
            <ref bean="liferayTransactionManager" />
        </property>
<property name="target">
            <ref bean="com.liferay.co.AppAuthService.impl" />
        </property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_SUPPORTS,readOnly</prop>
            </props>
        </property>
    </bean> -->

    <!-- bean id="com.liferay.co.AuthJsonBuilder.impl" class="com.liferay.co.AppAuthServiceImpl" lazy-init="true"/>
<property name="dataSource">
            <ref bean="liferayDataSource" />
        </property>
<property name="sessionFactory">
            <ref bean="liferaySessionFactory" />
        </property>

    </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.impl
LS.Tx – LS.impl
LSFactory – svc LS.Tx
================================
LSPersis.Impl
LSPersis.Tx – Target – LSPersis.impl
LSUtil
================================

http://www.liferay.com/web/guest/products/portal/architecture/spring_hibernate
http://www.javalobby.org/articles/thread-safe/index.jsp
http://www.ibm.com/developerworks/web/library/wa-spring2/
http://www.sleberknight.com/blog/sleberkn/

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, $reserved-article-id.data))
#set ($tagsAsset = $tagsService.getAsset(“com.liferay.portlet.journal.model.JournalArticle”, $articleResourcePK))
#set ($tagsEntries = $tagsAsset.getEntries())

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

Advertisements
No comments yet

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: