Skip to main content

Posts

Showing posts from November, 2011

Hibernate: Merge vs SaveOrUpdate

Hibernate: Merge vs SaveOrUpdate By  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 one Save the object back within the same Hibernate Session Here’s a quick summary that I found out about MERGE and SaveOrUpdate. void saveOrUpdate(object)->object must be attached to a hibernate session (including all sub objects within the object), and once save/update is done, the object reflects the updated changes (e.

The keyboard shortcuts for Goolge Chrome(or IE) browsers

Windows keyboard shortcuts Tab and window shortcuts Ctrl+N Opens a new window. Ctrl+T Opens a new tab. Ctrl+Shift+N Opens 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+T Reopens 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 exist

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 methods JSP/GSP TagLibs - You can control jsp or gsp page output based on roles and permissions Programmatic 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 curr

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: <meta http-equiv = "refresh" content = "${pageContext.session.maxInactiveInterval};url=error.jsp?type=timeout" /> and check it in the  error.jsp  as follows: <c:choose>     <c:when test = "${param.type == 'timeout'}" >         <p> Your session has been timed out. </p>     </c:when>     <c:otherwise>         <!-- Handle default case here. -->     </c:otherwise> </c:choose>