{"id":8,"date":"2013-07-02T16:32:24","date_gmt":"2013-07-02T14:32:24","guid":{"rendered":"http:\/\/itblog.inginea.eu\/?p=8"},"modified":"2016-10-24T09:55:27","modified_gmt":"2016-10-24T07:55:27","slug":"deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api","status":"publish","type":"post","link":"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/","title":{"rendered":"Deproxy a lazily loaded JPA reference (using standard Java and JPA API)"},"content":{"rendered":"<p>When tried to tune our near-production application, we came to problem when a single entity reference When tried to tune our near-production application, we came to problem when a single entity reference (not a collection) is loaded lazily. We used inheritance with this entity and hibernate JPA provider (as probably any other provider) inserts a proxy object into referencing entity instead of reference to real object loaded from database (as it is not yet loaded).<\/p>\n<p>We came to a problem because we were casting super class to subclasses using instanceof. The problem is that proxy class is already a subclass and cannot be cast to a sibling class. It is a proxy only to super class instance, but it&#8217;s not possible to access methods of superclasses directly. The proxy never gets converted to real subclass. The problem is specified <a href=\"http:\/\/jwyseur.blogspot.sk\/2009\/06\/casting-hibernate-proxies-to-subclasses.html\" target=\"_blank\">here<\/a>, <a href=\"http:\/\/stackoverflow.com\/questions\/2216547\/converting-hibernate-proxy-to-real-object\/17420667#17420667\" target=\"_blank\">here<\/a> and <a href=\"http:\/\/bmchild.blogspot.sk\/2013\/03\/hibernate-proxy-cast-to-entity-class.html\" target=\"_blank\">here<\/a>. All described solutions depend on hibernate non-standard API to retrieve deproxied instance.<\/p>\n<p>However, after lots of thinking&#8230;<\/p>\n<p>&#8230; I found a solution to deproxy a class using standard Java and JPA API. Tested with hibernate, but does not require hibernate as a dependency and should work with all JPA providers.<\/p>\n<p>Only one requirement &#8211; its necessary to modify parent class (Address) and add a simple helper method.<\/p>\n<p>General idea: add helper method to parent class which returns itself. when method called on proxy, it will forward the call to real instance and return this real instance.<\/p>\n<p>Implementation is a little bit more complex, as hibernate recognizes that proxied class returns itself and still returns proxy instead of real instance. Workaround is to wrap returned instance into a simple wrapper class, which has different class type than the real instance.<\/p>\n<p>In code:<\/p>\n<pre class=\"lang:java decode:true \">class Address {\r\n  public AddressWrapper getWrappedSelf() {\r\n    return new AddressWrapper(this);\r\n  }\r\n...\r\n}\r\n\r\nclass AddressWrapper {\r\n  private Address wrappedAddress;\r\n...\r\n}\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>To cast Address proxy to real subclass, use following:<\/p>\n<pre class=\"lang:java decode:true\">Address address = dao.getSomeAddress(...);\r\nAddress deproxiedAddress = address.getWrappedSelf().getWrappedAddress();\r\nif (deproxiedAddress instanceof WorkAddress) {\r\n  WorkAddress workAddress = (WorkAddress)deproxiedAddress;\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When tried to tune our near-production application, we came to problem when a single entity reference When tried to tune our near-production application, we came to problem when a single entity reference (not a collection) is loaded lazily. We used inheritance with this entity and hibernate JPA provider (as probably any other provider) inserts a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[64],"tags":[9,10],"series":[],"class_list":["post-8","post","type-post","status-publish","format-standard","hentry","category-java","tag-jpa","tag-lazy-loading"],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Deproxy a lazily loaded JPA reference (using standard Java and JPA API) - .Lost in Coding<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Deproxy a lazily loaded JPA reference (using standard Java and JPA API) - .Lost in Coding\" \/>\n<meta property=\"og:description\" content=\"When tried to tune our near-production application, we came to problem when a single entity reference When tried to tune our near-production application, we came to problem when a single entity reference (not a collection) is loaded lazily. We used inheritance with this entity and hibernate JPA provider (as probably any other provider) inserts a [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/\" \/>\n<meta property=\"og:site_name\" content=\".Lost in Coding\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ondrej.mihalyi\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/ondrej.mihalyi\" \/>\n<meta property=\"article:published_time\" content=\"2013-07-02T14:32:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-10-24T07:55:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2021\/09\/duke-CloudSurf-small-e1637277171314.png?fit=300%2C202&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"202\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ondro Mih\u00e1lyi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/OndroMih\" \/>\n<meta name=\"twitter:site\" content=\"@OndroMih\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ondro Mih\u00e1lyi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/\"},\"author\":{\"name\":\"Ondro Mih\u00e1lyi\",\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616\"},\"headline\":\"Deproxy a lazily loaded JPA reference (using standard Java and JPA API)\",\"datePublished\":\"2013-07-02T14:32:24+00:00\",\"dateModified\":\"2016-10-24T07:55:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/\"},\"wordCount\":307,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616\"},\"keywords\":[\"JPA\",\"Lazy-Loading\"],\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/\",\"url\":\"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/\",\"name\":\"Deproxy a lazily loaded JPA reference (using standard Java and JPA API) - .Lost in Coding\",\"isPartOf\":{\"@id\":\"https:\/\/ondro.inginea.eu\/#website\"},\"datePublished\":\"2013-07-02T14:32:24+00:00\",\"dateModified\":\"2016-10-24T07:55:27+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/ondro.inginea.eu\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Deproxy a lazily loaded JPA reference (using standard Java and JPA API)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ondro.inginea.eu\/#website\",\"url\":\"https:\/\/ondro.inginea.eu\/\",\"name\":\".Lost in Coding\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ondro.inginea.eu\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616\",\"name\":\"Ondro Mih\u00e1lyi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/i2.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2017\/08\/fotoOMsquare3x300.jpg?fit=300%2C300&ssl=1\",\"contentUrl\":\"https:\/\/i2.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2017\/08\/fotoOMsquare3x300.jpg?fit=300%2C300&ssl=1\",\"width\":300,\"height\":300,\"caption\":\"Ondro Mih\u00e1lyi\"},\"logo\":{\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/image\/\"},\"description\":\"Ondro is a software developer and consultant specializing in combining standard and proven tools to solve new and challenging problems. He's been developing in Java for over 10 years. He\u2019s worked for clients like Payara, LottoLand, Uniqa and others. He has co-founded OmniFish, where he works as a director and Jakarta EE expert. He\u2019s passionate about helping his clients and the wider Java community with their projects based on Jakarta EE and similar technologies. As an experienced Java developer and instructor, he's helped companies build and educate their development teams and improve their development processes. He's a core member of several opensource projects and Jakarta EE specification projects. He\u2019s a frequent conference speaker, leader of the Czech JUG and a Java Champion. Ondro is a regular conference speaker at international conferences. Since 2016, he's presented at the following conferences: \u2022 FOSDEM, Brussels, Belgium 2023) \u2022 JChampionsConf, Online (year 2023) \u2022 EclipseCon, Germany (year 2022) \u2022 GeeCon, Prague, Czechia (years 2016, 2019, 2022) \u2022 JavaLand, Bruehl, Germany (years 2018, 2021) \u2022 JFokus, Stockholm, Sweden (year 2019) \u2022 Devops Con, Munich, Germany (year 2019) \u2022 Oracle CodeOne, San Francisco, USA (years 2018, 2019) \u2022 Devoxx, Antwerp, Belgium (year 2018) \u2022 JPrime, Sofia, Bulgaria (years 2017, 2018) \u2022 Java2Days, Sofia, Bulgaria (years 2016, 2018) \u2022 EclipseCon, France (year 2018) \u2022 JavaOne, San Francisco, USA (years 2016, 2017) \u2022 Oracle Code, Prague, Czechia (year 2017) \u2022 Devoxx, London, UK (year 2017) \u2022 GeeCon, Krakow, Poland (year 2017) \u2022 W-JAX, Munich, Germany (years 2016, 2017) \u2022 Bed-Con, Berlin, Germany (year 2017) \u2022 Oredev, Malmo, Sweden (year 2017) \u2022 Devoxx, Casablanca, Morocco (year 2017) \u2022 Java Developer Days, Krakow, Poland (year 2016)\",\"sameAs\":[\"https:\/\/www.facebook.com\/ondrej.mihalyi\",\"https:\/\/cz.linkedin.com\/in\/mihalyiondrej\",\"https:\/\/twitter.com\/https:\/\/twitter.com\/OndroMih\"],\"url\":\"https:\/\/ondro.inginea.eu\/index.php\/author\/ondrejm\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Deproxy a lazily loaded JPA reference (using standard Java and JPA API) - .Lost in Coding","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:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/","og_locale":"en_US","og_type":"article","og_title":"Deproxy a lazily loaded JPA reference (using standard Java and JPA API) - .Lost in Coding","og_description":"When tried to tune our near-production application, we came to problem when a single entity reference When tried to tune our near-production application, we came to problem when a single entity reference (not a collection) is loaded lazily. We used inheritance with this entity and hibernate JPA provider (as probably any other provider) inserts a [&hellip;]","og_url":"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/","og_site_name":".Lost in Coding","article_publisher":"https:\/\/www.facebook.com\/ondrej.mihalyi","article_author":"https:\/\/www.facebook.com\/ondrej.mihalyi","article_published_time":"2013-07-02T14:32:24+00:00","article_modified_time":"2016-10-24T07:55:27+00:00","og_image":[{"width":300,"height":202,"url":"https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2021\/09\/duke-CloudSurf-small-e1637277171314.png?fit=300%2C202&ssl=1","type":"image\/png"}],"author":"Ondro Mih\u00e1lyi","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/OndroMih","twitter_site":"@OndroMih","twitter_misc":{"Written by":"Ondro Mih\u00e1lyi","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/#article","isPartOf":{"@id":"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/"},"author":{"name":"Ondro Mih\u00e1lyi","@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616"},"headline":"Deproxy a lazily loaded JPA reference (using standard Java and JPA API)","datePublished":"2013-07-02T14:32:24+00:00","dateModified":"2016-10-24T07:55:27+00:00","mainEntityOfPage":{"@id":"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/"},"wordCount":307,"commentCount":0,"publisher":{"@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616"},"keywords":["JPA","Lazy-Loading"],"articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/","url":"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/","name":"Deproxy a lazily loaded JPA reference (using standard Java and JPA API) - .Lost in Coding","isPartOf":{"@id":"https:\/\/ondro.inginea.eu\/#website"},"datePublished":"2013-07-02T14:32:24+00:00","dateModified":"2016-10-24T07:55:27+00:00","breadcrumb":{"@id":"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/ondro.inginea.eu\/index.php\/deproxy-a-lazily-loaded-jpa-reference-using-standard-java-and-jpa-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ondro.inginea.eu\/"},{"@type":"ListItem","position":2,"name":"Deproxy a lazily loaded JPA reference (using standard Java and JPA API)"}]},{"@type":"WebSite","@id":"https:\/\/ondro.inginea.eu\/#website","url":"https:\/\/ondro.inginea.eu\/","name":".Lost in Coding","description":"","publisher":{"@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ondro.inginea.eu\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616","name":"Ondro Mih\u00e1lyi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/image\/","url":"https:\/\/i2.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2017\/08\/fotoOMsquare3x300.jpg?fit=300%2C300&ssl=1","contentUrl":"https:\/\/i2.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2017\/08\/fotoOMsquare3x300.jpg?fit=300%2C300&ssl=1","width":300,"height":300,"caption":"Ondro Mih\u00e1lyi"},"logo":{"@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/image\/"},"description":"Ondro is a software developer and consultant specializing in combining standard and proven tools to solve new and challenging problems. He's been developing in Java for over 10 years. He\u2019s worked for clients like Payara, LottoLand, Uniqa and others. He has co-founded OmniFish, where he works as a director and Jakarta EE expert. He\u2019s passionate about helping his clients and the wider Java community with their projects based on Jakarta EE and similar technologies. As an experienced Java developer and instructor, he's helped companies build and educate their development teams and improve their development processes. He's a core member of several opensource projects and Jakarta EE specification projects. He\u2019s a frequent conference speaker, leader of the Czech JUG and a Java Champion. Ondro is a regular conference speaker at international conferences. Since 2016, he's presented at the following conferences: \u2022 FOSDEM, Brussels, Belgium 2023) \u2022 JChampionsConf, Online (year 2023) \u2022 EclipseCon, Germany (year 2022) \u2022 GeeCon, Prague, Czechia (years 2016, 2019, 2022) \u2022 JavaLand, Bruehl, Germany (years 2018, 2021) \u2022 JFokus, Stockholm, Sweden (year 2019) \u2022 Devops Con, Munich, Germany (year 2019) \u2022 Oracle CodeOne, San Francisco, USA (years 2018, 2019) \u2022 Devoxx, Antwerp, Belgium (year 2018) \u2022 JPrime, Sofia, Bulgaria (years 2017, 2018) \u2022 Java2Days, Sofia, Bulgaria (years 2016, 2018) \u2022 EclipseCon, France (year 2018) \u2022 JavaOne, San Francisco, USA (years 2016, 2017) \u2022 Oracle Code, Prague, Czechia (year 2017) \u2022 Devoxx, London, UK (year 2017) \u2022 GeeCon, Krakow, Poland (year 2017) \u2022 W-JAX, Munich, Germany (years 2016, 2017) \u2022 Bed-Con, Berlin, Germany (year 2017) \u2022 Oredev, Malmo, Sweden (year 2017) \u2022 Devoxx, Casablanca, Morocco (year 2017) \u2022 Java Developer Days, Krakow, Poland (year 2016)","sameAs":["https:\/\/www.facebook.com\/ondrej.mihalyi","https:\/\/cz.linkedin.com\/in\/mihalyiondrej","https:\/\/twitter.com\/https:\/\/twitter.com\/OndroMih"],"url":"https:\/\/ondro.inginea.eu\/index.php\/author\/ondrejm\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6wlb6-8","jetpack-related-posts":[{"id":172,"url":"https:\/\/ondro.inginea.eu\/index.php\/jpql-enhancements-in-jpa-2-1-and-java-ee-7-part-1\/","url_meta":{"origin":8,"position":0},"title":"JPQL Enhancements in JPA 2.1 and Java EE 7 &#8211; JOIN ON","author":"Ondro Mih\u00e1lyi","date":"22 February, 2016","format":false,"excerpt":"Java EE 7 is around for a few years already, and provides several very useful and long-awaited features, like entity graphs and better support for stored procedures and results mapping. For an overview, have a look at Thorben Janssen's blog post. The query capabilities were also enhanced, with 3 additional\u2026","rel":"","context":"In &quot;Jakarta EE&quot;","block_context":{"text":"Jakarta EE","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/java\/jakarta-ee\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2016\/02\/java-persistence-api-jpa-step-by-step-4-728.jpg?fit=596%2C447&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":141,"url":"https:\/\/ondro.inginea.eu\/index.php\/differences-in-jpa-entity-locking-modes\/","url_meta":{"origin":8,"position":1},"title":"Differences in JPA entity locking modes","author":"Ondro Mih\u00e1lyi","date":"4 November, 2015","format":false,"excerpt":"JPA provides essentially 2 types of locking mechanisms to help synchronize access to entities. Both mechanisms prevent a scenario, where 2 transactions overwrite data of each other without knowing it. By entity locking, we typically want to prevent following scenario with 2 parallel transactions: Adam's transaction reads data X Barbara's\u2026","rel":"","context":"In &quot;Jakarta EE&quot;","block_context":{"text":"Jakarta EE","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/java\/jakarta-ee\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":48,"url":"https:\/\/ondro.inginea.eu\/index.php\/properties-and-config-in-persistence-xml\/","url_meta":{"origin":8,"position":2},"title":"Properties and config in persistence.xml","author":"Ondro Mih\u00e1lyi","date":"12 March, 2013","format":false,"excerpt":"List of elements in persistence.xml","rel":"","context":"In &quot;Configuration&quot;","block_context":{"text":"Configuration","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/config\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":416,"url":"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/","url_meta":{"origin":8,"position":3},"title":"The simplest way to define a singleton in Java correctly","author":"Ondro Mih\u00e1lyi","date":"11 September, 2016","format":false,"excerpt":"A singleton pattern is probably the simplest well-known design pattern, but still people often implement it incorrectly in Java. The main goal of the pattern is to ensure there is a single instance of a class accessible globally before it is first needed. But wait, that could be accomplished just\u2026","rel":"","context":"In &quot;Java&quot;","block_context":{"text":"Java","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/java\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":209,"url":"https:\/\/ondro.inginea.eu\/index.php\/mvc-1-0-in-java-ee-8-getting-started-using-facelets\/","url_meta":{"origin":8,"position":4},"title":"MVC 1.0 in Java EE 8: Getting started using facelets","author":"Ondro Mih\u00e1lyi","date":"19 January, 2016","format":false,"excerpt":"MVC 1.0 is an action-based Model-View-Controller web framework, which will be a part of future Java EE 8. It will live side by side with component-based JSF framework and will provide an alternative for building HTML+javascript oriented applications with full control over URLs. This post summarizes what needs to be\u2026","rel":"","context":"In &quot;Jakarta EE&quot;","block_context":{"text":"Jakarta EE","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/java\/jakarta-ee\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":533,"url":"https:\/\/ondro.inginea.eu\/index.php\/using-hotswapagent-to-speed-up-development\/","url_meta":{"origin":8,"position":5},"title":"Using HotswapAgent to speed up development","author":"Ondro Mih\u00e1lyi","date":"20 October, 2017","format":false,"excerpt":"As a Java EE developer, I sometimes envy how fast it's possible to see the result of a code change in a running application with interpreted languages like PHP or JavaScript. With Java, it's always necessary to rebuild the source code in a bytecode, which can be then safely updated\u2026","rel":"","context":"In &quot;Configuration&quot;","block_context":{"text":"Configuration","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/config\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2017\/09\/Screenshot-from-DCEVM.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/posts\/8"}],"collection":[{"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/comments?post=8"}],"version-history":[{"count":6,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/posts\/8\/revisions"}],"predecessor-version":[{"id":441,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/posts\/8\/revisions\/441"}],"wp:attachment":[{"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/media?parent=8"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/categories?post=8"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/tags?post=8"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/series?post=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}