Skip to main content

Posts

Showing posts from August 28, 2011

JSF Lifecycle Phases

JSF Lifecycle Phases JSF follows MVC design pattern to handle request-response process. Basically JSF handles three types of requests. Non-Faces Request Generates Faces Response Faces Request Generates Non-Faces Response Faces Request Generates Faces Response In another case of course non-jsf to non-jsf is there but in this case there is no involvement of JSF action here, so this is not a part of jsf lifecycle process. A JavaServer Faces page is represented by a tree of UI components, called a view . When a client makes a request for the page, the life cycle starts. During the life cycle, the JavaServer Faces implementation must build the view while considering state saved from a previous submission of the page. When the client submits a page, the JavaServer Faces implementation must perform several tasks, such as validating the data input of components in the view and converting input data to types specified on the server side. The JavaServer Faces implementation performs a...

Hibernate session.merge(persistingObject) Vs session.saveOrUpdate(persistingObject)

Hibernate provide two techniques to deal with save and update functionality, As per those techniques it first checks the instance in db, if It is already persisted in that database, if that is the case then it will simply persist the updated fields into DB otherwise it will persist the new instance in to DB. session.saveOrUpdate(persistingInstance) :It also persist the new instance in to DB and update the already persisted instances. Insert the data if the primary key is not exist. Problem:In some scenario's you might face the issue of NonUniqueObjectException : message "a different object with the same identifier value was already associated with the session." Technically before persisting in to db it first check in to the Hibernate cache, and by any reason if that object is present in cache then you will get the above exception. So by remedy of the above issue we can use session.merge(persistingObject) : It is directly checking in to your databa...