Foros de discusión

Custom SQL & Update statements

thumbnail
Nagendra Kumar Busam, modificado hace 12 años.

Custom SQL & Update statements

Liferay Master Mensajes: 678 Fecha de incorporación: 7/07/09 Mensajes recientes
Hi Folks,

Is there any way to use update SQL statements with custom sql

Thanks,
- Nagendra Kumar
thumbnail
Hitoshi Ozawa, modificado hace 12 años.

RE: Custom SQL & Update statements

Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientes
Are you talking about HQL or do you want to bypass Hibernate?
thumbnail
Nagendra Kumar Busam, modificado hace 12 años.

RE: Custom SQL & Update statements

Liferay Master Mensajes: 678 Fecha de incorporación: 7/07/09 Mensajes recientes
I am not talking about bypassing Hibernate.

If we see Liferay's default code we have many classes which have signature like XXXFinderImpl.java (XXX is nothing but Entity e.g., BlogsEntryFinderImpl)

Normally the custom SQL queries we invoke through that class are SELECT & COUNT kind of SQLs (we will have relevant xml files under custom-sql folder portal-impl/src)

I tried UPDATE statement using custom sql it was throwing some error (I did this around 40 days back)
thumbnail
jelmer kuperus, modificado hace 12 años.

RE: Custom SQL & Update statements

Liferay Legend Mensajes: 1191 Fecha de incorporación: 10/03/10 Mensajes recientes
I suppose you could , but it would be fairly tricky since you would manually have to manage the model listeners and cache's so you'd better have a darn good reason to attempt something like that emoticon
thumbnail
Nagendra Kumar Busam, modificado hace 12 años.

RE: Custom SQL & Update statements

Liferay Master Mensajes: 678 Fecha de incorporación: 7/07/09 Mensajes recientes
Jelmer, I have a valid reason for doing the same.

Let me explain a bit more about my use case

> I have developed a custom portlet with service.xml, i have 5 tables assume t1,t2,t3, t4 & t5.

> t1,t2,t3,t4 are normal tables & t5 is a mapping table. t1 & t2 mappings (CASE 1) , t1 & t3 mappings (CASE 3) and t1 & t4 mappings (CASE 3) will be place in t5 table

> i want to update t5 table coditionally based on UI (it may come from CASE 1, CASE 2 & CASE 3)

When i am trying to update from custom SQL it is throwing some error

BTW i am using 5.2 EE SP3

Thanks,
- Nagendra Kumar
thumbnail
Hitoshi Ozawa, modificado hace 12 años.

RE: Custom SQL & Update statements

Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientes
I think there is some misunderstanding about the concept behind Liferay as a platform.
There were some questions about using several databases within a service.xml a while back too.

This is creating a service that's tightly bound - Liferay tries to simplify the structure to
make services/entities loosely bound in the platfom layer so they are reusable across portlets.
thumbnail
Nagendra Kumar Busam, modificado hace 12 años.

RE: Custom SQL & Update statements

Liferay Master Mensajes: 678 Fecha de incorporación: 7/07/09 Mensajes recientes
Can you guide me how to proceed ahead for doing the same