{"id":3791,"date":"2020-06-22T18:56:27","date_gmt":"2020-06-22T13:26:27","guid":{"rendered":"https:\/\/www.h2kinfosys.com\/blog\/?p=3791"},"modified":"2020-06-22T18:56:29","modified_gmt":"2020-06-22T13:26:29","slug":"hibernate-program","status":"publish","type":"post","link":"https:\/\/www.h2kinfosys.com\/blog\/hibernate-program\/","title":{"rendered":"Hibernate Program"},"content":{"rendered":"\n<p>Let&#8217;s create our first Java application with Hibernate technology.&nbsp;<\/p>\n\n\n\n<p>One of the simplest ways is to create a basic Maven project and to add Hibernate dependency to pom.xml. The version of the <a href=\"https:\/\/www.h2kinfosys.com\/blog\/hibernate-overview\/\">Hibernate framework <\/a>can vary:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em>&lt;dependency&gt;&nbsp;<\/em>\n<em>&lt;groupId&gt;org.hibernate&lt;\/groupId&gt;&nbsp;<\/em>\n<em>&lt;artifactId&gt;hibernate-agroal&lt;\/artifactId&gt;&nbsp;<\/em>\n<em>&lt;version&gt;5.4.17.Final&lt;\/version&gt;&nbsp;<\/em>\n<em>&lt;type&gt;pom&lt;\/type&gt;&nbsp;<\/em>\n<em>&lt;\/dependency&gt;&nbsp;<\/em><\/pre>\n\n\n\n<p>We are going to use the MySQL database. So, you need to make sure your MySQL database already have setup. Also, we will need the <a href=\"https:\/\/www.h2kinfosys.com\/blog\/jdbc-vs-orm-framework\/\">JDBC driver for MySQL<\/a>. As we have the maven project, we just need to add to pom.xml dependencies to the library :<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<pre class=\"wp-block-preformatted\"><em>&lt;!-- https:\/\/mvnrepository.com\/artifact\/mysql\/mysql-connector-java --&gt;<\/em>\n<em>&lt;dependency&gt;<\/em>\n<em>&lt;groupId&gt;mysql&lt;\/groupId&gt;<\/em>\n<em>&lt;artifactId&gt;mysql-connector-java&lt;\/artifactId&gt;<\/em>\n<em>&lt;version&gt;8.0.20&lt;\/version&gt;<\/em>\n<em>&lt;\/dependency&gt;<\/em><\/pre>\n<\/div><\/div>\n\n\n\n<p>As the next preparation step, we need to create a MySQL database. For this example, we created &#8220;exampledb&#8221; and one database table Customer. Here is the SQL query that was run for the table creation:<\/p>\n\n\n<p>[box type=&#8221;shadow&#8221; align=&#8221;&#8221; class=&#8221;&#8221; width=&#8221;&#8221;]<\/p>\n<p><i><span style=\"font-weight: 400;\">create table exampledb.CUSTOMER (<br><\/span><\/i><i><span style=\"font-weight: 400;\">&nbsp; &nbsp;id INT NOT NULL auto_increment,<br><\/span><\/i><i><span style=\"font-weight: 400;\">&nbsp; &nbsp;first_name VARCHAR(20) default NULL,<br><\/span><\/i><i><span style=\"font-weight: 400;\">&nbsp; &nbsp;last_name&nbsp; VARCHAR(20) default NULL,<br><\/span><\/i><i><span style=\"font-weight: 400;\">&nbsp; &nbsp;email VARCHAR(20)&nbsp; default NULL,<br>&nbsp;&nbsp;&nbsp;PRIMARY KEY (id));<br><\/span><\/i><em><strong>To run this query, you can use MySQL Workbench:<\/strong><\/em><\/p>\n<p>[\/box]<\/p>\n\n\n<p><img fetchpriority=\"high\" decoding=\"async\" width=\"608\" height=\"398\" src=\"https:\/\/lh4.googleusercontent.com\/CO-8-MurENILttNsRpnCZ8vKQX7PkE-kX5Oitff4wB3AlnP-o8NjE8QmHL9PxxcF21iPkEU275HEZqom3K2a1KxBDcyps4ouwuCxBukI4mAwM0cUcwY9EfR8ZV8dTRULAi6wGwDr\" alt=\"\" title=\"\"><\/p>\n\n\n\n<p>The Java POJO(Plain Old Java Object) class is a class with fields, constructors, getters, and setters.&nbsp; Methods getXXX and setXXXwill make it JavaBeans compliant class.<\/p>\n\n\n\n<p>A POJO doesn&#8217;t extend some specialized classes or implement interfaces.&nbsp; If you create a class that will be persisted by Hibernate, it is important to provide <a href=\"https:\/\/en.wikipedia.org\/wiki\/JavaBeans\" rel=\"nofollow noopener\" target=\"_blank\">JavaBeans <\/a>compliant and create one attribute, which will work as an ID.<\/p>\n\n\n\n<p><strong><em>Let&#8217;s create a corresponding Java POJO class in our application:<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>package<\/strong> edu.hibernate.example;\n\n<strong>public<\/strong> <strong>class<\/strong> Customer {\n<strong>private<\/strong> <strong>int<\/strong> id;\n<strong>private<\/strong> String firstName;\n<strong>private<\/strong> String lastName;\n<strong>private<\/strong> String email;\n<strong>public<\/strong> Customer (String firstName, String lastName, String email) {\n<strong>super<\/strong>();\n<strong>this<\/strong>.firstName = firstName;\n<strong>this<\/strong>.lastName = lastName;\n<strong>this<\/strong>.email = email;\n}\n<strong>public<\/strong> Customer() {\n}\n<strong>public<\/strong> <strong>int<\/strong> getId() {\n<strong>return<\/strong> id;\n}\n<strong>public<\/strong> <strong>void<\/strong> setId(<strong>int<\/strong> id) {\n<strong>this<\/strong>.id = id;\n}\n<strong>public<\/strong> String getFirstName() {\n<strong>return<\/strong> firstName;\n}\n<strong>public<\/strong> <strong>void<\/strong> setFirstName(String firstName) {\n<strong>this<\/strong>.firstName = firstName;\n}\n<strong>public<\/strong> String getLastName() {\n<strong>return<\/strong> lastName;\n}\n<strong>public<\/strong> <strong>void<\/strong> setLastName(String lastName) {\n<strong>this<\/strong>.lastName = lastName;\n}\n<strong>public<\/strong> String getEmail() {\n<strong>return<\/strong> email;\n}\n<strong>public<\/strong> <strong>void<\/strong> setEmail(String email) {\n<strong>this<\/strong>.email = email;\n}\n}\n<\/pre>\n\n\n\n<p><strong><em>To relate database table with java class we need to create xml-file Customer.hbh.xml in the resources folder:<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?xml version = <em>\"1.0\"<\/em> encoding = <em>\"utf-8\"<\/em>?&gt;\n&lt;!DOCTYPE hibernate-mapping PUBLIC&nbsp;\n\"-\/\/Hibernate\/Hibernate Mapping DTD\/\/EN\"\n\"http:\/\/www.hibernate.org\/dtd\/hibernate-mapping-3.0.dtd\"&gt;&nbsp;\n\n&lt;hibernate-mapping&gt;\n&nbsp;&nbsp;&nbsp;&lt;class name = <em>\"edu.hibernate.example.Customer\"<\/em> table = <em>\"CUSTOMER\"<\/em>&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;meta attribute = <em>\"class-description\"<\/em>&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This class contains the customer detail.&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/meta&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;id name = <em>\"id\"<\/em> type = <em>\"int\"<\/em> column = <em>\"id\"<\/em>&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;generator class=<em>\"native\"<\/em>\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/id&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;property name = <em>\"firstName\"<\/em> column = <em>\"first_name\"<\/em> type = <em>\"string\"<\/em>\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;property name = <em>\"lastName\"<\/em> column = <em>\"last_name\"<\/em> type = <em>\"string\"<\/em>\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;property name = <em>\"email\"<\/em> column = <em>\"email\"<\/em> type = <em>\"string\"<\/em>\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&lt;\/class&gt;\n&lt;\/hibernate-mapping&gt;<\/pre>\n\n\n\n<p>Now we need to create a configuration file in our application with a set of settings related to MySQL database and other related parameters.&nbsp; Developers that work on applications that include the Hibernate technology place all such information as a standard Java properties file called hibernate.properties. Also, there is an option to supply this information as an XML file named hibernate.cfg.xml.<\/p>\n\n\n\n<p>In our examples, we will use the way with XML formatted file hibernate.cfg.xml to specify required Hibernate properties. If some of the properties are not specified Hibernate takes the default value. Most of the properties are not required to specify them in the property file, but there are some mandatory properties. This file hibernate.cfg.xml location is in the <em>resources<\/em> folder. Let&#8217;s look at the list of the important Hibernate properties that we used in our configuration file. They are required to be configured for a database in a regular situation:<\/p>\n\n\n\n<p>hibernate.dialect &#8211; the property is responsible to pass information to Hibernate so it will generate the appropriate SQL for the chosen database.<\/p>\n\n\n<p>[box type=&#8221;info&#8221; align=&#8221;&#8221; class=&#8221;&#8221; width=&#8221;&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">hibernate.connection.driver_class &#8211; this property holds the JDBC driver class.<br><\/span><span style=\"font-weight: 400;\">hibernate.connection.url &#8211; property contains the JDBC URL to the database instance.<br><\/span><span style=\"font-weight: 400;\">hibernate.connection.username &#8211; property to place the database username.<br><\/span><span style=\"font-weight: 400;\">hibernate.connection.password &#8211;&nbsp; property to place the database password.<\/span><\/p>\n<p>[\/box]<\/p>\n\n\n<pre class=\"wp-block-preformatted\">&lt;?xml version = <em>\"1.0\"<\/em> encoding = <em>\"utf-8\"<\/em>?&gt;\n&lt;!DOCTYPE hibernate-configuration SYSTEM&nbsp;\n\"http:\/\/www.hibernate.org\/dtd\/hibernate-configuration-3.0.dtd\"&gt;\n&lt;hibernate-configuration&gt;\n&lt;session-factory&gt;\n\n&lt;property name=<em>\"hibernate.dialect\"<\/em>&gt;\norg.hibernate.dialect.MySQLDialect\n&lt;\/property&gt;\n\n&lt;property name=<em>\"hibernate.connection.driver_class\"<\/em>&gt;\ncom.mysql.jdbc.Driver\n&lt;\/property&gt;\n\n&lt;!-- Assume test is the database name --&gt;\n\n&lt;property name=<em>\"hibernate.connection.url\"<\/em>&gt;\njdbc:mysql:\/\/localhost\/exampledb?serverTimezone=UTC\n&lt;\/property&gt;\n\n&lt;property name=<em>\"hibernate.connection.username\"<\/em>&gt;\nroot\n&lt;\/property&gt;\n\n&lt;property name=<em>\"hibernate.connection.password\"<\/em>&gt;\nroot\n&lt;\/property&gt;\n\n&lt;!-- List of XML mapping files --&gt;\n&lt;mapping resource=<em>\"Customer.hbm.xml\"<\/em> \/&gt;\n\n&lt;\/session-factory&gt;\n&lt;\/hibernate-configuration&gt;<\/pre>\n\n\n\n<p>Finally, we are ready to create the instance of our Customer class and to interact with it. Let&#8217;s create the one, persist, update one of the properties, delete. We will list all the database instances after each of the steps. First of all, we will create a class that will be responsible for all actions on the Customer instances:<\/p>\n\n\n\n<p><strong><em>package edu.hibernate.example;<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import java.util.List;\nimport java.util.Iterator;\n\nimport org.hibernate.HibernateException;\nimport org.hibernate.Session;\nimport org.hibernate.Transaction;\nimport org.hibernate.SessionFactory;\nimport org.hibernate.cfg.Configuration;\n\npublic class CustomerService {\nprivate static SessionFactory factory;\n\npublic CustomerService() {\ntry {\nfactory = new Configuration().configure().buildSessionFactory();\n} catch (Throwable ex) {\nSystem.err.println(\"Failed to create sessionFactory object.\" + ex);\nthrow new ExceptionInInitializerError(ex);\n}\n\n}\n\npublic Integer addCustomer(String firstname, String lastname, String email) {\nSession session = factory.openSession();\nTransaction transaction = null;\nInteger customerID = null;\n\ntry {\ntransaction = session.beginTransaction();\nCustomer customer = new Customer(firstname, lastname, email);\ncustomerID = (Integer) session.save(customer);\ntransaction.commit();\n} catch (HibernateException e) {\nif (transaction != null)\ntransaction.rollback();\ne.printStackTrace();\n} finally {\nsession.close();\n}\nreturn customerID;\n}\n\npublic List listCustomers() {\nSession session = factory.openSession();\nTransaction transaction = null;\nList customers = null;\ntry {\ntransaction = session.beginTransaction();\ncustomers = session.createQuery(\"FROM Customer\").list();\ntransaction.commit();\nreturn customers;\n} catch (HibernateException e) {\nif (transaction != null)\ntransaction.rollback();\ne.printStackTrace();\n} finally {\nsession.close();\n}\nreturn customers;\n}\n\npublic void updateCustomer(Integer CustomerID, String email) {\nSession session = factory.openSession();\nTransaction transaction = null;\n\ntry {\ntransaction = session.beginTransaction();\nCustomer customer = (Customer) session.get(Customer.class, CustomerID);\ncustomer.setEmail(email);\nsession.update(customer);\ntransaction.commit();\n} catch (HibernateException e) {\nif (transaction != null)\ntransaction.rollback();\ne.printStackTrace();\n} finally {\nsession.close();\n}\n}\n\npublic void deleteCustomer(Integer CustomerID) {\nSession session = factory.openSession();\nTransaction transaction = null;\n\ntry {\ntransaction = session.beginTransaction();\nCustomer customer = (Customer) session.get(Customer.class, CustomerID);\nsession.delete(customer);\ntransaction.commit();\n} catch (HibernateException e) {\nif (transaction != null)\ntransaction.rollback();\ne.printStackTrace();\n} finally {\nsession.close();\n}\n}\n}\n<\/pre>\n\n\n\n<p><strong><em>Finally, we got this project hierarchy:<\/em><\/strong><\/p>\n\n\n\n<p><img decoding=\"async\" width=\"332\" height=\"386\" src=\"https:\/\/lh3.googleusercontent.com\/2Z_rrI33s-y7jbjozat0Arl_3pGvoQh8AJ4pYVw3ZkFGJmdMp4iNybWqNdXfV3J47BiZBDWTJATUrqnOBc3VH9pvBG2aNrjR0JcMLYZ2ZwL7VrsXFk6ttQpnJTmOqykFbZzAqShf\" alt=\"\" title=\"\"><\/p>\n\n\n\n<p><strong><em>Here is our main method of the application:<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">package edu.hibernate.example;\n\nimport java.util.Iterator;\nimport java.util.List;\n\npublic class HibernateExample {\n\npublic static void main(String[] args) {\n\n&nbsp; &nbsp; &nbsp; CustomerService customerService = new CustomerService();\n&nbsp; &nbsp; &nbsp; Integer customerID1 = customerService.addCustomer(\"Bob\", \"Lie\", \"bob@gmail.com\");\n&nbsp; &nbsp; &nbsp; System.out.println(\"List of Customers after creation of the new record:\");\n&nbsp; &nbsp; &nbsp; printListCustomers(customerService.listCustomers());\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp; &nbsp; &nbsp; customerService.updateCustomer(customerID1, \"bobLie@gmail.com\");\n&nbsp; &nbsp; &nbsp; System.out.println(\"List of Customers after updating the record:\");\n&nbsp; &nbsp; &nbsp; printListCustomers(customerService.listCustomers());\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp; &nbsp; &nbsp; customerService.deleteCustomer(customerID1);\n&nbsp; &nbsp; &nbsp; System.out.println(\"List of Customers after deleting the record:\"); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp; &nbsp; &nbsp; printListCustomers(customerService.listCustomers());\n\n}\n\nprivate static void printListCustomers(List customers) {\nif(!customers.iterator().hasNext()) {\nSystem.out.println(\"The list is empty!\");\n}\nfor (Iterator iterator = customers.iterator(); iterator.hasNext();) {\nCustomer customer = (Customer) iterator.next();\nSystem.out.print(\"First Name: \" + customer.getFirstName());\nSystem.out.print(\" Last Name: \" + customer.getLastName());\nSystem.out.println(\" Email: \" + customer.getEmail());\n}\n}\n}\n<\/pre>\n\n\n\n<p><strong><em>The output of our application is:<\/em><\/strong><\/p>\n\n\n<p>[box type=&#8221;info&#8221; align=&#8221;&#8221; class=&#8221;&#8221; width=&#8221;&#8221;]List of Customers after creation of the new record:<br>First Name: Bob Last Name: Lie Email: bob@gmail.com<br>List of Customers after updating the record:<br>First Name: Bob Last Name: Lie Email: bobLie@gmail.com<br>List of Customers after deleting the record:<br>The list is empty!<br>[\/box]<\/p>\n\n\n<p>So, we successfully created the Java project and implemented base CRUD operations (create, read, update, delete) with the help of the Hibernate framework and with the use of MySQL database.<\/p>\n\n\n\n<p>We have used the XML mapping file for the transformation. But there is another way to do this. The Hibernate annotations are a new way to do this without the use of the XML file. You can use mixed-method: annotations and XML mapping together.<\/p>\n\n\n\n<p><strong><em>In this case, our Java POJO class will look like this:<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>package<\/strong> edu.hibernate.example;\n\n<strong>import<\/strong> javax.persistence.Column;\n<strong>import<\/strong> javax.persistence.Entity;\n<strong>import<\/strong> javax.persistence.GeneratedValue;\n<strong>import<\/strong> javax.persistence.Id;\n<strong>import<\/strong> javax.persistence.Table;\n\n@Entity\n@Table(name = \"CUSTOMER\")\n<strong>public<\/strong> <strong>class<\/strong> Customer {\n@Id @GeneratedValue\n@Column(name = \"id\")\n<strong>private<\/strong> <strong>int<\/strong> id;\n@Column(name = \"first_name\")\n<strong>private<\/strong> String firstName;\n@Column(name = \"last_name\")\n<strong>private<\/strong> String lastName;\n@Column(name = \"email\")\n<strong>private<\/strong> String email;\n<strong>public<\/strong> Customer (String firstName, String lastName, String email) {\n<strong>super<\/strong>();\n<strong>this<\/strong>.firstName = firstName;\n<strong>this<\/strong>.lastName = lastName;\n<strong>this<\/strong>.email = email;\n}\n<strong>public<\/strong> Customer() {\n}\n<strong>public<\/strong> <strong>int<\/strong> getId() {\n<strong>return<\/strong> id;\n}\n<strong>public<\/strong> <strong>void<\/strong> setId(<strong>int<\/strong> id) {\n<strong>this<\/strong>.id = id;\n}\n<strong>public<\/strong> String getFirstName() {\n<strong>return<\/strong> firstName;\n}\n<strong>public<\/strong> <strong>void<\/strong> setFirstName(String firstName) {\n<strong>this<\/strong>.firstName = firstName;\n}\n<strong>public<\/strong> String getLastName() {\n<strong>return<\/strong> lastName;\n}\n<strong>public<\/strong> <strong>void<\/strong> setLastName(String lastName) {\n<strong>this<\/strong>.lastName = lastName;\n}\n<strong>public<\/strong> String getEmail() {\n<strong>return<\/strong> email;\n}\n<strong>public<\/strong> <strong>void<\/strong> setEmail(String email) {\n<strong>this<\/strong>.email = email;\n}\n}\n<\/pre>\n\n\n\n<p>There are more annotations. There is the way to define one-to-one, one-to-many and many-to-many relationships between classes with annotations too.<\/p>\n\n\n\n<p>We will also need to do small changes inCustomerService class for SessionFactory builder:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>public<\/strong> <strong>class<\/strong> CustomerService {\n<strong>private<\/strong> <strong>static<\/strong> SessionFactory <em>factory<\/em>;\n\n<strong>public<\/strong> CustomerService() {\n<strong>try<\/strong> {\n<em>factory<\/em> = <strong>new<\/strong> AnnotationConfiguration().\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; configure().\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/addPackage(\"edu.hibernate.example\") \/\/add package if used.\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addAnnotatedClass(Customer.<strong>class<\/strong>).\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; buildSessionFactory();\n} <strong>catch<\/strong> (Throwable ex) {\nSystem.<strong><em>err<\/em><\/strong>.println(\"Failed to create sessionFactory object.\" + ex);\n<strong>throw<\/strong> <strong>new<\/strong> ExceptionInInitializerError(ex);\n}\n\n}\n...\n}\n<\/pre>\n\n\n\n<p>Other code in our code wouldn&#8217;t be changed. All the annotations are from <em><strong>javax.persistence package. XML<\/strong><\/em> mappings have greater flexibility, but for portability to other EJB 3 compliant ORM applications, you must use annotations.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s create our first Java application with Hibernate technology.&nbsp; One of the simplest ways is to create a basic Maven project and to add Hibernate dependency to pom.xml. The version of the Hibernate framework can vary: &lt;dependency&gt;&nbsp; &lt;groupId&gt;org.hibernate&lt;\/groupId&gt;&nbsp; &lt;artifactId&gt;hibernate-agroal&lt;\/artifactId&gt;&nbsp; &lt;version&gt;5.4.17.Final&lt;\/version&gt;&nbsp; &lt;type&gt;pom&lt;\/type&gt;&nbsp; &lt;\/dependency&gt;&nbsp; We are going to use the MySQL database. So, you need to make [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3816,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[1007,1008,1009],"class_list":["post-3791","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java-tutorials","tag-hibernate-program","tag-java-application","tag-java-pojo"],"_links":{"self":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/3791","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/comments?post=3791"}],"version-history":[{"count":0,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/3791\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media\/3816"}],"wp:attachment":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media?parent=3791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/categories?post=3791"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/tags?post=3791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}