[Building Sakai] Help on how to query Sakai database

markjnorton at earthlink.net markjnorton at earthlink.net
Wed Jul 9 10:01:03 PDT 2014


Generally, it is not recommended to make direct queries against a Sakai database.  The data contained in these records are maintained and managed by the Site Service.  A Java API allows you to access Site information, including some rather powerful search capabilities.  While the database schema has been stable for quite some time, there is no guarantee that it won't change in a future release.  The API protects you against those sorts of changes, even updating table definitions as needed.  I strongly suggest you have a look at the Site Service in the Sakai kernel and see if the objects/methods meet your needs.

- Mark Norton


-----Original Message-----
>From: Virgílio Santos <virgilio.santos at gmail.com>
>Sent: Jul 9, 2014 11:04 AM
>To: sakai-dev at collab.sakaiproject.org
>Subject: [Building Sakai] Help on how to query Sakai database
>
>Hello,
>
>I have a query do execute on Sakai database that I could not figured
>out how to do with the available services. Basically, I want to query
>all Sites that have some specific tool in at least one of its pages.
>
>For know, I'm trying something like this (It's not the query I will
>really use, just an example):
>
>String sql = "SELECT * from SAKAI_SITE";
>List<Site> siteList = null;
>
>SQLQuery query = this.getSession().createSQLQuery(sql);
>query.addEntity(Site.class);
>query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
>List results = query.list();
>
>for(Object object : results) {
>    Site s = (Site) object;
>    // do stuff
>}
>
>And getting this error:
>org.sakaiproject.portal.api.PortalHandlerException:
>org.sakaiproject.tool.api.ToolException:
>org.springframework.web.util.NestedServletException: Request
>processing failed; nested exception is org.hibernate.MappingException:
>Unknown entity: org.sakaiproject.site.api.Site
>
>Any tips on making complex data queries on Sakai database will be very
>useful as well
>
>Thanks in advance.
>
>-- 
>Deserve's Got Nothing To Do With It
>_______________________________________________
>sakai-dev mailing list
>sakai-dev at collab.sakaiproject.org
>http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>
>TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"



More information about the sakai-dev mailing list