Q: – What is Hibernate proxy?
Mapping of classes can be made into a proxy instead of a table. A proxy is returned when actually a load is called on a session. The proxy contains actual method to load the data. The proxy is created by default by Hibernate, for mapping a class to a file. The code to invoke Jdbc is contained in this class
Q: – What is the difference between merge and update ?
update () : When the session does not contain an persistent instance with the same identifier, and if it is sure use update for the data persistence in hibernate. merge (): Irrespective of the state of a session, if there is a need to save the modifications at any given time, use merge().
Q: – What is the difference between load() and get() in Hibernate ?
Difference between load() and get() load() Use this method if it is sure that the objects exist. The load() method throws an exception,when the unique id could not found in the database. The load() method returns proxy by default and the data base will not be effected until the invocation of the proxy. get() Use this method if it is not sure that the objects exist. Returns null when the unique id is unavailable in the database. The data base will be effected immediately.
Q: – what is the main difference between Entity Beans and Hibernate.?
Entity beans are to be implemented by containers, classes, descriptors. Hibernate is just a tool that quickly persist the object tree to a class hierarchy in a database and without using a single SQL statement. The inheritance and polymorphism is quite simply implemented in hibernate which is out of the box of EJB and a big drawback.
Q: – What is ORM?
Object Relational Model is a programming technique. This technique is used to convert the data from an incompatible type to that of a relational database. The mapping is done by using the OOP languages. For example every table in a table is represented by an object.
The purpose of ORM is an application is allowed and written OOP language that is to deal with the data that is manipulates in the forms objects. The class level attributes are ‘mapped’ to tables.
Q: – What is lazy fetching in hibernate?
Lazy fetchieng is associated with child objects loading for its parents. While loading the parent, the selection of loading a child object is to be specified / mentioned in the hbm.xml file. Hibernate does not load the whole child objects by default. Lazy=true means not to load the child objects.
Q: – What are the benefits of HibernateTemplate?
The benefits of HibernateTemplate are:
- HibernateTemplate, which is a Spring Template class, can simplify the interactions with Hibernate Sessions.
- Various common functions are simplified into single method invocations.
- The sessions of hibernate are closed automatically
- The exceptions will be caught automatically, and converts them into runtime exceptions.
Q: – What is Hibernate Query Language (HQL)?
Hibernate Query Language is designed for data management using Hibernate technology. It is completely object oriented and hence has notions like inheritance, polymorphism and abstraction. The queries are case-sensitive. This has an exception for Java classes and properties. The query operations are through objects. HQL acts as a bridge between Objects and RDBMS.
Q: – What are the core interfaces of Hibernate framework?
1. Session Interface: The basic interface for all hibernate applications. The instances are light weighted and can be created and destroyed without expensive process. 2. SessionFactory interface: The delivery of session objects to hibernate applications is done by this interface. For the whole application, there will be generally one SessionFactory and can be shared by all the application threads. 3. Configuration Interface: Hibernate bootstrap action is configured by this interface. The location specification is specified by specific mapping documents, is done by the instance of this interface. 4. Transaction Interface: This is an optional interface. This interface is used to abstract the code from a transaction that is implemented such as a JDBC / JTA transaction. 5. Query and Criteria interface: The queries from the user are allowed by this interface apart from controlling the flow of the query execution.
Q: – Explain the role of Session interface in Hibernate.
Session interface is a single threaded object. The representation of single unit of work with the Java application and the persistence database is done by this object. The wrapping of a JDBC connection is the emphasized role of a Session interface object. This is the major interface between Java application and Hibernate. This is a runtime interface. The beginning and ending of a transaction cycle is bounded by the Session interface. The purpose of this interface is to perform create, read and delete operations for the objects that are mapped with entity classes.
Q: – Explain with code sample how to create a custom control ?
Steps to create a custom control:
- Create a new project.
- Add a custom control to the project.
- Change the name of the class you need to inherit the control from the base class. E.g. inherit the class from System.Windows.Forms.Button if the control s to be inherited from a button class.
- Implement the control with custom properties and featured needed by the control.
- Override the OnPaint method if the control’s appearance needs to be changed.
- Save the build the control
- Reference you control into another or the same project and use the control.
Submitted By:-Goyal Ankur Email-ID: – email@example.com