[Building Sakai] Composite primary key

Aaron Zeckoski aaronz at vt.edu
Sat May 9 03:22:36 PDT 2009


In this case you should maybe consider sending a link to your code and
including the stacktrace of the exception you are getting.

I have used sakai services from JSP without problems and the team from
unisa has several struts tools which work in sakai. Look at this for
some ideas:
https://source.sakaiproject.org/contrib/unisa/struts/trunk/

The beans as defined below look ok to me.
-AZ


On Sat, May 9, 2009 at 11:10 AM, Ketan Nale <ketan_nale at yahoo.com> wrote:
> Thanks Aaron,
>
>         I am using struts and JSP with spring.I have problem in using
> SiteService. It is injected it in externalLogic bean in my appContext as
> follows:
>         At my first request to externalLogic bean i am getting all methods
> working fine,but when there is second call to any method of externalLogic,
> it throws null pointer exception on bens object.
>        I posted same problem on forum before but didnt get any reply. Also
> tried many other ways but no one worked so started using this dao instace
> for time being.
>        There is one more interesting thing that when i create my Apps
> iteamBean object on JSP as there in code generated from SakaiAppBuilder i
> can get externalLogic instance.But i dont want to put any code/logic on JSP
>
> myAppContext.xml
>
> <beans>
>
>     <!-- Bring in the hibernate related beans -->
>     <import resource="spring-hibernate.xml" />
>     <import resource="sakai-hibernate.xml" />
>
>     <!-- create an external logic bean which abstracts out the Sakai bits
> -->
>     <bean id="org.sakaiproject.accounts.logic.ExternalLogic"
>         class="org.sakaiproject.accounts.logic.ExternalLogicImpl"
>         init-method="init">
>         <property name="functionManager"
> ref="org.sakaiproject.authz.api.FunctionManager" />
>         <property name="securityService"
> ref="org.sakaiproject.authz.api.SecurityService" />
>         <property name="sessionManager"
> ref="org.sakaiproject.tool.api.SessionManager" />
>         <property name="siteService"
> ref="org.sakaiproject.site.api.SiteService" />
>         <property name="toolManager"
> ref="org.sakaiproject.tool.api.ToolManager" />
>         <property name="userDirectoryService"
>             ref="org.sakaiproject.user.api..UserDirectoryService" />
>     </bean>
>
>     <!-- create a logic bean, give it the dao from above -->
>     <bean id="org.sakaiproject.accounts.logic.AccountsLogic"
>         class="org.sakaiproject.accounts.logic.AccountsLogicImpl"
>         init-method="init">
>         <property name="dao"
>             ref="org.sakaiproject.accounts.dao.AccountsDao" />
>         <property name="externalLogic"
>             ref="org.sakaiproject.accounts.logic.ExternalLogic" />
>     </bean>
> </beans>
>
>
>
> --- On Sat, 9/5/09, Aaron Zeckoski <aaronz at vt.edu> wrote:
>
> From: Aaron Zeckoski <aaronz at vt.edu>
> Subject: Re: [Building Sakai] Composite primary key
> To: "KetanNale" <ketan_nale at yahoo.com>
> Cc: sakai-dev at collab.sakaiproject.org
> Date: Saturday, 9 May, 2009, 2:16 PM
>
> 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/]
>
> ________________________________
> Bring your gang together. Do your thing. Find your favourite Yahoo! Group.



-- 
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