{"id":1298,"date":"2022-08-24T18:47:03","date_gmt":"2022-12-15T15:58:11","guid":{"rendered":"https:\/\/www.silicloud.com\/blog\/uncategorized\/example-of-a-hibernate-sql-query-in-its-native-form\/"},"modified":"2024-03-12T15:28:14","modified_gmt":"2024-03-12T15:28:14","slug":"example-of-a-hibernate-sql-query-in-its-native-form","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/","title":{"rendered":"Example of a Hibernate SQL Query in its native form."},"content":{"rendered":"<p>In this tutorial, we will be exploring the Hibernate Native SQL Query with examples. Previously, we discussed Hibernate Query Language and Hibernate Criteria, but now it&#8217;s time to delve into Hibernate Native SQL queries.<\/p>\n<h2>SQL Query for Hibernate<\/h2>\n<p>Hibernate offers the ability to run native SQL queries using the SQLQuery object. This feature proves useful when executing database-specific queries that are not supported by Hibernate API, such as query hints or the CONNECT keyword in Oracle Database. However, it is not recommended to use Hibernate SQL queries in typical scenarios because it forfeits the advantages of Hibernate association and the first level cache. To better understand the tables and their corresponding model classes mapping, please refer to the HQL example which utilizes the <a href=\"https:\/\/www.mysql.com\/\">MySQL<\/a> database setup.<\/p>\n<h3>An illustration showcasing how to utilize Hibernate Native SQL.<\/h3>\n<p>To utilize Hibernate Native SQL Query, we employ Session.createSQLQuery(String query) to produce the SQLQuery object and execute it. As an illustration, if the aim is to retrieve all the entries from the Employee table, it can be accomplished using the subsequent code.<\/p>\n<pre class=\"post-pre\"><code>\/\/ Prep work\r\nSessionFactory sessionFactory = HibernateUtil.getSessionFactory();\r\nSession session = sessionFactory.getCurrentSession();\r\n\r\n\/\/ Get All Employees\r\nTransaction tx = session.beginTransaction();\r\nSQLQuery query = session.createSQLQuery(\"select emp_id, emp_name, emp_salary from Employee\");\r\nList&lt;Object[]&gt; rows = query.list();\r\nfor(Object[] row : rows){\r\n\tEmployee emp = new Employee();\r\n\temp.setId(Long.parseLong(row[0].toString()));\r\n\temp.setName(row[1].toString());\r\n\temp.setSalary(Double.parseDouble(row[2].toString()));\r\n\tSystem.out.println(emp);\r\n}\r\n<\/code><\/pre>\n<p>When we run the code using the given data setup, it generates the output stated below.<\/p>\n<pre class=\"post-pre\"><code>Hibernate: select emp_id, emp_name, emp_salary from Employee\r\nId= 1, Name= Pankaj, Salary= 100.0, {Address= null}\r\nId= 2, Name= David, Salary= 200.0, {Address= null}\r\nId= 3, Name= Lisa, Salary= 300.0, {Address= null}\r\nId= 4, Name= Jack, Salary= 400.0, {Address= null}\r\n<\/code><\/pre>\n<p>Observe that the list() method produces a List of Object array. We must explicitly convert them to double, long, etc. The toString() methods of our Employee and Address classes are implemented as follows.<\/p>\n<pre class=\"post-pre\"><code>@Override\r\npublic String toString() {\r\n\treturn \"Id= \" + id + \", Name= \" + name + \", Salary= \" + salary\r\n\t\t\t+ \", {Address= \" + address + \"}\";\r\n}\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>@Override\r\npublic String toString() {\r\n\treturn \"AddressLine1= \" + addressLine1 + \", City=\" + city\r\n\t\t\t+ \", Zipcode=\" + zipcode;\r\n}\r\n<\/code><\/pre>\n<p>Please observe that our query does not retrieve any Address information, whereas if we utilize the HQL query &#8220;from Employee&#8221;, it also retrieves the data from the related table.<\/p>\n<h3>The &#8220;addScalar&#8221; method in Hibernate SQL Query<\/h3>\n<p>From an efficiency standpoint, Hibernate employs ResultSetMetadata to infer the column types returned by the query. To specify the data type of the column, we can make use of the addScalar() method. Nonetheless, the data will still be received as an array of Object.<\/p>\n<pre class=\"post-pre\"><code>\/\/Get All Employees - addScalar example\r\nquery = session.createSQLQuery(\"select emp_id, emp_name, emp_salary from Employee\")\r\n\t\t.addScalar(\"emp_id\", new LongType())\r\n\t\t.addScalar(\"emp_name\", new StringType())\r\n\t\t.addScalar(\"emp_salary\", new DoubleType());\r\nrows = query.list();\r\nfor(Object[] row : rows){\r\n\tEmployee emp = new Employee();\r\n\temp.setId(Long.parseLong(row[0].toString()));\r\n\temp.setName(row[1].toString());\r\n\temp.setSalary(Double.parseDouble(row[2].toString()));\r\n\tSystem.out.println(emp);\r\n}\r\n<\/code><\/pre>\n<p>When the data is large, we can expect a slight enhancement in performance, even though the end result will remain unchanged.<\/p>\n<h3>Multiple Tables with Hibernate Native SQL<\/h3>\n<p>If we want to retrieve information from both the Employee and Address tables, we can easily create an SQL query to accomplish this and then parse the resulting set of data.<\/p>\n<pre class=\"post-pre\"><code>query = session.createSQLQuery(\"select e.emp_id, emp_name, emp_salary,address_line1, city, \r\n\tzipcode from Employee e, Address a where a.emp_id=e.emp_id\");\r\nrows = query.list();\r\nfor(Object[] row : rows){\r\n\tEmployee emp = new Employee();\r\n\temp.setId(Long.parseLong(row[0].toString()));\r\n\temp.setName(row[1].toString());\r\n\temp.setSalary(Double.parseDouble(row[2].toString()));\r\n\tAddress address = new Address();\r\n\taddress.setAddressLine1(row[3].toString());\r\n\taddress.setCity(row[4].toString());\r\n\taddress.setZipcode(row[5].toString());\r\n\temp.setAddress(address);\r\n\tSystem.out.println(emp);\r\n}\r\n<\/code><\/pre>\n<p>The output generated for the given code will be as shown below.<\/p>\n<pre class=\"post-pre\"><code>Hibernate: select e.emp_id, emp_name, emp_salary,address_line1, city, zipcode from Employee e, Address a where a.emp_id=e.emp_id\r\nId= 1, Name= Pankaj, Salary= 100.0, {Address= AddressLine1= Albany Dr, City=San Jose, Zipcode=95129}\r\nId= 2, Name= David, Salary= 200.0, {Address= AddressLine1= Arques Ave, City=Santa Clara, Zipcode=95051}\r\nId= 3, Name= Lisa, Salary= 300.0, {Address= AddressLine1= BTM 1st Stage, City=Bangalore, Zipcode=560100}\r\nId= 4, Name= Jack, Salary= 400.0, {Address= AddressLine1= City Centre, City=New Delhi, Zipcode=100100}\r\n<\/code><\/pre>\n<h3>Using Hibernate&#8217;s native SQL entity and join feature.<\/h3>\n<p>We can retrieve the data from an associated table using table joins by utilizing the addEntity() and addJoin() methods. For instance, we can also obtain the aforementioned data in the following manner.<\/p>\n<pre class=\"post-pre\"><code>\/\/Join example with addEntity and addJoin\r\nquery = session.createSQLQuery(\"select {e.*}, {a.*} from Employee e join Address a ON e.emp_id=a.emp_id\")\r\n\t\t.addEntity(\"e\",Employee.class)\r\n\t\t.addJoin(\"a\",\"e.address\");\r\nrows = query.list();\r\nfor (Object[] row : rows) {\r\n    for(Object obj : row) {\r\n    \tSystem.out.print(obj + \"::\");\r\n    }\r\n    System.out.println(\"\\n\");\r\n}\r\n\/\/Above join returns both Employee and Address Objects in the array\r\nfor (Object[] row : rows) {\r\n\tEmployee e = (Employee) row[0];\r\n\tSystem.out.println(\"Employee Info::\"+e);\r\n\tAddress a = (Address) row[1];\r\n\tSystem.out.println(\"Address Info::\"+a);\r\n}\r\n<\/code><\/pre>\n<p>{[aliasname].*} is utilized to retrieve all attributes of an entity. When we incorporate addEntity() and addJoin() in join queries as demonstrated, it returns both the objects. The output generated by the code mentioned above appears as follows.<\/p>\n<pre class=\"post-pre\"><code>Hibernate: select e.emp_id as emp_id1_1_0_, e.emp_name as emp_name2_1_0_, e.emp_salary as emp_sala3_1_0_, a.emp_id as emp_id1_0_1_, a.address_line1 as address_2_0_1_, a.city as city3_0_1_, a.zipcode as zipcode4_0_1_ from Employee e join Address a ON e.emp_id=a.emp_id\r\nId= 1, Name= Pankaj, Salary= 100.0, {Address= AddressLine1= Albany Dr, City=San Jose, Zipcode=95129}::AddressLine1= Albany Dr, City=San Jose, Zipcode=95129::\r\n\r\nId= 2, Name= David, Salary= 200.0, {Address= AddressLine1= Arques Ave, City=Santa Clara, Zipcode=95051}::AddressLine1= Arques Ave, City=Santa Clara, Zipcode=95051::\r\n\r\nId= 3, Name= Lisa, Salary= 300.0, {Address= AddressLine1= BTM 1st Stage, City=Bangalore, Zipcode=560100}::AddressLine1= BTM 1st Stage, City=Bangalore, Zipcode=560100::\r\n\r\nId= 4, Name= Jack, Salary= 400.0, {Address= AddressLine1= City Centre, City=New Delhi, Zipcode=100100}::AddressLine1= City Centre, City=New Delhi, Zipcode=100100::\r\n\r\nEmployee Info::Id= 1, Name= Pankaj, Salary= 100.0, {Address= AddressLine1= Albany Dr, City=San Jose, Zipcode=95129}\r\nAddress Info::AddressLine1= Albany Dr, City=San Jose, Zipcode=95129\r\nEmployee Info::Id= 2, Name= David, Salary= 200.0, {Address= AddressLine1= Arques Ave, City=Santa Clara, Zipcode=95051}\r\nAddress Info::AddressLine1= Arques Ave, City=Santa Clara, Zipcode=95051\r\nEmployee Info::Id= 3, Name= Lisa, Salary= 300.0, {Address= AddressLine1= BTM 1st Stage, City=Bangalore, Zipcode=560100}\r\nAddress Info::AddressLine1= BTM 1st Stage, City=Bangalore, Zipcode=560100\r\nEmployee Info::Id= 4, Name= Jack, Salary= 400.0, {Address= AddressLine1= City Centre, City=New Delhi, Zipcode=100100}\r\nAddress Info::AddressLine1= City Centre, City=New Delhi, Zipcode=100100\r\n<\/code><\/pre>\n<p>You can execute both queries in the mysql client and observe that the resulting output is identical.<\/p>\n<pre class=\"post-pre\"><code>mysql&gt; select e.emp_id as emp_id1_1_0_, e.emp_name as emp_name2_1_0_, e.emp_salary as emp_sala3_1_0_, a.emp_id as emp_id1_0_1_, a.address_line1 as address_2_0_1_, a.city as city3_0_1_, a.zipcode as zipcode4_0_1_ from Employee e join Address a ON e.emp_id=a.emp_id;\r\n+--------------+----------------+----------------+--------------+----------------+-------------+---------------+\r\n| emp_id1_1_0_ | emp_name2_1_0_ | emp_sala3_1_0_ | emp_id1_0_1_ | address_2_0_1_ | city3_0_1_  | zipcode4_0_1_ |\r\n+--------------+----------------+----------------+--------------+----------------+-------------+---------------+\r\n|            1 | Pankaj         |            100 |            1 | Albany Dr      | San Jose    | 95129         |\r\n|            2 | David          |            200 |            2 | Arques Ave     | Santa Clara | 95051         |\r\n|            3 | Lisa           |            300 |            3 | BTM 1st Stage  | Bangalore   | 560100        |\r\n|            4 | Jack           |            400 |            4 | City Centre    | New Delhi   | 100100        |\r\n+--------------+----------------+----------------+--------------+----------------+-------------+---------------+\r\n4 rows in set (0.00 sec)\r\n\r\nmysql&gt; select e.emp_id, emp_name, emp_salary,address_line1, city, zipcode from Employee e, Address a where a.emp_id=e.emp_id;\r\n+--------+----------+------------+---------------+-------------+---------+\r\n| emp_id | emp_name | emp_salary | address_line1 | city        | zipcode |\r\n+--------+----------+------------+---------------+-------------+---------+\r\n|      1 | Pankaj   |        100 | Albany Dr     | San Jose    | 95129   |\r\n|      2 | David    |        200 | Arques Ave    | Santa Clara | 95051   |\r\n|      3 | Lisa     |        300 | BTM 1st Stage | Bangalore   | 560100  |\r\n|      4 | Jack     |        400 | City Centre   | New Delhi   | 100100  |\r\n+--------+----------+------------+---------------+-------------+---------+\r\n4 rows in set (0.00 sec)\r\n\r\nmysql&gt; \r\n<\/code><\/pre>\n<h3>Native SQL Query in Hibernate with Parameters.<\/h3>\n<p>Similar to JDBC PreparedStatement, Hibernate SQL queries also allow us to pass parameters. We can set these parameters using either the name or the index, as demonstrated in the example below.<\/p>\n<pre class=\"post-pre\"><code>query = session\r\n\t\t.createSQLQuery(\"select emp_id, emp_name, emp_salary from Employee where emp_id = ?\");\r\nList&lt;Object[]&gt; empData = query.setLong(0, 1L).list();\r\nfor (Object[] row : empData) {\r\n\tEmployee emp = new Employee();\r\n\temp.setId(Long.parseLong(row[0].toString()));\r\n\temp.setName(row[1].toString());\r\n\temp.setSalary(Double.parseDouble(row[2].toString()));\r\n\tSystem.out.println(emp);\r\n}\r\n\r\nquery = session\r\n\t\t.createSQLQuery(\"select emp_id, emp_name, emp_salary from Employee where emp_id = :id\");\r\nempData = query.setLong(\"id\", 2L).list();\r\nfor (Object[] row : empData) {\r\n\tEmployee emp = new Employee();\r\n\temp.setId(Long.parseLong(row[0].toString()));\r\n\temp.setName(row[1].toString());\r\n\temp.setSalary(Double.parseDouble(row[2].toString()));\r\n\tSystem.out.println(emp);\r\n}\r\n<\/code><\/pre>\n<p>The code above will generate the output.<\/p>\n<pre class=\"post-pre\"><code>Hibernate: select emp_id, emp_name, emp_salary from Employee where emp_id = ?\r\nId= 1, Name= Pankaj, Salary= 100.0, {Address= null}\r\nHibernate: select emp_id, emp_name, emp_salary from Employee where emp_id = ?\r\nId= 2, Name= David, Salary= 200.0, {Address= null}\r\n<\/code><\/pre>\n<p>You should refrain from using Hibernate SQL Query unless you have a requirement to run queries specific to a particular database. That wraps up the brief introduction of Hibernate SQL Query.<\/p>\n<p>&nbsp;<\/p>\n<p>More tutorials<\/p>\n<p><a class=\"LinkSuggestion__Link-sc-1gewdgc-4 cLBplk\" href=\"https:\/\/www.silicloud.com\/blog\/tutorial-on-hibernate-tomcat-jndi-datasource\/\" target=\"_blank\" rel=\"noopener\">Tutorial on how to set up a Hibernate Tomcat JNDI DataSource.<span class=\"sc-gswNZR eASTkv\">(Opens in a new browser tab)<\/span><\/a><\/p>\n<p><a class=\"LinkSuggestion__Link-sc-1gewdgc-4 cLBplk\" href=\"https:\/\/www.silicloud.com\/blog\/learning-roadmap-for-aspiring-data-analysts-in-2022\/\" target=\"_blank\" rel=\"noopener\">Learning Roadmap for Aspiring Data Analysts in 2022<span class=\"sc-gswNZR eASTkv\">(Opens in a new browser tab)<\/span><\/a><\/p>\n<p><a class=\"LinkSuggestion__Link-sc-1gewdgc-4 cLBplk\" href=\"https:\/\/www.silicloud.com\/blog\/the-objectoutputstream-in-java\/\" target=\"_blank\" rel=\"noopener\">the ObjectOutputStream in Java<span class=\"sc-gswNZR eASTkv\">(Opens in a new browser tab)<\/span><\/a><\/p>\n<p><a class=\"LinkSuggestion__Link-sc-1gewdgc-4 cLBplk\" href=\"https:\/\/www.silicloud.com\/blog\/one-option-for-paraphrasing-java-thread-join-example-natively-could-be-example-of-using-the-java-thread-join-method\/\" target=\"_blank\" rel=\"noopener\">Java Thread Join method<span class=\"sc-gswNZR eASTkv\">(Opens in a new browser tab)<\/span><\/a><\/p>\n<p><a class=\"LinkSuggestion__Link-sc-1gewdgc-4 cLBplk\" href=\"https:\/\/www.silicloud.com\/blog\/common-errors-that-occur-when-using-nginx-for-connections\/\" target=\"_blank\" rel=\"noopener\">Common errors that occur when using Nginx for connections.<span class=\"sc-gswNZR eASTkv\">(Opens in a new browser tab)<\/span><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will be exploring the Hibernate Native SQL Query with examples. Previously, we discussed Hibernate Query Language and Hibernate Criteria, but now it&#8217;s time to delve into Hibernate Native SQL queries. SQL Query for Hibernate Hibernate offers the ability to run native SQL queries using the SQLQuery object. This feature proves useful [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-1298","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Example of a Hibernate SQL Query in its native form. - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"Hibernate offers the ability to run native SQL queries using the SQLQuery object. This feature proves useful when executing database-specific\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Example of a Hibernate SQL Query in its native form.\" \/>\n<meta property=\"og:description\" content=\"Hibernate offers the ability to run native SQL queries using the SQLQuery object. This feature proves useful when executing database-specific\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-15T15:58:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-12T15:28:14+00:00\" \/>\n<meta name=\"author\" content=\"Liam\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:site\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Liam\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/\"},\"author\":{\"name\":\"Liam\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/23786905eb7b377f45ddb01c17da7671\"},\"headline\":\"Example of a Hibernate SQL Query in its native form.\",\"datePublished\":\"2022-12-15T15:58:11+00:00\",\"dateModified\":\"2024-03-12T15:28:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/\"},\"wordCount\":630,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/\",\"name\":\"Example of a Hibernate SQL Query in its native form. - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\"},\"datePublished\":\"2022-12-15T15:58:11+00:00\",\"dateModified\":\"2024-03-12T15:28:14+00:00\",\"description\":\"Hibernate offers the ability to run native SQL queries using the SQLQuery object. This feature proves useful when executing database-specific\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.silicloud.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Example of a Hibernate SQL Query in its native form.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"name\":\"Silicon Cloud Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\",\"name\":\"Silicon Cloud Blog\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"contentUrl\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"width\":1024,\"height\":1024,\"caption\":\"Silicon Cloud Blog\"},\"image\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\",\"https:\/\/twitter.com\/SiliCloudGlobal\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/23786905eb7b377f45ddb01c17da7671\",\"name\":\"Liam\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8d37ed3e7f770dde8bf069ba0b4298688028c3abaacf1131742fc1352d174ebd?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8d37ed3e7f770dde8bf069ba0b4298688028c3abaacf1131742fc1352d174ebd?s=96&d=mm&r=g\",\"caption\":\"Liam\"},\"sameAs\":[\"http:\/\/Wilson\"],\"url\":\"https:\/\/www.silicloud.com\/blog\/author\/liamwilson\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Example of a Hibernate SQL Query in its native form. - Blog - Silicon Cloud","description":"Hibernate offers the ability to run native SQL queries using the SQLQuery object. This feature proves useful when executing database-specific","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/","og_locale":"en_US","og_type":"article","og_title":"Example of a Hibernate SQL Query in its native form.","og_description":"Hibernate offers the ability to run native SQL queries using the SQLQuery object. This feature proves useful when executing database-specific","og_url":"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/","og_site_name":"Blog - Silicon Cloud","article_publisher":"https:\/\/www.facebook.com\/SiliCloudGlobal\/","article_published_time":"2022-12-15T15:58:11+00:00","article_modified_time":"2024-03-12T15:28:14+00:00","author":"Liam","twitter_card":"summary_large_image","twitter_creator":"@SiliCloudGlobal","twitter_site":"@SiliCloudGlobal","twitter_misc":{"Written by":"Liam","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/#article","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/"},"author":{"name":"Liam","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/23786905eb7b377f45ddb01c17da7671"},"headline":"Example of a Hibernate SQL Query in its native form.","datePublished":"2022-12-15T15:58:11+00:00","dateModified":"2024-03-12T15:28:14+00:00","mainEntityOfPage":{"@id":"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/"},"wordCount":630,"commentCount":0,"publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/","url":"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/","name":"Example of a Hibernate SQL Query in its native form. - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/#website"},"datePublished":"2022-12-15T15:58:11+00:00","dateModified":"2024-03-12T15:28:14+00:00","description":"Hibernate offers the ability to run native SQL queries using the SQLQuery object. This feature proves useful when executing database-specific","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/blog\/example-of-a-hibernate-sql-query-in-its-native-form\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.silicloud.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Example of a Hibernate SQL Query in its native form."}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/blog\/#website","url":"https:\/\/www.silicloud.com\/blog\/","name":"Silicon Cloud Blog","description":"","publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.silicloud.com\/blog\/#organization","name":"Silicon Cloud Blog","url":"https:\/\/www.silicloud.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","contentUrl":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","width":1024,"height":1024,"caption":"Silicon Cloud Blog"},"image":{"@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/SiliCloudGlobal\/","https:\/\/twitter.com\/SiliCloudGlobal"]},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/23786905eb7b377f45ddb01c17da7671","name":"Liam","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8d37ed3e7f770dde8bf069ba0b4298688028c3abaacf1131742fc1352d174ebd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8d37ed3e7f770dde8bf069ba0b4298688028c3abaacf1131742fc1352d174ebd?s=96&d=mm&r=g","caption":"Liam"},"sameAs":["http:\/\/Wilson"],"url":"https:\/\/www.silicloud.com\/blog\/author\/liamwilson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/1298","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/comments?post=1298"}],"version-history":[{"count":0,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/1298\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/media?parent=1298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/categories?post=1298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/tags?post=1298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}