0

Our application has very large data and we want to perform our business logic (aggregations) in the Database Layer (Stored Procedures).

Liferay prefers to have business logic in Business Layer (having mutli-layered Architecture).

What is the impact if we want to use Stored Procedures for Business Logic?

As Liferay also uses Hibernate, Is there a way to by-pass hibernate in this case if it doesn't add much value in this case?

Prakash K
  • 11,669
  • 6
  • 51
  • 109
dsr301
  • 759
  • 3
  • 7
  • 21

2 Answers2

1

The fact that Liferay does its business logic in application code doesn't mean that you must do the same, the architecture of your application is completely up to you.

(This presumes that your application data doesn't reference Liferay's data)

František Hartman
  • 14,436
  • 2
  • 40
  • 60
1

There are reasons why Liferay does its business logic at application code level (high level):

  1. This way the portal becomes database agnostic, and hence can be deployed without considering much about the underlying database.
  2. Not all databases support Stored Procedures. So to support multiple databases the code can't be in Stored Procedure.
  3. Portals are mostly content driven and not so much data intensive.

There may be other reasons or there might be some other philosophy they may be following, but this is what I can think of right now.

So now the question whether you can use it or not?

As frant.hartm says, it is completely up to you. It depends upon your requirement and how you plan to design, maintain and enhance your architecture.

Also as a word of caution: It is recommended not to use Liferay's database tables directly from Stored procedures as Liferay may change the Database architecture for newer versions. So it might complicate your upgrade procedure.

I feel this question is not so liferay related, hence here are some links that might help you decide:

  1. Arguments for/against Business Logic in stored procedures. The first few answers are good pointers in this direction.
  2. Whether to put the business logic in Stored Procedure or Not?
  3. Code generators vs. ORMs vs. Stored Procedures.

Is there a way to by pass hibernate in this case if it doesn't add much value in this case.

If it does not add value then yes you can use JDBC for your own custom portlet by-passing hibernate. There is nothing special to configure for using JDBC, it is the same good old thing :-).

Hope this leads you in a positive direction.

Community
  • 1
  • 1
Prakash K
  • 11,669
  • 6
  • 51
  • 109