Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Florencia Gadea
Caching an entity on server startup
November 29, 2012 7:40 AM
Answer

Florencia Gadea

Rank: Regular Member

Posts: 146

Join Date: March 27, 2012

Recent Posts

Hi Everyone!

I'm not sure how Liferay cache system works. I'm developing a portlet, and I created an entity. I would like this entity to be cached on server startup.

How can I do this?

I'm using Liferay 6.1.1 GA 2.

Thanks,

Flor.
David H Nebinger
RE: Caching an entity on server startup
November 29, 2012 8:40 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11787

Join Date: September 1, 2006

Recent Posts

A service builder entity?

If so, you could override XxxLocalServiceImpl's afterPropertiesSet() method to fetch the entity after the object's been created. Be sure to call the superclass method, though...
Florencia Gadea
RE: Caching an entity on server startup
December 3, 2012 4:54 AM
Answer

Florencia Gadea

Rank: Regular Member

Posts: 146

Join Date: March 27, 2012

Recent Posts

Hi David,

Thanks for your answer.

Yes, it is a service builder entitiy.
So you think that something like this would work?

 1
 2@Override
 3public void afterPropertiesSet() {
 4    PersistedModelLocalServiceRegistryUtil.register("com.rcs.service.model.MessageSource", messageSourceLocalService);
 5    try {
 6        messageSourcePersistence.findAll();
 7    } catch(SystemException e) {            
 8    }       
 9}


Regards,

Flor.