Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Ishan Sahore
Dynamic Query on Expando tables
October 17, 2012 1:49 AM
Answer

Ishan Sahore

Rank: Junior Member

Posts: 56

Join Date: April 25, 2012

Recent Posts

Hi all,

I am trying to use dynamic query on expandotable.
The following code I wrote:
1DynamicQuery query = DynamicQueryFactoryUtil.forClass(ExpandoTable.class)
2                    .add(PropertyFactoryUtil.forName("tableId").eq(tableId));
3List<ExpandoTable> li=ExpandoTableLocalServiceUtil.dynamicQuery(query);


This is giving me an exception:
1Unable find model com.liferay.portlet.expando.model.impl.ExpandoTableImpl
2java.lang.ClassNotFoundException: com.liferay.portlet.expando.model.impl.ExpandoTableImpl


Cna anyone tell me where am I missing something.

Thanks,
Ishan
Siby Mathew
RE: Dynamic Query on Expando tables
October 17, 2012 2:06 AM
Answer

Siby Mathew

Rank: Expert

Posts: 267

Join Date: March 4, 2011

Recent Posts

Hi Ishan,
You dont need to use Dynamic query for this. You can use :

1ExpandoTable expandoTable = ExpandoTableLocalServiceUtil.getExpandoTable(tableId);


Thanks,
Siby Mathew
Ishan Sahore
RE: Dynamic Query on Expando tables
October 17, 2012 2:21 AM
Answer

Ishan Sahore

Rank: Junior Member

Posts: 56

Join Date: April 25, 2012

Recent Posts

Hi Siby,

I have just quoted a simple illustration of how I am using dynamic query.
I need to use dynamic queries to fetch various types of data.
The statement
1ExpandoTable expandoTable = ExpandoTableLocalServiceUtil.getExpandoTable(tableId);

searches by the primary key (tableId), I need to search by different fields.
Any help ?
Siby Mathew
RE: Dynamic Query on Expando tables
October 17, 2012 2:25 AM
Answer

Siby Mathew

Rank: Expert

Posts: 267

Join Date: March 4, 2011

Recent Posts

Hi Ishan,
There are also other methods like :
1
2ExpandoTableLocalServiceUtil.getTables(companyId,className);
3ExpandoTableLocalServiceUtil.getTables(companyId,classNameId);


This will return you a list of expando tables for that class.
Will that be suitable for you ?

Thanks,
Siby
Mayur Patel
RE: Dynamic Query on Expando tables
October 17, 2012 3:47 AM
Answer

Mayur Patel

Rank: Expert

Posts: 350

Join Date: November 17, 2010

Recent Posts

Hey Ishan,

Can you check this,

1DynamicQuery query = DynamicQueryFactoryUtil.forClass(ExpandoTable.class,PortletClassloaderUtil.getClassLoader())
2                    .add(PropertyFactoryUtil.forName("tableId").eq(tableId));
3List<ExpandoTable> li=ExpandoTableLocalServiceUtil.dynamicQuery(query);


Thanks.
Ishan Sahore
RE: Dynamic Query on Expando tables
October 17, 2012 3:56 AM
Answer

Ishan Sahore

Rank: Junior Member

Posts: 56

Join Date: April 25, 2012

Recent Posts

Mayur Patel:
Hey Ishan,

Can you check this,

1DynamicQuery query = DynamicQueryFactoryUtil.forClass(ExpandoTable.class,PortletClassloaderUtil.getClassLoader())
2                    .add(PropertyFactoryUtil.forName("tableId").eq(tableId));
3List<ExpandoTable> li=ExpandoTableLocalServiceUtil.dynamicQuery(query);


Thanks.



Thanks Mayur,
You hit the bulls eye.
Anyways, I got it resolved moments earlier.
Rewati Raman
RE: Dynamic Query on Expando tables
October 17, 2012 4:07 AM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

Thanks Mayur,

It resolved my Problem too
Mayur Patel
RE: Dynamic Query on Expando tables
October 18, 2012 11:25 PM
Answer

Mayur Patel

Rank: Expert

Posts: 350

Join Date: November 17, 2010

Recent Posts

Great guys...Good to know this emoticon

Happy Learning !!!