{"id":594,"date":"2004-04-28T10:28:26","date_gmt":"2004-04-28T14:28:26","guid":{"rendered":"http:\/\/wordpress.cephas.net\/?p=594"},"modified":"2004-04-28T10:28:26","modified_gmt":"2004-04-28T14:28:26","slug":"hibernate-non-object-retrieval","status":"publish","type":"post","link":"https:\/\/cephas.net\/blog\/2004\/04\/28\/hibernate-non-object-retrieval\/","title":{"rendered":"Hibernate: Non object retrieval"},"content":{"rendered":"<p><a href=\"http:\/\/www.hibernate.org\/\">Hibernate<\/a> has significantly reduced the amount of time I&#8217;ve spent on the writing and maintaining SQL in the applications I&#8217;m working on. Because it exists to map data from Java classes to database tables and back, there aren&#8217;t alot of examples on the site if you need to get non object data out of the database (for instance if you&#8217;re doing reporting on the existing data).  That&#8217;s not to say that it&#8217;s not possible! Given a <a href=\"http:\/\/www.hibernate.org\/hib_docs\/api\/net\/sf\/hibernate\/Query.html\">Query<\/a> object, call the <a href=\"http:\/\/www.hibernate.org\/hib_docs\/api\/net\/sf\/hibernate\/Query.html#list()\">list()<\/a> method and then iterate over the resulting <a href=\"http:\/\/java.sun.com\/j2se\/1.3\/docs\/api\/java\/util\/List.html\">List<\/a>.  Calling the <a href=\"http:\/\/java.sun.com\/j2se\/1.3\/docs\/api\/java\/util\/List.html#get(int)\">get()<\/a> method on the list results in an array of Objects (which is analogous to a row returned from a resultset).  Then you&#8217;ll just need to retrieve the appropriate element of the array given your SQL query (where the order of the items in your &#8216;SELECT ..&#8217; SQL query determines the order in which the objects are returned in the Object[]).<br \/>\n<code><br \/>\n\/\/ .. code to create a Query object<br \/>\nList list = q.list();<br \/>\nfor (int i=0; i<br \/>\nIf you're having trouble finding out the Java type of the element in a row, I've found <a href=\"http:\/\/www.hibernate.org\/190.html\">Hibern8IDE<\/a> to be an excellent help in running, testing and debugging Hibernate queries.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hibernate has significantly reduced the amount of time I&#8217;ve spent on the writing and maintaining SQL in the applications I&#8217;m working on. Because it exists to map data from Java classes to database tables and back, there aren&#8217;t alot of examples on the site if you need to get non object data out of the &hellip; <a href=\"https:\/\/cephas.net\/blog\/2004\/04\/28\/hibernate-non-object-retrieval\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Hibernate: Non object retrieval<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,4,2],"tags":[],"_links":{"self":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/594"}],"collection":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/comments?post=594"}],"version-history":[{"count":0,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/594\/revisions"}],"wp:attachment":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/media?parent=594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/categories?post=594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/tags?post=594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}