Linkin Park MinutesToMidnight
Monday, August 27, 2007
Tuesday, August 14, 2007
Method to get spring applicatin context from JSF
if(userAcctService == null){
ServletContext servletContext =
(ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext();
ApplicationContext appContext =
WebApplicationContextUtils.getWebApplicationContext(servletContext);
//WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext());
userAcctService = (UserAcctService)appContext.getBean("httpInvokerProxy");
}
if(userAcctService == null){
ServletContext servletContext =
(ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext();
ApplicationContext appContext =
WebApplicationContextUtils.getWebApplicationContext(servletContext);
//WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext());
userAcctService = (UserAcctService)appContext.getBean("httpInvokerProxy");
}
Wednesday, August 08, 2007
HQL: select object(s) from query result set
When you select a particular column(s) from table using HQL, how do you handle the return result? what is the type of result will be returned?
Here is some example:
When you select a single object:
private List loadAffiliationsbyCategory(MucRoom room, int affiliation) {
return getHibernateTemplate().find("Select id.jid from MucAffiliation where id.room=? and affiliation=?",
new Object[] {room,affiliation});
}
Test code:
for(String key:loadAffiliationsbyCategory2(room, MucRole.Affiliation.outcast.getValue())){
log.debug("test " + key);
}
When you select more then one object:
private List
When you select a particular column(s) from table using HQL, how do you handle the return result? what is the type of result will be returned?
Here is some example:
When you select a single object:
private List
return getHibernateTemplate().find("Select id.jid from MucAffiliation where id.room=? and affiliation=?",
new Object[] {room,affiliation});
}
Test code:
for(String key:loadAffiliationsbyCategory2(room, MucRole.Affiliation.outcast.getValue())){
log.debug("test " + key);
}
When you select more then one object:
private List
Subscribe to:
Posts (Atom)