save vs persist Hibernate

Save(): 1. Syntax: public Serializable save(Object object) throws HibernateException. 2. The return type of the save method is java.io.Serializable. It returns the generated Id after saving the record. 3. It can save the changes to the database outside of the transaction. i.e. Save method can be used inside or outside the transaction. 4. Session.save() for … Read more

openSession vs getCurrentSession Hibernate

The SessionFactory.getCurrentSession() returns a session bound to a context. We don’t need to close this. We have to set hibernate.current_session_context_class to thread and then implement something like a servlet filter that opens the session. We can access that session anywhere else by using the SessionFactory.getCurrentSession(). thread The SessionFactory.openSession() always opens a new session that we … Read more

get() vs load() Hibernate

session.load() • It will always return a “proxy” in Hibernate terms without hitting the database. In Hibernate, proxy represents a fake object with the given identifier value but its properties are not initialized yet. • If no record found, it will throws an ObjectNotFoundException. • Example: Let we call session.load(Employee.class,new Integer(10)). Hibernate will create one … Read more

JSF Interview Questions and Answers

What is JSF? JSF stands for Java Server Faces. It is a UI component based and event driven MVC web application framework which simplifies the UI construction by reusable UI component. JSF specification provides a set of standard UI components which are reusable and extendable. Note: JSF is built on top of the Servlet API. … Read more

Struts 2 Interview Questions and Answers

What is MVC? MVC stands for Model-View-Controller design pattern which separates the business logic, presentation logic and navigation logic. Where: Model: is responsible for encapsulating the application data (POJO). View: is responsible for rendering the model data. Controller: is responsible for receiving the user request, building model object and passing the model object to the … Read more

JSP lifecycle phases

A JSP page is converted into servlet before service requests. JSP Lifecycle consists of following phases: JSP Page Translation: The container validates the JSP page and parse it to generate the servlet file. JSP Page Compilation: The generated servlet file is compiled into a servlet class. Class Loading: Container loads the generated servlet class into … Read more

Categories JSP

JSP Interview Questions and Answers

What is JSP? JSP refers to the java server pages. Before starting discussion on jsp let us discuss the some problems of servlet. See more at: JSP Overview. What are the JSP lifecycle phases? A JSP page is converted into servlet before service requests. JSP Lifecycle consists of following phases: JSP Page Translation: The container … Read more

Servlets Interview Questions and Answers

What is a Web application? A web application or website is an application program which accessed over a network connection using HTTP and often runs inside a web browser. What is a Web browser? A web browser is a program which acts as an interface between user and web application e.g. Internet Explorer, Chrome, Safari, … Read more

Java examples programs

  Learn basic simple core java examples programs tutorial with output in eclipse online for hello world, java data types, if else statements, switch statement, for loop, enhanced for loop, while loop, do while loop and more.   Hello World java example: Java hello world example eclipse. Java data types examples programs: Java data types … Read more

Java Generate Pyramid Triangle

  Program to generate pyramid triangle example in java. /** * Program to generate pyramid triangle example in java. * @author W3schools360 */ public class GeneratePyramidTriangleExample { static void generatePyramidTriangle(int rows){ //Logic to generate pyramid triangle. for(int i=1; i<= rows; i++){ for(int j=0; j < i; j++){ System.out.print(“*”); } //New line. System.out.println(“”); } } public … Read more