Fórum
Liferay 6.1 DynamicQuery Issue
Durrab Khan, modificado 11 Anos atrás.
Liferay 6.1 DynamicQuery Issue
New Member Postagens: 13 Data de Entrada: 11/05/12 Postagens Recentes
I have written the service entities which points to the different Data Source and Generates the code successfully. But I have a problem when I try to create a DynamicQuery and try to do order by and other stuff it give me the following below error
... 182 more
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Every derived table must have its own alias
Another thing My Data Source is related to Oracle Database and using Views but the Error it shows me with the MySQL jdbc Exception which really confuse.
Following below is the code which creates the query and call the Service
DynamicQuery query = null;
if(sortField != null && sortOrder != null){
if(sortOrder.equals(SortOrder.ASCENDING))
{
query = DynamicQueryFactoryUtil.forClass(APICARD_CUSTOMER.class,"ac");
//query = DynamicQueryFactoryUtil.forClass(APICARD_CUSTOMER.class,"ApiCardCustomer")
//.add(PropertyFactoryUtil.forName("ID_CUSTOMER").eq(new Long(10)));
}
else
{
query = DynamicQueryFactoryUtil.forClass(APICARD_CUSTOMER.class,"ac");
//query = DynamicQueryFactoryUtil.forClass(APICARD_CUSTOMER.class,"ApiCardCustomer")
// .addOrder(OrderFactoryUtil.desc(sortField));
}
@SuppressWarnings("unchecked")
List<APICARD_CUSTOMER> result = APICARD_CUSTOMERLocalServiceUtil.getService().dynamicQuery(query, start, end);
return result;
}
I just need to add that the problem is very strange: My Liferay database exist in My SQL and My Service Builder Generates the Entities from Oracle Database but the above code shows me the error in the My SQL Exception which is really strange it looks like the Dynamic Query is not using my Oracle Dialect
I really need a help as soon as possible
Thanks in Advance
Durrab Jami Khan
... 182 more
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Every derived table must have its own alias
Another thing My Data Source is related to Oracle Database and using Views but the Error it shows me with the MySQL jdbc Exception which really confuse.
Following below is the code which creates the query and call the Service
DynamicQuery query = null;
if(sortField != null && sortOrder != null){
if(sortOrder.equals(SortOrder.ASCENDING))
{
query = DynamicQueryFactoryUtil.forClass(APICARD_CUSTOMER.class,"ac");
//query = DynamicQueryFactoryUtil.forClass(APICARD_CUSTOMER.class,"ApiCardCustomer")
//.add(PropertyFactoryUtil.forName("ID_CUSTOMER").eq(new Long(10)));
}
else
{
query = DynamicQueryFactoryUtil.forClass(APICARD_CUSTOMER.class,"ac");
//query = DynamicQueryFactoryUtil.forClass(APICARD_CUSTOMER.class,"ApiCardCustomer")
// .addOrder(OrderFactoryUtil.desc(sortField));
}
@SuppressWarnings("unchecked")
List<APICARD_CUSTOMER> result = APICARD_CUSTOMERLocalServiceUtil.getService().dynamicQuery(query, start, end);
return result;
}
I just need to add that the problem is very strange: My Liferay database exist in My SQL and My Service Builder Generates the Entities from Oracle Database but the above code shows me the error in the My SQL Exception which is really strange it looks like the Dynamic Query is not using my Oracle Dialect
I really need a help as soon as possible
Thanks in Advance
Durrab Jami Khan
David H Nebinger, modificado 11 Anos atrás.
RE: Liferay 6.1 DynamicQuery Issue
Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
I've had little luck using DQ on the outside. I've taken to only using DQ within my XxxLocalServiceImpl class, exposing a method to the outside to call.
I think your problem is a result of trying to cross the class loader boundary. When you call APICARD_CUSTOMERLocalServiceUtil.getService(), the instance you get back is actually within the class loader of the portlet providing the service, not your class loader. Things start to break in mysterious ways when you do that.
Instead add your method within APICARD_CUSTOMERLocalServiceImpl to do the necessary DQ retrieve and use the generated method in APICARD_CUSTOMERLocalServiceUtil and I think you'll be fine.
I think your problem is a result of trying to cross the class loader boundary. When you call APICARD_CUSTOMERLocalServiceUtil.getService(), the instance you get back is actually within the class loader of the portlet providing the service, not your class loader. Things start to break in mysterious ways when you do that.
Instead add your method within APICARD_CUSTOMERLocalServiceImpl to do the necessary DQ retrieve and use the generated method in APICARD_CUSTOMERLocalServiceUtil and I think you'll be fine.
Durrab Khan, modificado 11 Anos atrás.
RE: Liferay 6.1 DynamicQuery Issue
New Member Postagens: 13 Data de Entrada: 11/05/12 Postagens Recentes
Thanks for your precious reply
That really helps - I created the method in the LocalServiceBaseImpl and called the DynamicQuery from its Util and it works fine.
Thanks Again
Regards:
Durrab Jami Khan
That really helps - I created the method in the LocalServiceBaseImpl and called the DynamicQuery from its Util and it works fine.
Thanks Again
Regards:
Durrab Jami Khan