Publication Framework with Custom Entity

Integrating Liferay Publication Framework with our Custom Entity

Publication Framework of Liferay is one of the powerful feature which helps us to track the change set, review and publish it (Refer). By default Liferay provides this feature which is already enabled with many of the out of the box modules like WebContent, Blogs, etc.. We can also use this feature with our Custom Entity by Integrating Publication Framework with our Custom module.

Step 1:

In our Custom service.xml, we need to enable change-tracking-enabled and mvcc-enabled to true for those entities which needs to be a part of Publication Framework. As for demonstration I have created sample service.xml with change set enabled as below :

<entity change-tracking-enabled="true" mvcc-enabled="true" local-service="true" name="Book" remote-service="false" uuid="true">
        <column name="bookId" primary="true" type="long" />
        <column name="companyId" type="long" />
        <column name="userId" type="long" />
        <column name="userName" type="String" />
        <column name="createDate" type="Date" />
        <column name="modifiedDate" type="Date" />
        <column name="title" type="String" />
        <column name="publication" type="String" />

Now you can build service and write your *Impl as usual, with all the add, update, etc.. methods. Liferay will track all the updates on this Entity in its Change Tracker. 

Step 2: 

Create TableReferenceDefinition Implementation, we need to create this implementation for Publication Framework to identify our custom tables.

@Component(service = TableReferenceDefinition.class)
public class BookTableReferenceDefinition implements TableReferenceDefinition<BookTable> {

    public void defineChildTableReferences(ChildTableReferenceInfoBuilder<BookTable> childTableReferenceInfoBuilder) {

    public void defineParentTableReferences(
            ParentTableReferenceInfoBuilder<BookTable> parentTableReferenceInfoBuilder) {

    public BasePersistence<?> getBasePersistence() {
        return _bookPersistence;

    public BookTable getTable() {
        return BookTable.INSTANCE;

    private BookPersistence _bookPersistence;


Step 3:

Create CTDisplayRenderer for the Book Entity, as this is used by Publication Framework to display Book in Review Change Screen.

@Component(service = CTDisplayRenderer.class)
public class BookCTDisplayRenderer extends BaseCTDisplayRenderer<Book> {

    public Class<Book> getModelClass() {
        return Book.class;

    public String getTitle(Locale locale, Book book) throws PortalException {
        return book.getTitle();

    public String getContent(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
            Locale locale, Book book) throws Exception {
        return book.getTitle() + StringPool.DOUBLE_DASH + book.getPublication();



Done!! Now you can create a Publication (Refer) and add data to the Book entity. In the Review changes screen of Publication you can see the records which were added.




Note : Above example is done on Liferay 7.4