Fórumok
custom-sql in liferay 6.1
sheela mk, módosítva 12 év-val korábban
custom-sql in liferay 6.1
Regular Member Bejegyzések: 111 Csatlakozás dátuma: 2012.02.17. Legújabb bejegyzések
hai..Everbody,
trying for custom-sql query,with Liferay6.1 with tomcat7,mysql
M not able to generate its BooksFinder interface and BooksfinderUtil class after ant build-service also
Let me know wher i ve gone wrong..
Using Eclipse helios in Ubunto..
service.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd">
<service-builder package-path="book.database">
<author>sourceone</author>
<namespace>B</namespace>
<entity name="Books" local-service="true" remote-service="false">
<column name="bookId" type="long" primary="true"></column>
<column name="title" type="String"></column>
<column name="author" type="String"></column>
<column name="dateOfPurchase" type="Date"></column>
<column name="pages" type="int"></column>
<column name="userId" type="long"></column>
<column name="companyId" type="long"></column>
<column name="groupId" type="long"></column>
<order by="asc">
<order-column name="bookId"></order-column>
</order>
<finder return-type="Collection" name="GroupId">
<finder-column name="groupId"></finder-column>
</finder>
<finder return-type="Collection" name="CompanyId">
<finder-column name="companyId"></finder-column>
</finder>
<finder return-type="Collection" name="UserId">
<finder-column name="userId"></finder-column>
</finder>
<finder return-type="Collection" name="Group_Title">
<finder-column name="groupId"></finder-column>
<finder-column name="title"></finder-column>
</finder>
<finder return-type="Collection" name="Group_Author">
<finder-column name="groupId"></finder-column>
<finder-column name="author"></finder-column>
</finder>
</entity>
</service-builder>
package book.database.service.persistence;
import java.util.List;
import book.database.model.impl.BooksImpl;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.SQLQuery;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
import com.liferay.util.dao.orm.CustomSQLUtil;
public class BookFinderImpl extends BasePersistenceImpl { //Here I has to use implements BooksFinder
public List findBooks(String title)
{
public final String FIND_BOOK="findBooks";
Session session=null;
session=openSession();
String sql=CustomSQLUtil.get(FIND_BOOK);
SQLQuery query=session.createSQLQuery(sql);
query.addEntity("Books",BooksImpl.class);
QueryPos qpos=QueryPos.getInstance(query);
qpos.add(title);
return (List)query.list();
}
}
/src/custom-sql/default.xml
<?xml version="1.0" encoding="UTF-8"?>
<custom-sql>
<sql id="findBooks">
<![CDATA[
SELECT
{Books.*}
FROM
Books
WHERE
(Books.title like ?)
]]>
</sql>
</custom-sql>
portal-ext.properties
custom.sql.configs=custom-sql/default.xml
trying for custom-sql query,with Liferay6.1 with tomcat7,mysql
M not able to generate its BooksFinder interface and BooksfinderUtil class after ant build-service also
Let me know wher i ve gone wrong..
Using Eclipse helios in Ubunto..
service.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd">
<service-builder package-path="book.database">
<author>sourceone</author>
<namespace>B</namespace>
<entity name="Books" local-service="true" remote-service="false">
<column name="bookId" type="long" primary="true"></column>
<column name="title" type="String"></column>
<column name="author" type="String"></column>
<column name="dateOfPurchase" type="Date"></column>
<column name="pages" type="int"></column>
<column name="userId" type="long"></column>
<column name="companyId" type="long"></column>
<column name="groupId" type="long"></column>
<order by="asc">
<order-column name="bookId"></order-column>
</order>
<finder return-type="Collection" name="GroupId">
<finder-column name="groupId"></finder-column>
</finder>
<finder return-type="Collection" name="CompanyId">
<finder-column name="companyId"></finder-column>
</finder>
<finder return-type="Collection" name="UserId">
<finder-column name="userId"></finder-column>
</finder>
<finder return-type="Collection" name="Group_Title">
<finder-column name="groupId"></finder-column>
<finder-column name="title"></finder-column>
</finder>
<finder return-type="Collection" name="Group_Author">
<finder-column name="groupId"></finder-column>
<finder-column name="author"></finder-column>
</finder>
</entity>
</service-builder>
package book.database.service.persistence;
import java.util.List;
import book.database.model.impl.BooksImpl;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.SQLQuery;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
import com.liferay.util.dao.orm.CustomSQLUtil;
public class BookFinderImpl extends BasePersistenceImpl { //Here I has to use implements BooksFinder
public List findBooks(String title)
{
public final String FIND_BOOK="findBooks";
Session session=null;
session=openSession();
String sql=CustomSQLUtil.get(FIND_BOOK);
SQLQuery query=session.createSQLQuery(sql);
query.addEntity("Books",BooksImpl.class);
QueryPos qpos=QueryPos.getInstance(query);
qpos.add(title);
return (List)query.list();
}
}
/src/custom-sql/default.xml
<?xml version="1.0" encoding="UTF-8"?>
<custom-sql>
<sql id="findBooks">
<![CDATA[
SELECT
{Books.*}
FROM
Books
WHERE
(Books.title like ?)
]]>
</sql>
</custom-sql>
portal-ext.properties
custom.sql.configs=custom-sql/default.xml
Victor E, módosítva 11 év-val korábban
RE: custom-sql in liferay 6.1
New Member Bejegyzések: 5 Csatlakozás dátuma: 2012.03.02. Legújabb bejegyzések
Hi Sheela,
Were you able to resolve your issue?
I encountered the same problem with the Finder and FinderUtil class not being generated after running build-service.
Using LR 6.1 and Eclipse Indigo.
Were you able to resolve your issue?
I encountered the same problem with the Finder and FinderUtil class not being generated after running build-service.
Using LR 6.1 and Eclipse Indigo.
sheela mk, módosítva 11 év-val korábban
RE: custom-sql in liferay 6.1
Regular Member Bejegyzések: 111 Csatlakozás dátuma: 2012.02.17. Legújabb bejegyzések
Hai..After refreshing project I got it..
But Some times I wont get it..if i try out other ex.......
exactly I dont kwn what the solution is.. But i got it for BookFinder interface..and BookfinderUtil..
let me knw..if u get any answers..
But Some times I wont get it..if i try out other ex.......
exactly I dont kwn what the solution is.. But i got it for BookFinder interface..and BookfinderUtil..
let me knw..if u get any answers..
Sandeep Nair, módosítva 11 év-val korábban
RE: custom-sql in liferay 6.1
Liferay Legend Bejegyzések: 1744 Csatlakozás dátuma: 2008.11.06. Legújabb bejegyzések
Unlike other classes that are generated by Servicebuilder, finders are not generated automatically.
You first have to manually create FinderImpl class and then run the servicebuilder to generate the other finder related classes
http://kamalkantrajput.blogspot.com/2009/07/how-to-use-custom-sql-in-liferay.html
Regards,
Sandeep
You first have to manually create FinderImpl class and then run the servicebuilder to generate the other finder related classes
http://kamalkantrajput.blogspot.com/2009/07/how-to-use-custom-sql-in-liferay.html
Regards,
Sandeep
Subhash Pavuskar, módosítva 11 év-val korábban
RE: custom-sql in liferay 6.1
Regular Member Bejegyzések: 234 Csatlakozás dátuma: 2012.03.13. Legújabb bejegyzések
Can anyone tell me what is the use of custom sql and when to use it?
Hitoshi Ozawa, módosítva 11 év-val korábban
RE: custom-sql in liferay 6.1
Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
Following wiki may help you:
http://www.liferay.com/community/wiki/-/wiki/Main/Service+Builder+Finders
http://www.liferay.com/community/wiki/-/wiki/Main/Service+Builder+Finders
Edgar Trania, módosítva 10 év-val korábban
RE: custom-sql in liferay 6.1
Junior Member Bejegyzések: 37 Csatlakozás dátuma: 2010.11.13. Legújabb bejegyzések
also having same problem clicking refresh doesn't show xxxFinder interface and xxxFinderUtil class at also i tried to reopen my eclipse and that interface and class doesnt show what is the problem
im using liferay 6.1 and eclipse juno on windows
im using liferay 6.1 and eclipse juno on windows
Piña Kanpokaldean, módosítva 9 év-val korábban
RE: custom-sql in liferay 6.1
Junior Member Bejegyzések: 79 Csatlakozás dátuma: 2012.04.14. Legújabb bejegyzések
Just a note, since I just solved a similar issue I was having: the finderImpl method you have to create manually must have the entity's exact name. If you use anything else as the class name, the interface won't be generated. Hopefully this will be of use to someone, eventually,.
3ESofttech Solutions, módosítva 9 év-val korábban
RE: custom-sql in liferay 6.1
New Member Bejegyzések: 2 Csatlakozás dátuma: 2014.08.20. Legújabb bejegyzések
Please check the Sql query