[Building Sakai] Composite primary key

Aaron Zeckoski aaronz at vt.edu
Sat May 9 01:46:36 PDT 2009


If you want to get the users of a site then this is not really the way
to do it. You probably want to do something more like this:
http://bugs.sakaiproject.org/confluence/display/BOOT/Using+the+SiteService
(see the part about getting members)
OR
http://bugs.sakaiproject.org/confluence/display/BOOT/Using+the+AuthzGroup+Service
(see the part about getting users in a site with given permissions)

If this actually has nothing to do with Sakai users and sites and you
are trying to store your own hibernate stuff then you probably want to
not use composite keys. They are tricky in hibernate and require at
least the following:
1) the pojos must override equals() and hashCode() to implement
composite identifier equality
2) the pojos must implement Serializable
3) the class must use load() to retrieve the persistent object once
the key values are persisted on a copy of the pojo which you
instantiate via new
4) queries must include all composite key values (you cann to a query
on part of a composite key)

In general I would recommend you do not use composite keys (and the
hibernate manual seems to discourage it as well).
https://www.hibernate.org/5.html
-AZ


On Sat, May 9, 2009 at 7:04 AM, KetanNale <ketan_nale at yahoo.com> wrote:
>
> Hi All,
>
> I am trying to get all users of a particular site.For getting it i have used
> "dao", The method  is as follows
>
> public List<SakaiSiteUser> getAllSiteUsersBySiteId(String siteId) {
>                // TODO Auto-generated method stub
>                List<SakaiSiteUser> sakaiSiteUserList= null;
>                SakaiSiteUserPK sakaiSiteUserPK = new SakaiSiteUserPK();
>                SakaiSite sakaiSite = new SakaiSite();
>                sakaiSite.setId(siteId);
>                sakaiSiteUserPK.setSite(sakaiSite);
>                sakaiSiteUserList = dao.findBySearch(SakaiSiteUser.class,  new
> Search("id",sakaiSiteUserPK));
>                return sakaiSiteUserList;
>        }
>
> Here i want to search only on site_id , user_id for site can be anythig.
>
> For reference attaching some of the files with this message.
> http://www.nabble.com/file/p23457620/SakaiSiteUser.hbm.xml
> SakaiSiteUser.hbm.xml
> http://www.nabble.com/file/p23457620/SakaiSiteUser.java SakaiSiteUser.java
> http://www.nabble.com/file/p23457620/SakaiSiteUserPK.java
> SakaiSiteUserPK.java
> http://www.nabble.com/file/p23457620/BaseSakaiSiteUser.java
> BaseSakaiSiteUser.java
> http://www.nabble.com/file/p23457620/BaseSakaiSiteUserPK.java
> BaseSakaiSiteUserPK.java
> --
> View this message in context: http://www.nabble.com/Composite-primary-key-tp23457620p23457620.html
> Sent from the Sakai - Development mailing list archive at Nabble.com.
>
> _______________________________________________
> 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"
>



-- 
Aaron Zeckoski (aaronz at vt.edu)
Senior Research Engineer - CARET - Cambridge University
[http://bugs.sakaiproject.org/confluence/display/~aaronz/]
Sakai Fellow - [http://aaronz-sakai.blogspot.com/]


More information about the sakai-dev mailing list