Liferay Objects and Batch: model business data without writing Java

Liferay Objects and Batch: model business data without writing Java
Liferay and portals
Alejandro Muñoz del Prado

Alejandro Muñoz del Prado

Equipo técnico

November 19, 2026
5 min read
Share:

When someone needs to manage business entities (customers, contracts, orders, tickets) within a Liferay portal, the first reaction is usually to think of a Java module with its entity, its service and its persistence layer. That route still exists, but for most cases it's no longer necessary. Liferay DXP's Objects allow you to define the data model directly from the administration interface, with fields, relationships, value lists and validations, and the system generates the table, the REST API and the basic forms underneath.

The approach changes: the entity is configured rather than programmed. The technical work is still there, but it shifts. Instead of writing a domain class, you need to carefully think through the data model and, above all, how that data will be loaded and consumed from outside. That's where the auto-generated REST API and batch-type client extensions come in.

Designing the model with fields, relationships and validations

An Object is defined from Control Panel > Objects. The first step is deciding the fields: text, number, date, boolean, or a special type called picklist, which is a closed list of values (for example, the status of a ticket: open, in progress, closed). Picklists are managed separately, as catalogs reusable across multiple Objects, which avoids the classic problem of having the same list of values duplicated and out of sync across different screens.

Relationships are configured just as declaratively: one-to-many, many-to-many, with the option of making the relationship mandatory or not. Imagine a Contract Object related to a Customer Object in a one-to-many relationship: a customer can have several contracts, and each contract belongs to exactly one. Liferay automatically generates the relationship field and, if requested, a selection widget in the form.

Field-level validations (maximum length, format, numeric range) are defined within the Object's own configuration, without external rules. For more complex validations that depend on several fields at once, Liferay offers Object actions: rules that trigger on specific events (on create, on update, on delete) and that can execute conditional logic, send notifications or update other fields. This is the piece that most resembles "programming", but it's still configuration within the platform, not a separate Java module.

Consuming the Object via its auto-generated REST API

Each Object marked as exposed automatically generates a REST endpoint under /o/c/ followed by the Object's plural name. Without writing a single line of code, you can already perform a GET, POST, PUT or DELETE against that entity, with pagination, filtering and sorting included out of the box.

Bash
curl -X GET "https://sede.example.com/o/c/contratos?filter=estado eq 'ABIERTO'" \
  -H "Authorization: Basic BASE64(usuario:password)"

This is the point that changes everyday work the most: any external integration (a CRM, a mobile app, a migration script) consumes that API directly without going through intermediate layers that previously had to be maintained by hand. The trade-off is that you need to take care with permissions at the Object and field level, because what is exposed through configuration is truly exposed, and a badly set access control filter can leave more visible than it should.

Portals and applications built to last for years. And someone to maintain them.

We build and maintain portals, intranets and applications. And we rescue existing ones: we update them, tidy them up and leave them maintainable.

See portals and development

Loading initial data with a batch client extension

Defining the model and exposing it is fine, but in any real project you need to populate it with startup data: picklist catalogs, test customers, default configurations. Doing this by hand from the interface doesn't scale, and automating it with an external script that calls the REST API one record at a time isn't ideal either when dealing with large volumes or environments that need to be repeated (development, pre-production, production).

For that we use a batch-type client extension: an artifact independent of the Liferay core that runs as a job and that can read files (CSV, JSON) and load them into the Objects using the REST API itself or the internal persistence layer, depending on the case. In our internal repository sede/client-extensions/sede-objetos-batch we have solved exactly this pattern: a batch job that reads a set of data files and registers the site's business Objects in the correct order, respecting the dependencies between Objects (first Customer, then Contract, for example).

The client extension definition file is simple, something like this:

YAML
sede-objetos-batch:
  name: Sede Objetos Batch
  type: batch
  batch:
    jarPath: sede-objetos-batch.jar
    schedule:
      cron: "0 0 2 * * ?"

Order matters, just as in other data loading scenarios: if the job tries to create a Contract before the Customer it references exists, the execution fails with a referential integrity error that, if you don't look closely at the log, can seem like an Object failure when it's actually a sequencing problem in the loading script.

This same pattern (Objects plus batch client extension) is what we develop step by step in the S11 and S12 material of the Liferay DXP administration course we teach, available in curso-liferay-chms/material. There, the exercise consists of modeling a complete case (from the first field to the loading job) so that whoever follows it sees how an Object is created and also how it fits into a real deployment flow, with repeatable data across environments.

What changes when the team works this way

With Objects, technical judgment is still needed, but it's applied elsewhere: instead of discussing how an entity maps in Java, the important discussion is how the data model is structured, which validations go in the Object itself and which are better left to an action, and how the initial load is automated so it doesn't depend on someone remembering to do it by hand in each environment.

In projects where we already work with AI agents for internal tasks, this kind of declarative configuration fits well: a well-defined Object, with its REST API exposed, is a much easier surface for an agent to query or update than a database with tables and implicit relationships documented only in the code. It's not the starting point of the project, but it is a piece that makes it easier to integrate later on.

If the project is going to grow in the number of Objects and relationships, it's worth investing time at the beginning in naming the fields well and documenting the keys of shared picklists. That small amount of initial order is what prevents, months later, having three different Objects representing the same concept with different names.

Tags:liferay dxpapi restclient extensionsliferay objectsmodelado de datosbatch

Portals and applications built to last for years. And someone to maintain them.

We build and maintain portals, intranets and applications. And we rescue existing ones: we update them, tidy them up and leave them maintainable.

See portals and development