{"id":3059,"date":"2016-06-14T10:24:14","date_gmt":"2016-06-14T08:24:14","guid":{"rendered":"https:\/\/adrhc.go.ro\/wordpress\/?p=3059"},"modified":"2017-06-08T12:15:34","modified_gmt":"2017-06-08T10:15:34","slug":"jpa-performance","status":"publish","type":"post","link":"https:\/\/adrhc.go.ro\/blog\/jpa-performance\/","title":{"rendered":"JPA performance"},"content":{"rendered":"<pre>\r\n<a href=\"http:\/\/java-persistence-performance.blogspot.ro\/2011\/06\/how-to-improve-jpa-performance-by-1825.html#\" target=\"_blank\">http:\/\/java-persistence-performance.blogspot.ro\/2011\/06\/how-to-improve-jpa-performance-by-1825.html#<\/a>\r\n<a href=\"http:\/\/spitballer.blogspot.ro\/2010\/04\/jpa-persisting-vs-merging-entites.html\" target=\"_blank\">http:\/\/spitballer.blogspot.ro\/2010\/04\/jpa-persisting-vs-merging-entites.html<\/a>\r\n\r\n<strong>Use byte code weaving<\/strong>\r\nEclipseLink implements LAZY for OneToOne and ManyToOne relationships using byte code weaving\r\n\r\n<strong>Pagination<\/strong>\r\nUse setFirstResult, setMaxResults of javax.persistence.Query.\r\n\r\n<strong>Caching<\/strong>\r\nSee <a href=\"https:\/\/docs.oracle.com\/javaee\/7\/tutorial\/persistence-cache001.htm#GKJIO\" target=\"_blank\">https:\/\/docs.oracle.com\/javaee\/7\/tutorial\/persistence-cache001.htm#GKJIO<\/a>.\r\nSee &lt;shared-cache-mode> in persistence.xml or javax.persistence.sharedCache.mode property when creating the EntityManagerFactory.\r\nSee javax.persistence.Cacheable used to annotate an entity.\r\n\r\n<strong>JDBC batching (insert\/update only)<\/strong>\r\nSee <a href=\"http:\/\/docs.jboss.org\/hibernate\/orm\/4.3\/manual\/en-US\/html_single\/#batch\" target=\"_blank\">http:\/\/docs.jboss.org\/hibernate\/orm\/4.3\/manual\/en-US\/html_single\/#batch<\/a>.\r\nhibernate.jdbc.batch_size: a non-zero value enables use of JDBC2 batch updates by Hibernate. e.g. recommended values between 5 and 30\r\n\r\n<strong>JDBC fetch size (retrieve only)<\/strong>\r\nhibernate.jdbc.fetch_size: a non-zero value determines the JDBC fetch size (calls Statement.setFetchSize())\r\nStatement.setFetchSize: gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed for ResultSet objects genrated by this Statement. If the value specified is zero, then the hint is ignored. The default value is zero.\r\nIn my opinion the best explanation is here: <a href=\"https:\/\/docs.oracle.com\/cd\/E11882_01\/java.112\/e16548\/resltset.htm#JJDBC28621\" target=\"_blank\">https:\/\/docs.oracle.com\/cd\/E11882_01\/java.112\/e16548\/resltset.htm#JJDBC28621<\/a>\r\nExcerpt: <em>Standard JDBC also enables you to specify the number of rows fetched with each database round-trip for a query, and this number is referred to as the fetch size.<\/em>\r\n\r\n<strong>Hibernate batch size (@BatchSize)<\/strong>\r\n<a href=\"http:\/\/docs.jboss.org\/hibernate\/orm\/4.3\/manual\/en-US\/html_single\/#performance-fetching\" target=\"_blank\">http:\/\/docs.jboss.org\/hibernate\/orm\/4.3\/manual\/en-US\/html_single\/#performance-fetching<\/a>\r\n@BatchSize specifies a \"batch size\" for fetching instances of this class by identifier. Not yet loaded instances are loaded batch-size at a time (default 1).\r\n\r\n<strong>Hibernate fetching strategies (@Fetch)<\/strong>\r\n<a href=\"http:\/\/docs.jboss.org\/hibernate\/orm\/4.3\/manual\/en-US\/html_single\/#performance-fetching\" target=\"_blank\">http:\/\/docs.jboss.org\/hibernate\/orm\/4.3\/manual\/en-US\/html_single\/#performance-fetching<\/a>\r\n<a href=\"http:\/\/www.mkyong.com\/hibernate\/hibernate-fetching-strategies-examples\/\" target=\"_blank\">http:\/\/www.mkyong.com\/hibernate\/hibernate-fetching-strategies-examples\/<\/a>\r\nFetching strategies: join fetching, select fetching, subselect fetching, batch fetching.\r\n\r\n<strong>other<\/strong>\r\n<a href=\"http:\/\/www.jroller.com\/eyallupu\/entry\/solving_the_simultaneously_fetch_multiple1\" target=\"_blank\">http:\/\/www.jroller.com\/eyallupu\/entry\/solving_the_simultaneously_fetch_multiple1<\/a>\r\n\r\n<strong>hibernate.default_batch_fetch_size<\/strong>\r\n<a href=\"http:\/\/stackoverflow.com\/questions\/21162172\/default-batch-fetch-size-recommended-values\" target=\"_blank\">http:\/\/stackoverflow.com\/questions\/21162172\/default-batch-fetch-size-recommended-values<\/a>\r\n<a href=\"http:\/\/docs.jboss.org\/hibernate\/orm\/4.3\/manual\/en-US\/html\/ch03.html\" target=\"_blank\">http:\/\/docs.jboss.org\/hibernate\/orm\/4.3\/manual\/en-US\/html\/ch03.html<\/a>\r\nsee also <em>hibernate.batch_fetch_style<\/em> at <a href=\"http:\/\/docs.jboss.org\/hibernate\/orm\/4.3\/manual\/en-US\/html_single\/#performance-fetching\" target=\"_blank\">http:\/\/docs.jboss.org\/hibernate\/orm\/4.3\/manual\/en-US\/html_single\/#performance-fetching<\/a>\r\n<a href=\"https:\/\/github.com\/hibernate\/hibernate-orm\/blob\/master\/hibernate-core\/src\/main\/java\/org\/hibernate\/loader\/BatchFetchStyle.java\" target=\"_blank\">https:\/\/github.com\/hibernate\/hibernate-orm\/blob\/master\/hibernate-core\/src\/main\/java\/org\/hibernate\/loader\/BatchFetchStyle.java<\/a> specifies LEGACY as the default for <em>hibernate.batch_fetch_style<\/em>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/java-persistence-performance.blogspot.ro\/2011\/06\/how-to-improve-jpa-performance-by-1825.html# http:\/\/spitballer.blogspot.ro\/2010\/04\/jpa-persisting-vs-merging-entites.html Use byte code weaving EclipseLink implements LAZY for OneToOne and ManyToOne relationships using byte code weaving Pagination Use setFirstResult, setMaxResults of javax.persistence.Query. Caching See https:\/\/docs.oracle.com\/javaee\/7\/tutorial\/persistence-cache001.htm#GKJIO. See &lt;shared-cache-mode> in persistence.xml or javax.persistence.sharedCache.mode property when creating the EntityManagerFactory. See javax.persistence.Cacheable [&hellip;]<\/p>\n<div class=\"link-more\"><a href=\"https:\/\/adrhc.go.ro\/blog\/jpa-performance\/#more-3059\" class=\"more-link\">Continue reading &#10142; <span class=\"screen-reader-text\">JPA performance<\/span><\/a><\/div>","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,36,10],"tags":[],"class_list":["post-3059","post","type-post","status-publish","format-standard","hentry","category-database","category-java","category-programming"],"_links":{"self":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/posts\/3059","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/comments?post=3059"}],"version-history":[{"count":0,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/posts\/3059\/revisions"}],"wp:attachment":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/media?parent=3059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/categories?post=3059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/tags?post=3059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}