{"id":10882,"date":"2017-12-29T17:30:51","date_gmt":"2017-12-29T15:30:51","guid":{"rendered":"https:\/\/techmoz.net\/?p=10882"},"modified":"2021-03-01T17:50:44","modified_gmt":"2021-03-01T15:50:44","slug":"java-data-access-objects-considerations-p-2","status":"publish","type":"post","link":"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/","title":{"rendered":"Java &#8211; Data Access Objects &#8211; Considerations (p. 2)"},"content":{"rendered":"<p>I couldn&#8217;t let this year end without fulfilling my promise, so i had to publish this last episode of the <a href=\"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-1\/\" target=\"_blank\" rel=\"noopener\">Java &#8211; Data Access Objects &#8211; Considerations series<\/a>.<\/p>\n<p>We will be talking about a simple problem: when each method of a DAO opens a new connection to the database in order to fetch or modify data, a new concern pops up: how to handle transactions? How do we group DAO operations in a single <a href=\"https:\/\/en.wikipedia.org\/wiki\/ACID\" target=\"_blank\" rel=\"noopener\">ACID<\/a> transaction? Being a Javatic article, we will be assuming JDBC as the API used to interact with the database.<\/p>\n<p>Transacting on a JDBC connection<br \/>\nIn JDBC, transactions are bound to connections. In order to group multiple <a href=\"https:\/\/en.wikipedia.org\/wiki\/Data_manipulation_language\" target=\"_blank\" rel=\"noopener\">DML<\/a> statements in a transaction, we must disable the <a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/sql\/Connection.html#setAutoCommit(boolean)\" target=\"_blank\" rel=\"noopener\">auto-commit<\/a> on the connection object we want to transact on and then we can start throwing DML statement at it and at the end we get to commit or rollback the transaction.<\/p>\n<p>If you take a pause and go back to our problem statements, upstairs, you might find out that we can already answer that question. We just found the answer. The answer is: the different DAO operations must share the connection object in order to have their DML statements grouped in a single transactional unit which will be later committed or rolled back.<\/p>\n<p>It&#8217;s important to make sure that the connection object is shared among the DAO operations only when we are in the middle of a transaction, otherwise, each operation should open it&#8217;s own connection.<\/p>\n<p>This means that we need a way to check if we are in the middle of a transaction or not, so that we can decide to use the shared connection object or to create a new connection.<\/p>\n<p>We will put the <strong>getConnection()<\/strong> method in our <strong>AbstractDAO<\/strong>, so that specific DAO classes are not aware (abstraction) of the existence of a shared connection and all that mambo-djambo.<\/p>\n<h3>The CustomerDAO example<\/h3>\n<p>See below the code of the <strong>CustomerDAO,<\/strong> which extends the <strong>AbstractDAO<\/strong>, that we will soon be discussing.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npublic class CustomerDAO extends AbstractDAO {\r\n\r\n    \r\n    public void updateEmail(String personId, String email){\r\n        \r\n       \/\/TODO: Validate arguments\r\n        \r\n        Connection connection = this.getConnection();\r\n\r\n        try{\r\n\r\n            \/\/Execute the update operation here\r\n\r\n\r\n        }finally{\r\n\r\n           this.close(connection);\r\n\r\n        }\r\n\r\n    }\r\n\r\n\r\n    public void updateMobile(String personId, String mobile){\r\n        \r\n        \/\/TODO: Validate arguments\r\n        \r\n        Connection connection = this.getConnection();\r\n\r\n        try{\r\n\r\n            \r\n            \/\/Execute the update operation here\r\n\r\n        }finally{\r\n\r\n           this.close(connection);\r\n\r\n        }\r\n\r\n    }\r\n    \r\n\r\n}\r\n<\/pre>\n<p>Both methods <strong>close<\/strong> and <strong>getConnection<\/strong> belong to the <strong>AbstractDAO<\/strong> class.<\/p>\n<h3>Abstract DAO<\/h3>\n<p>This would be the parent class of all our DAO classes. Providing the logic required to make the DAO objects transaction capable.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npublic abstract class AbstractDAO {\r\n\r\n     \r\n     private static ThreadLocal&lt;Connection&gt; sharedConnection = new ThreadLocal&lt;&gt;();\r\n\r\n\r\n     \/\/Returns the shared connection, if exists, \r\n     \/\/otherwise, creates a new one\r\n     protected Connection getConnection(){\r\n\r\n         Optional&lt;Connection&gt; optional = getSharedConnection();\r\n\r\n         if(optional.isPresent()) \r\n             return optional.get();\r\n         else return openNewConnection(); \r\n\r\n     }   \r\n\r\n\r\n     \/\/Keep the connection open in case it's shared\r\n     \/\/Close the connection if not shared\r\n     protected close(Connection connection){\r\n         \r\n         if(getSharedConnection().isPresent())\r\n             return;\r\n\r\n         connection.close();\r\n\r\n     }\r\n\r\n    \r\n     private Optional&lt;Connection&gt; getSharedConnection(){\r\n        return Optional.ofNullable(sharedConnection.get());\r\n     }\r\n\r\n     private static Connection openNewConnection(){\r\n         \/\/Open a new database connection here\r\n     } \r\n\r\n\r\n     \/\/Starts a new transaction (on the current Thread).\r\n     \/\/Creates a shared connection\r\n     \/\/with auto-commit disabled\r\n     public static void beginTransaction(){\r\n        Connection connection = openNewConnection();\r\n        connection.setAutoCommit(false);\r\n        sharedConnection.set(connection);\r\n     }\r\n     \r\n     \r\n\r\n     \/\/Commits the active-transaction\r\n     \/\/Closes and clears the shared connection\r\n     public static void commitTransaction(){\r\n\r\n         Optional&lt;Connection&gt; optional = getSharedConnection();\r\n         if(!optional.isPresent())\r\n             throw new IllegalStateException(&quot;No active transaction&quot;);\r\n\r\n         Connection connection = optional.get();\r\n\r\n         try{\r\n\r\n            connection.commit(); \r\n\r\n         }finally{\r\n\r\n            connection.close(); \/\/close the shared connection\r\n            sharedConnection.remove();\/\/remove the shared connection;\r\n \r\n         }\r\n         \r\n     }\r\n\r\n\r\n\r\n     \/\/Rolls back the active-transaction\r\n     \/\/Closes and clears the shared connection\r\n     public static void rollbackTransaction(){\r\n\r\n         Optional&lt;Connection&gt; optional = getSharedConnection();\r\n         if(!optional.isPresent())\r\n             throw new IllegalStateException(&quot;No active transaction&quot;);\r\n\r\n         Connection connection = optional.get();\r\n\r\n         try{\r\n\r\n             connection.rollback();\r\n\r\n         }finally{\r\n\r\n             connection.close(); \/\/close\r\n             sharedConnection.remove(); \/\/remove\r\n\r\n         }\r\n        \r\n     }\r\n\r\n}\r\n<\/pre>\n<p>You might have noticed that the <strong>AbstractDAO<\/strong> class has a few static methods. That methods are intended to be invoked from the transaction-demarcation layer, which is the services-layer.<\/p>\n<p>In a nutshell, we could for example, have a service method that updates customer information as below:<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npublic void updateCustomerDetails(String id, String email, String mobile){\r\n    \r\n     CustomerDAO dao = new CustomerDAO();\r\n\r\n     \/\/Start a new transaction\r\n     AbstractDAO.beginTransaction();\r\n\r\n     try{\r\n\r\n         \/\/Update the details\r\n         dao.updateEmail(id,email);\r\n         dao.updateMobile(id,mobile);\r\n         \r\n         \/\/Commit the transaction\r\n         AbstractDAO.commitTransaction();\r\n\r\n    }catch(RuntimeException ex){\r\n        \/\/Rollback the transaction\r\n        AbstractDAO.rollbackTransaction();\r\n        throw ex;\r\n\r\n    }\r\n     \r\n\r\n}\r\n<\/pre>\n<p>We made sure that all DAO operations executed in the same transaction will share the connection, while operations executed out of a transaction won&#8217;t share the connection object.<\/p>\n<p>We also made sure that multiple Threads executing transactions wont be sharing the connection object, meaning, each Thread will have its own connection object, thanks to the <a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/ThreadLocal.html\" target=\"_blank\" rel=\"noopener\">ThreadLocal<\/a> variable. In this model, one Thread can only execute one transaction per time, no chained transactions are supported. Despite the fact that it works, it&#8217;s worth asking if it&#8217;s the best way to deal with transactions across DAOs.<\/p>\n<h3>Is it the best way?<\/h3>\n<p>While what we have done in this article is a good way to explain how transaction-demarcation works behind the scenes, it&#8217;s probably not the best way to deal with transactions across DAOs in a J2EE application. But what would the real cons be? Here they follow:<\/p>\n<ul>\n<li>Its coupled to JDBC and only supports transactions through direct JDBC connections.<\/li>\n<li>No JPA support &#8211; coding is required<\/li>\n<li>No support for transactions across multiple databases\/resources.<\/li>\n<li>No child transactions support<\/li>\n<\/ul>\n<p>While the cons list above might not seem to be a big deal, I have the duty to tell you about two technologies that are out there that can make you re-think about writing your own transaction-management library: <a href=\"https:\/\/en.wikipedia.org\/wiki\/Java_Transaction_API\" target=\"_blank\" rel=\"noopener\">JTA<\/a> and <a href=\"https:\/\/en.wikipedia.org\/wiki\/Enterprise_JavaBeans\" target=\"_blank\" rel=\"noopener\">EJB<\/a> (container managed transaction).<\/p>\n<p>JTA enables distributed transactions across multiple resources. Such resources can be jdbc enabled databases, <a href=\"https:\/\/docs.oracle.com\/javaee\/6\/tutorial\/doc\/gipko.html\" target=\"_blank\" rel=\"noopener\">message driven beans<\/a>, <a href=\"https:\/\/docs.oracle.com\/cd\/E19798-01\/821-1841\/gipkr\/index.html\" target=\"_blank\" rel=\"noopener\">session beans<\/a>, <a href=\"https:\/\/docs.oracle.com\/javaee\/6\/tutorial\/doc\/gipgl.html\" target=\"_blank\" rel=\"noopener\">resource-adapters<\/a> or custom resources. This literally means that <strong>anything can participate in a transaction<\/strong>, as long as such thing <strong>implements a specific JTA contract<\/strong>.<\/p>\n<p>JTA is just an API that defines contracts. You need more than the API itself in order to use JTA, you need a JTA transaction-manager. Any JAVA EE certified server comes with a built-in transaction-manager and you don&#8217;t have to worry about it. If you intend to use JTA in a SE environment, you will need to include a transaction manager in your application.<\/p>\n<p>What about EJB? EJBs are divided in : session beans and message-driven beans (MDBs).<\/p>\n<p>MDBs are EJBs that interact with message queue resources, while session beans are meant to be used by client applications or components to access the system&#8217;s functionalities\/services.<\/p>\n<p>The special thing about session beans is that simply by annotating a method with the <strong>@Transactional<\/strong> annotation, you will be telling the container to begin a transaction every-time that method is invoked and the transaction will be automatically rolled-back if any exception is thrown by the method. You can also annotate the methods to join a transaction in case it&#8217;s already active or to fail when invoked in the middle of a transaction. You have a considerable set of options for transactions demarcation.<\/p>\n<p>This is why EJB session beans are the perfect example of Container Managed Transactions (CMT). The EJB API is built on top of both the CDI and the JTA APIs. JTA is what an EJB\/J2EE container uses for transactions. The CDI API is what allows the <strong>@Transactional<\/strong> annotation to function, enabling interception capabilities, but these details are simply way too out of our scope here.<\/p>\n<p>This was me giving you an idea of these two JavaEE APIs that might help you save a few code lines and years of maintenance, unless of-course you know what you are doing.<\/p>\n<p>This is it. We are done here. Remember that in order for this To be a consummated discussion, you must talk back to me, so please, leave a comment, ask, make an observation, criticize, give an example, contribute.<\/p>\n<p>It&#8217;s always my pleasure.<\/p>\n<p><strong>#TheLastOf2017<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I couldn&#8217;t let this year end without fulfilling my promise, so i had to publish this last episode of the Java &#8211; Data Access Objects &#8211; Considerations series. We will be talking about a simple problem: when each method of a DAO opens a new connection to the database in order to fetch or modify<\/p>\n","protected":false},"author":3,"featured_media":10884,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_dcms_eufi_img":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[963,974,952,978,991],"tags":[],"class_list":["post-10882","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles-2","category-development-tools","category-highlights-2","category-java-2","category-programming"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java - Data Access Objects - Considerations (p. 2) - Techmoz<\/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:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java - Data Access Objects - Considerations (p. 2) - Techmoz\" \/>\n<meta property=\"og:description\" content=\"I couldn&#8217;t let this year end without fulfilling my promise, so i had to publish this last episode of the Java &#8211; Data Access Objects &#8211; Considerations series. We will be talking about a simple problem: when each method of a DAO opens a new connection to the database in order to fetch or modify\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Techmoz\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/web.facebook.com\/hostmoz\" \/>\n<meta property=\"article:published_time\" content=\"2017-12-29T15:30:51+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-03-01T15:50:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techmoz.net\/wp-content\/uploads\/2021\/03\/Java-Data-Access-Objects-Considerations.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"718\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"M\u00e1rio J\u00fanior\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hostmoz\" \/>\n<meta name=\"twitter:site\" content=\"@hostmoz\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"M\u00e1rio J\u00fanior\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"NewsArticle\"],\"@id\":\"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/\"},\"author\":{\"name\":\"M\u00e1rio J\u00fanior\",\"@id\":\"https:\/\/techmoz.net\/#\/schema\/person\/fd20b46d911cc409a8a48646aa2eeafe\"},\"headline\":\"Java &#8211; Data Access Objects &#8211; Considerations (p. 2)\",\"datePublished\":\"2017-12-29T15:30:51+00:00\",\"dateModified\":\"2021-03-01T15:50:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/\"},\"wordCount\":1350,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/techmoz.net\/#organization\"},\"image\":{\"@id\":\"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/techmoz.net\/wp-content\/uploads\/2021\/03\/Java-Data-Access-Objects-Considerations.jpeg\",\"articleSection\":[\"Articles\",\"Development Tools\",\"Highlights\",\"Java\",\"Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/#respond\"]}],\"copyrightYear\":\"2017\",\"copyrightHolder\":{\"@id\":\"https:\/\/techmoz.net\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/\",\"url\":\"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/\",\"name\":\"Java - Data Access Objects - Considerations (p. 2) - Techmoz\",\"isPartOf\":{\"@id\":\"https:\/\/techmoz.net\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/techmoz.net\/wp-content\/uploads\/2021\/03\/Java-Data-Access-Objects-Considerations.jpeg\",\"datePublished\":\"2017-12-29T15:30:51+00:00\",\"dateModified\":\"2021-03-01T15:50:44+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/#primaryimage\",\"url\":\"https:\/\/techmoz.net\/wp-content\/uploads\/2021\/03\/Java-Data-Access-Objects-Considerations.jpeg\",\"contentUrl\":\"https:\/\/techmoz.net\/wp-content\/uploads\/2021\/03\/Java-Data-Access-Objects-Considerations.jpeg\",\"width\":1280,\"height\":718,\"caption\":\"Java - Data Access Objects - Considerations\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/techmoz.net\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java &#8211; Data Access Objects &#8211; Considerations (p. 2)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/techmoz.net\/#website\",\"url\":\"https:\/\/techmoz.net\/\",\"name\":\"Techmoz\",\"description\":\"O maior Portal de Tecnologia em Mo\u00e7ambique\",\"publisher\":{\"@id\":\"https:\/\/techmoz.net\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/techmoz.net\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/techmoz.net\/#organization\",\"name\":\"Hostmoz,Lda\",\"url\":\"https:\/\/techmoz.net\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/techmoz.net\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/techmoz.test\/wp-content\/uploads\/2023\/01\/techmoz-logo.png?fit=385%2C90&ssl=1\",\"contentUrl\":\"https:\/\/techmoz.test\/wp-content\/uploads\/2023\/01\/techmoz-logo.png?fit=385%2C90&ssl=1\",\"width\":385,\"height\":90,\"caption\":\"Hostmoz,Lda\"},\"image\":{\"@id\":\"https:\/\/techmoz.net\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/web.facebook.com\/hostmoz\",\"https:\/\/x.com\/hostmoz\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/techmoz.net\/#\/schema\/person\/fd20b46d911cc409a8a48646aa2eeafe\",\"name\":\"M\u00e1rio J\u00fanior\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/techmoz.net\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1ba78c78f5737d6907dfb107a42f20c04a903414c196f57b04d376fc82cffd1e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1ba78c78f5737d6907dfb107a42f20c04a903414c196f57b04d376fc82cffd1e?s=96&d=mm&r=g\",\"caption\":\"M\u00e1rio J\u00fanior\"},\"description\":\"M\u00e1rio Francisco J\u00fanior is the Head Of Software Development at Vodacom Mozambique.\",\"url\":\"https:\/\/techmoz.net\/en\/author\/mfjunior\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java - Data Access Objects - Considerations (p. 2) - Techmoz","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:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/","og_locale":"en_US","og_type":"article","og_title":"Java - Data Access Objects - Considerations (p. 2) - Techmoz","og_description":"I couldn&#8217;t let this year end without fulfilling my promise, so i had to publish this last episode of the Java &#8211; Data Access Objects &#8211; Considerations series. We will be talking about a simple problem: when each method of a DAO opens a new connection to the database in order to fetch or modify","og_url":"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/","og_site_name":"Techmoz","article_publisher":"https:\/\/web.facebook.com\/hostmoz","article_published_time":"2017-12-29T15:30:51+00:00","article_modified_time":"2021-03-01T15:50:44+00:00","og_image":[{"width":1280,"height":718,"url":"https:\/\/techmoz.net\/wp-content\/uploads\/2021\/03\/Java-Data-Access-Objects-Considerations.jpeg","type":"image\/jpeg"}],"author":"M\u00e1rio J\u00fanior","twitter_card":"summary_large_image","twitter_creator":"@hostmoz","twitter_site":"@hostmoz","twitter_misc":{"Written by":"M\u00e1rio J\u00fanior","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","NewsArticle"],"@id":"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/#article","isPartOf":{"@id":"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/"},"author":{"name":"M\u00e1rio J\u00fanior","@id":"https:\/\/techmoz.net\/#\/schema\/person\/fd20b46d911cc409a8a48646aa2eeafe"},"headline":"Java &#8211; Data Access Objects &#8211; Considerations (p. 2)","datePublished":"2017-12-29T15:30:51+00:00","dateModified":"2021-03-01T15:50:44+00:00","mainEntityOfPage":{"@id":"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/"},"wordCount":1350,"commentCount":0,"publisher":{"@id":"https:\/\/techmoz.net\/#organization"},"image":{"@id":"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/#primaryimage"},"thumbnailUrl":"https:\/\/techmoz.net\/wp-content\/uploads\/2021\/03\/Java-Data-Access-Objects-Considerations.jpeg","articleSection":["Articles","Development Tools","Highlights","Java","Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/#respond"]}],"copyrightYear":"2017","copyrightHolder":{"@id":"https:\/\/techmoz.net\/#organization"}},{"@type":"WebPage","@id":"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/","url":"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/","name":"Java - Data Access Objects - Considerations (p. 2) - Techmoz","isPartOf":{"@id":"https:\/\/techmoz.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/#primaryimage"},"image":{"@id":"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/#primaryimage"},"thumbnailUrl":"https:\/\/techmoz.net\/wp-content\/uploads\/2021\/03\/Java-Data-Access-Objects-Considerations.jpeg","datePublished":"2017-12-29T15:30:51+00:00","dateModified":"2021-03-01T15:50:44+00:00","breadcrumb":{"@id":"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/#primaryimage","url":"https:\/\/techmoz.net\/wp-content\/uploads\/2021\/03\/Java-Data-Access-Objects-Considerations.jpeg","contentUrl":"https:\/\/techmoz.net\/wp-content\/uploads\/2021\/03\/Java-Data-Access-Objects-Considerations.jpeg","width":1280,"height":718,"caption":"Java - Data Access Objects - Considerations"},{"@type":"BreadcrumbList","@id":"https:\/\/techmoz.net\/en\/java-data-access-objects-considerations-p-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techmoz.net\/en\/"},{"@type":"ListItem","position":2,"name":"Java &#8211; Data Access Objects &#8211; Considerations (p. 2)"}]},{"@type":"WebSite","@id":"https:\/\/techmoz.net\/#website","url":"https:\/\/techmoz.net\/","name":"Techmoz","description":"O maior Portal de Tecnologia em Mo\u00e7ambique","publisher":{"@id":"https:\/\/techmoz.net\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techmoz.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techmoz.net\/#organization","name":"Hostmoz,Lda","url":"https:\/\/techmoz.net\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techmoz.net\/#\/schema\/logo\/image\/","url":"https:\/\/techmoz.test\/wp-content\/uploads\/2023\/01\/techmoz-logo.png?fit=385%2C90&ssl=1","contentUrl":"https:\/\/techmoz.test\/wp-content\/uploads\/2023\/01\/techmoz-logo.png?fit=385%2C90&ssl=1","width":385,"height":90,"caption":"Hostmoz,Lda"},"image":{"@id":"https:\/\/techmoz.net\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/web.facebook.com\/hostmoz","https:\/\/x.com\/hostmoz"]},{"@type":"Person","@id":"https:\/\/techmoz.net\/#\/schema\/person\/fd20b46d911cc409a8a48646aa2eeafe","name":"M\u00e1rio J\u00fanior","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techmoz.net\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1ba78c78f5737d6907dfb107a42f20c04a903414c196f57b04d376fc82cffd1e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1ba78c78f5737d6907dfb107a42f20c04a903414c196f57b04d376fc82cffd1e?s=96&d=mm&r=g","caption":"M\u00e1rio J\u00fanior"},"description":"M\u00e1rio Francisco J\u00fanior is the Head Of Software Development at Vodacom Mozambique.","url":"https:\/\/techmoz.net\/en\/author\/mfjunior\/"}]}},"_format-video":{"_last_editor_used_jetpack":["classic-editor"],"_edit_lock":["1673424500:2"],"_edit_last":["2"],"_wpml_media_featured":["1"],"_wpml_media_duplicate":["1"],"_syntaxhighlighter_encoded":["1"],"_yoast_wpseo_content_score":["30"],"_yoast_wpseo_estimated-reading-time-minutes":["6"],"views":["61"],"_thumbnail_id":["10884"],"_yoast_wpseo_primary_category":["963"],"_encloseme":["1"],"_wpas_done_all":["1"],"post_views_count":["399"],"mashsb_timestamp":["1674418198"],"mashsb_shares":["0"],"mashsb_jsonshares":["{\"total\":0,\"error\":{\"facebook_error\":\"\"},\"facebook_total\":0}"]},"_links":{"self":[{"href":"https:\/\/techmoz.net\/en\/wp-json\/wp\/v2\/posts\/10882","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techmoz.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techmoz.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techmoz.net\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/techmoz.net\/en\/wp-json\/wp\/v2\/comments?post=10882"}],"version-history":[{"count":3,"href":"https:\/\/techmoz.net\/en\/wp-json\/wp\/v2\/posts\/10882\/revisions"}],"predecessor-version":[{"id":10887,"href":"https:\/\/techmoz.net\/en\/wp-json\/wp\/v2\/posts\/10882\/revisions\/10887"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techmoz.net\/en\/wp-json\/wp\/v2\/media\/10884"}],"wp:attachment":[{"href":"https:\/\/techmoz.net\/en\/wp-json\/wp\/v2\/media?parent=10882"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techmoz.net\/en\/wp-json\/wp\/v2\/categories?post=10882"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techmoz.net\/en\/wp-json\/wp\/v2\/tags?post=10882"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}