{"id":739,"date":"2012-11-11T19:48:35","date_gmt":"2012-11-11T19:48:35","guid":{"rendered":"http:\/\/ilias-laptop\/examples\/enterprise-java\/jpa\/find-by-class-in-jpa\/"},"modified":"2019-02-27T14:46:48","modified_gmt":"2019-02-27T12:46:48","slug":"find-by-class-in-jpa","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/","title":{"rendered":"Find by class in JPA"},"content":{"rendered":"<p>This is an example of how to find an object by class in JPA. The Java Persistence API provides Java developers with an object\/relational mapping facility for managing relational data in Java applications.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n<p>Here, we are using JPA to retrieve an object by class, as shown below:<\/p>\n<h3>The FindByClassInJPA class<\/h3>\n<p>In <code>FindByClassInJPA<\/code> we create an <code>EntityManagerFactory<\/code> interface to interact with the entity manager factory for <code>MyPeristenceUnit<\/code>, that is defined in <code>persistence.xml<\/code> file. We create an EntityManager, using the <code>createEntityManager()<\/code> API method. Then, we create new <code>Employee<\/code> objects. The new objects are written to the database, using the <code>persist(java.lang.Object entity)<\/code> API method of <code>EntityManager<\/code>. The <code>getTransaction().begin()<\/code> and <code>getTransaction().commit()<\/code> methods are used before and after the <code>EntityManager<\/code> invokes a method so that a transaction begins and ends. <code>Employee<\/code> objects can be retrieved, using the <code>createQuery(String qlString)<\/code> API method of EntityManager, with an sql String query. Then, using the <code>getResultList()<\/code> of Query to execute a SELECT query that returns all results in a list that is cast to a list of <code>Employee<\/code> objects.<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.snippets.enterprise;\n\nimport java.util.Date;\nimport java.util.List;\n\nimport javax.persistence.EntityManager;\nimport javax.persistence.EntityManagerFactory;\nimport javax.persistence.Persistence;\nimport javax.persistence.Query;\n\npublic class FindByClassInJPA {\n\t\n\t@SuppressWarnings(\"unchecked\")\n\tpublic static void main(String[] args) {\n\t\t\n\t\tEntityManagerFactory emf = Persistence.createEntityManagerFactory(\"MyPersistenceUnit\");\n\t\t\n\t\tEntityManager em = emf.createEntityManager();\n\t\t\n\t\t\/\/ create the employees\n\t\t\n\t\tem.getTransaction().begin();\n\t\t\n\t\tfor (int i = 0; i &lt; 5; i++) {\n\t\t\tEmployee employee = new Employee();\n\t\t\temployee.setName(\"employe_\"+i);\n\t\t\temployee.setSurname(\"surname_\"+i);\n\t\t\temployee.setTitle(\"Engineer_\"+i);\n\t\t\temployee.setCreated(new Date());\n\t\t\tem.persist(employee);\n\t\t}\n\t\t\n\t\tem.getTransaction().commit();\n\t\t\n\t\t\/\/ retrieve the employees\n\t\t\n\t\tem.getTransaction().begin();\n\t\t\n\t\tQuery query = em.createQuery(\"SELECT e FROM Employee e\");\n\t\t\n\t\tList&lt;Employee&gt; employees = (List&lt;Employee&gt;) query.getResultList();\n\t\t\n\t\tif (employees!=null &amp;&amp; employees.size()&gt;0) {\n\t\t\tfor (Employee employee : employees) {\n\t\t\t\tSystem.out.println(employee);\n\t\t\t}\n\t\t}\n\t\t\n\t\tem.getTransaction().commit();\n\t\t\n\t\tem.close();\n\t    emf.close();\n\n\t}\n\n}\n<\/pre>\n<h3>Employee Class<\/h3>\n<p>The <code>Employee<\/code> class is an entity class, annotated with the <code>javax.persistence.Entity<\/code> annotation. It uses the <code>@Id<\/code> annotation to define its id property, and the <code>@GeneratedValue<\/code> annotation with strategy set to <code>GenerationType.AUTO<\/code> so that the id gets auto-generated values.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.snippets.enterprise;\n\nimport java.util.Date;\n\nimport javax.persistence.Entity;\nimport javax.persistence.GeneratedValue;\nimport javax.persistence.GenerationType;\nimport javax.persistence.Id;\n\n@Entity\npublic class Employee {\n\t\n\t@Id\n\t@GeneratedValue(strategy=GenerationType.AUTO)\n\tprivate Long id;\n    private String name;\n    private String surname;\n    private String title;\n    private Date created;\n    \n\tpublic Long getId() {\n\t\treturn id;\n\t}\n\tpublic void setId(Long id) {\n\t\tthis.id = id;\n\t}\n\t\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\tpublic void setName(String name) {\n\t\tthis.name = name;\n\t}\n\t\n\tpublic String getSurname() {\n\t\treturn surname;\n\t}\n\tpublic void setSurname(String surname) {\n\t\tthis.surname = surname;\n\t}\n\t\n\tpublic String getTitle() {\n\t\treturn title;\n\t}\n\tpublic void setTitle(String title) {\n\t\tthis.title = title;\n\t}\n\t\n\tpublic Date getCreated() {\n\t\treturn created;\n\t}\n\tpublic void setCreated(Date created) {\n\t\tthis.created = created;\n\t}\n\t\n\t@Override\n\tpublic String toString() {\n\t\treturn \"Employee [id=\" + id + \", name=\" + name + \", surname=\" + surname\n\t\t\t\t+ \", title=\" + title + \"]\";\n\t}\n\n}\n<\/pre>\n<p><b>persistence.xml<\/b>[ulp id=&#8217;WII99u1JyPvMb8sP&#8217;]<\/p>\n<pre class=\"brush:xml\">&lt;persistence xmlns=\"http:\/\/java.sun.com\/xml\/ns\/persistence\"\n    xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n    xsi:schemaLocation=\"http:\/\/java.sun.com\/xml\/ns\/persistence http:\/\/java.sun.com\/xml\/ns\/persistence\/persistence_2_0.xsd\"\n    version=\"2.0\"&gt;\n\t\n\t&lt;persistence-unit name=\"MyPersistenceUnit\" transaction-type=\"RESOURCE_LOCAL\"&gt;\n\t\t&lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;\/provider&gt;\n\t\t&lt;properties&gt;\n\t\t\t&lt;property name=\"hibernate.dialect\" value=\"org.hibernate.dialect.MySQL5InnoDBDialect\" \/&gt;\n\t\t\t&lt;property name=\"hibernate.hbm2ddl.auto\" value=\"update\" \/&gt;\n\t\t\t&lt;property name=\"hibernate.connection.driver_class\" value=\"com.mysql.jdbc.Driver\" \/&gt;\n\t\t\t&lt;property name=\"hibernate.connection.username\" value=\"jcg\" \/&gt;\n\t\t\t&lt;property name=\"hibernate.connection.password\" value=\"jcg\" \/&gt;\n\t\t\t&lt;property name=\"hibernate.connection.url\" value=\"jdbc:mysql:\/\/localhost\/companydb\" \/&gt;\n\t\t&lt;\/properties&gt;\n\t&lt;\/persistence-unit&gt;\n\t\n&lt;\/persistence&gt;\n<\/pre>\n<p><b>Output:<\/b><\/p>\n<pre style=\"background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;\"><code style=\"color: black; word-wrap: normal;\">Employee [id=1, name=employe_0, surname=surname_0, title=Engineer_0]\nEmployee [id=2, name=employe_1, surname=surname_1, title=Engineer_1]\nEmployee [id=3, name=employe_2, surname=surname_2, title=Engineer_2]\nEmployee [id=4, name=employe_3, surname=surname_3, title=Engineer_3]\nEmployee [id=5, name=employe_4, surname=surname_4, title=Engineer_4]<\/code>\n<\/pre>\n<p>&nbsp;<br \/>\nThis was an example of how to find an object by class in JPA.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is an example of how to find an object by class in JPA. The Java Persistence API provides Java developers with an object\/relational mapping facility for managing relational data in Java applications. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Here, we are using JPA to retrieve an object by class, as &hellip;<\/p>\n","protected":false},"author":6,"featured_media":1240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[198,1028],"class_list":["post-739","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jpa","tag-enterprise-java-2","tag-jpa"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Find by class in JPA - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"This is an example of how to find an object by class in JPA. The Java Persistence API provides Java developers with an object\/relational mapping facility\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Find by class in JPA - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"This is an example of how to find an object by class in JPA. The Java Persistence API provides Java developers with an object\/relational mapping facility\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2012-11-11T19:48:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-02-27T12:46:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Byron Kiourtzoglou\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Byron Kiourtzoglou\" \/>\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:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/\"},\"author\":{\"name\":\"Byron Kiourtzoglou\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/3b111ec1048740c68c9e709ff6240015\"},\"headline\":\"Find by class in JPA\",\"datePublished\":\"2012-11-11T19:48:35+00:00\",\"dateModified\":\"2019-02-27T12:46:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/\"},\"wordCount\":228,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg\",\"keywords\":[\"enterprise java\",\"jpa\"],\"articleSection\":[\"jpa\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/\",\"name\":\"Find by class in JPA - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg\",\"datePublished\":\"2012-11-11T19:48:35+00:00\",\"dateModified\":\"2019-02-27T12:46:48+00:00\",\"description\":\"This is an example of how to find an object by class in JPA. The Java Persistence API provides Java developers with an object\/relational mapping facility\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"jpa\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/jpa\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Find by class in JPA\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/3b111ec1048740c68c9e709ff6240015\",\"name\":\"Byron Kiourtzoglou\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Byron-Kiourtzoglou-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Byron-Kiourtzoglou-96x96.jpg\",\"caption\":\"Byron Kiourtzoglou\"},\"description\":\"Byron is a master software engineer working in the IT and Telecom domains. He is an applications developer in a wide variety of applications\/services. He is currently acting as the team leader and technical architect for a proprietary service creation and integration platform for both the IT and Telecom industries in addition to a in-house big data real-time analytics solution. He is always fascinated by SOA, middleware services and mobile development. Byron is co-founder and Executive Editor at Java Code Geeks.\",\"sameAs\":[\"https:\/\/www.pivotalgamers.com\/\",\"https:\/\/www.linkedin.com\/in\/byron-kiourtzoglou-530ab222\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/byron-kiourtzoglou\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Find by class in JPA - Java Code Geeks","description":"This is an example of how to find an object by class in JPA. The Java Persistence API provides Java developers with an object\/relational mapping facility","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:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/","og_locale":"en_US","og_type":"article","og_title":"Find by class in JPA - Java Code Geeks","og_description":"This is an example of how to find an object by class in JPA. The Java Persistence API provides Java developers with an object\/relational mapping facility","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-11-11T19:48:35+00:00","article_modified_time":"2019-02-27T12:46:48+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg","type":"image\/jpeg"}],"author":"Byron Kiourtzoglou","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Byron Kiourtzoglou","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/"},"author":{"name":"Byron Kiourtzoglou","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/3b111ec1048740c68c9e709ff6240015"},"headline":"Find by class in JPA","datePublished":"2012-11-11T19:48:35+00:00","dateModified":"2019-02-27T12:46:48+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/"},"wordCount":228,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg","keywords":["enterprise java","jpa"],"articleSection":["jpa"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/","name":"Find by class in JPA - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg","datePublished":"2012-11-11T19:48:35+00:00","dateModified":"2019-02-27T12:46:48+00:00","description":"This is an example of how to find an object by class in JPA. The Java Persistence API provides Java developers with an object\/relational mapping facility","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jpa\/find-by-class-in-jpa\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/"},{"@type":"ListItem","position":4,"name":"jpa","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/jpa\/"},{"@type":"ListItem","position":5,"name":"Find by class in JPA"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/3b111ec1048740c68c9e709ff6240015","name":"Byron Kiourtzoglou","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Byron-Kiourtzoglou-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Byron-Kiourtzoglou-96x96.jpg","caption":"Byron Kiourtzoglou"},"description":"Byron is a master software engineer working in the IT and Telecom domains. He is an applications developer in a wide variety of applications\/services. He is currently acting as the team leader and technical architect for a proprietary service creation and integration platform for both the IT and Telecom industries in addition to a in-house big data real-time analytics solution. He is always fascinated by SOA, middleware services and mobile development. Byron is co-founder and Executive Editor at Java Code Geeks.","sameAs":["https:\/\/www.pivotalgamers.com\/","https:\/\/www.linkedin.com\/in\/byron-kiourtzoglou-530ab222"],"url":"https:\/\/examples.javacodegeeks.com\/author\/byron-kiourtzoglou\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/739","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=739"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/739\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1240"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}