Proxy is used as a mechanism in Hibernate allowing breaking of the objects in the database in smaller parts that can easily be accessed and use the memory efficiently. The proxy allows the loading of this object in real time from the database and calls the methods from there. This sub-class consists of all the parent methods and allows easy accessing of them. What is the use of Hibernate proxy in Hibernate?The proxies are easy to create and it is created dynamically by sub-classing the objects at runtime. It also provides the actually mapping to be performed between the tables and objects in the XML files. Hibernate allow the storing of large amount of data in small files that can be easily accessed and the performance can be faster. It allows polymorphic queries to be retrieved and selects the way to perform the database manipulation tasks. Hibernate uses Hibernate Query Language that is independent of the type of database used. It provides an advanced ORM solution to map the Java class files to the database tables for easy access and retrieval of the data. It doesn’t allow the programmer to write explicit code to map the database tables to the application objects that are used during the interaction with RDBMS. Why Hibernate is preferred over JDBC?The preference of Hibernate is more due to the transparency it provides to the programmer for writing their code. It uses inheritance, polymorphism and abstraction features to handle the request and respond to the queries coming from the user. It is an extension to the SQL that uses an Object oriented paradigm to communicate and retrieve the data from the database. It uses the objects for making a connection between the Hibernate and the database. It is a powerful language that uses flexible mechanism for query, store, and update to take the objects from the database. What is the purpose of HQL in communication between Hibernate and RDBMS?HQL stands for Hibernate Query language and is used to set the communication between the Hibernate and RDBMS. This allows the communication being done between different objects of Hibernate and RDBMS. In the end an execution of the query gets listed that contain the Java Objects of the file. A HQL query is being creation after taking the session from the session factory and starting the session for the user. A session gets created by taking the interface from the SessionFactory from the configuration object. hbm files used to map the objects automatically. When this file is loaded then a configuration object gets created. To create the communication first loading of the Hibernate configuration file takes place. What is the process of communication between Hibernate with RDBMS?To create the communication between the Hibernate and RDBMS there are some steps that are involved in the process. Puts annotated classes Author.java and Book.java in like this : ther = "BOOK_NAME", length = 400, nulaable=false) This.bookId = "AUTHOR_ID", nullable = false) Public Book() = "BOOK_ID", unique = true, nullable = false) Public class Book implements java.io.Serializable thorName = FetchType.LAZY, mappedBy = "author") Public void setAuthorName(String authorName) thorId = "AUTHOR_NAME", nullable = false, length = 100) Public void setAuthorId(Integer authorId) Public Author() = "AUTHOR_ID", unique = true, nullable = false) Public class Author implements java.io.Serializable Puts annotated classes Employee.java and EmployeeDetail.java in your Hibernate configuration file, and also MySQL connection details. This.address = "EMP_NAME", nullable = false) This.emp = "ADDRESS", nullable = false, length = 400) Parameters = "property", value = "EMP_ID", unique = true, nullable = false) This.address = "generator", strategy = "foreign", Public EmployeeDetail(Employee emp, String name, String address) Public void setEmpDetail(EmployeeDetail empDetail) This.empId = FetchType.LAZY, mappedBy = "emp", cascade = CascadeType.ALL) Public = "EMP_ID", unique = true, nullable = false) Public class EmployeeDetail implements java.io.Serializable Public class Employee implements java.io.Serializable
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |