Skip to main content


Showing posts from November, 2011

Hibernate: Merge vs SaveOrUpdate

Hibernate: Merge vs SaveOrUpdateBy seung | September 18, 2008 In my previous and current project, I have run into cases where I needed to save an object to database using hibernate, and from time to time, I run into some sort of Hibernate Session Exception.  I did a bit of google search, and it turns out that when saving an object, I needed to make sure the object was attached to Hibernate session. This can be very tedious issue, since that means if you need to save an object that is not attached to a session, you need to do these. Retrieve the object using the Id value found within the object passed to you.Update the property values one by oneSave the object back within the same Hibernate Session Here’s a quick summary that I found out about MERGE and SaveOrUpdate.

The keyboard shortcuts for Goolge Chrome(or IE) browsers

Windows keyboard shortcuts Tab and window shortcutsCtrl+NOpens a new window.Ctrl+TOpens a new tab.Ctrl+Shift+NOpens a new window in incognito mode.Press Ctrl+O, then select file.Opens a file from your computer in Google Chrome.Press Ctrl and click a link. Or click a link with your middle mouse button (or mousewheel).Opens the link in a new tab in the background .Press Ctrl+Shift and click a link. Or press Shift and click a link with your middle mouse button (or mousewheel).Opens the link in a new tab and switches to the newly opened tab.Press Shift and click a link.Opens the link in a new window.Ctrl+Shift+TReopens the last tab you've closed. Google Chrome remembers the last 10 tabs you've closed.Drag a link to a tab.Opens the link in the tab.Drag a link to a blank area on the tab strip.Opens the link in a new tab.Drag a tab out of the tab strip.Opens the tab in a new window.Drag a tab out of the tab strip and into an existing window.Opens the tab in the existing window.P…

How to perform Authorization in Java with Apache Shiro

Authorization in Shiro can be handled in four ways. Programmatically - You can perform authorization checks in your java code with structures like if and else blocks.JDK annotations - You can attach an authorization annotation to your Java methodsJSP/GSP TagLibs - You can control jsp or gsp page output based on roles and permissionsProgrammatic Authorization Checking for permissions and roles, programmatically in your Java code is the traditional way of handling authorization. Here's how you can perform a permission check or role check in Shiro. Role Check This is an example of how you do a role check programmatically in your application. We want to check if a user has the administrator role and if they do, then we'll show a special button, otherwise we won't show it. First we get access to the current user, the Subject. Then we pass the adminstrator to the Subject's .hasRole() method. It will return TRUE or FALSE. //get the current Subject Subject currentUser = Secu…

How to check whether session was timed out in jsp page

Best what you could do is to add a <meta http-equiv="refresh"> tag to the <head> of the master template which redirects the page to the session timeout error page automatically whenever the session is expired. Since you're using a shared error page, you could pass the condition as a request parameter:<metahttp-equiv="refresh"content="${pageContext.session.maxInactiveInterval};url=error.jsp?type=timeout"