{"id":13810,"date":"2022-10-18T10:34:58","date_gmt":"2022-10-18T17:34:58","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=13810"},"modified":"2023-08-29T14:29:03","modified_gmt":"2023-08-29T21:29:03","slug":"couchbase-transaction-support-in-spring-data-couchbase","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/pt\/couchbase-transaction-support-in-spring-data-couchbase\/","title":{"rendered":"Suporte a transa\u00e7\u00f5es do Couchbase no Spring Data Couchbase"},"content":{"rendered":"<p><span style=\"font-weight: 400\"><a href=\"https:\/\/docs.couchbase.com\/server\/current\/learn\/data\/transactions.html\" target=\"_blank\" rel=\"noopener\">Suporte a transa\u00e7\u00f5es<\/a> foi adicionado recentemente aos SDKs do Couchbase. A partir de <em>Spring Data Couchbase 5.0.0-M5<\/em>O suporte a transa\u00e7\u00f5es foi adicionado ao <a href=\"https:\/\/docs.spring.io\/spring-data\/couchbase\/docs\/5.0.0-M6\/reference\" target=\"_blank\" rel=\"noopener\">Dados do Spring Couchbase<\/a><\/span><span style=\"font-weight: 400\">. Neste blog, descreveremos como usar o Spring Data <em>@Transactional<\/em> para aproveitar o Couchbase Transactions.<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><span style=\"font-weight: 400\">O <em>base de dados de mola<\/em> cont\u00e9m um reposit\u00f3rio <em>aplicativo de teste de dados de mola<\/em> que realiza transa\u00e7\u00f5es. Ele se baseia na <em>amostra de viagem<\/em> em um servidor Couchbase local. (qualquer bucket com um \u00edndice prim\u00e1rio ser\u00e1 suficiente).<\/span><\/p>\n<pre class=\"nums:false lang:default decode:true\">git clone git@github.com:spring-projects\/spring-data-examples.git\r\ncd spring-data-examples\/couchbase\/transactions<\/pre>\n<p><span style=\"font-weight: 400\">Os beans que oferecem suporte ao gerenciamento de transa\u00e7\u00f5es foram adicionados ao <em>AbstractCouchbaseConfiguration<\/em>. Para permitir que a classe de interceptador de transa\u00e7\u00f5es integrada seja substitu\u00edda pelo CouchbaseTransactionInterceptor, verifique se a seguinte linha est\u00e1 no arquivo <em>application.properties<\/em> file:<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><em><span style=\"font-weight: 400\">application.properties<\/span><\/em><\/p>\n<pre class=\"nums:false lang:default decode:true\">spring.main.allow-bean-definition-overriding=true<\/pre>\n<p><span style=\"font-weight: 400\">A configura\u00e7\u00e3o da transa\u00e7\u00e3o pode ser modificada substituindo o <em>configureEnvironment()<\/em> em sua classe que estende <em>AbstractCouchbaseConfiguration<\/em>.  Aqui definimos o <em>DurabilityLevel (n\u00edvel de durabilidade)<\/em> para <em>NENHUM<\/em> para que possamos trabalhar em nosso cluster de n\u00f3 \u00fanico. <\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><em><span style=\"font-weight: 400\">Config.java<\/span><\/em><\/p>\n<pre class=\"nums:false lang:default decode:true\">@Configuration\r\n@EnableCouchbaseRepositories({\"com.example.demo\"})\r\n@EnableTransactionManagement\r\npublic class Config extends AbstractCouchbaseConfiguration {\r\n\u2026\r\n\u00a0@Override\r\n\u00a0\u00a0public void configureEnvironment(ClusterEnvironment.Builder builder){\r\n\u00a0\u00a0\u00a0\u00a0builder.transactionsConfig(TransactionsConfig.durabilityLevel(DurabilityLevel.NONE));\r\n\u00a0\u00a0}<\/pre>\n<p><span style=\"font-weight: 400\">Na classe que os usar\u00e1, precisamos definir o modelo como de costume e uma refer\u00eancia ao objeto de servi\u00e7o. \u00c9 importante observar que o objeto <em>@Autowired<\/em> preenche uma vari\u00e1vel com um objeto proxy. Esse \u00e9 um detalhe importante, pois os objetos proxy executam o processamento antes e depois de chamar o m\u00e9todo real. <\/span><i><span style=\"font-weight: 400\">A cria\u00e7\u00e3o direta do objeto de servi\u00e7o a partir de seu construtor far\u00e1 com que a anota\u00e7\u00e3o @Transactional n\u00e3o tenha efeito.<\/span><\/i><span style=\"font-weight: 400\"><br \/>\n<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><em><span style=\"font-weight: 400\">CmdRunner.java<\/span><\/em><\/p>\n<pre class=\"nums:false lang:default decode:true\">@Autowired CouchbaseTemplate template;\r\n@Autowired AirportGatesService airportGatesService;<\/pre>\n<p><span style=\"font-weight: 400\">O servi\u00e7o \u00e9 definido com um <em>@Servi\u00e7o<\/em> anota\u00e7\u00e3o. O construtor recebe argumentos que s\u00e3o <em>@Bean<\/em> de modo que a infraestrutura possa criar um objeto proxy para <em>@Autowired<\/em>.<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><em><span style=\"font-weight: 400\">AirlineGateService.java<\/span><\/em><\/p>\n<pre class=\"nums:false lang:default decode:true\">@Service\r\npublic class AirlineGatesService {\r\n    CouchbaseTemplate template;\r\n    public AirlineGatesService(CouchbaseTemplate template) {\r\n      this.template = template;\r\n}<\/pre>\n<p><span style=\"font-weight: 400\"><em>AirlineGateService.java<\/em> (continua\u00e7\u00e3o)<\/span><\/p>\n<pre class=\"nums:false lang:default decode:true\">\/\/ The @Transactional annotation results in the method of the proxy for the service executing this in a transaction\r\n@Transactional\r\npublic void transferGates(String fromId, String toId, int gatesToTransfer, RuntimeException exceptionToThrow) {\r\n    \/\/ Not necessary, but may wish to include this check to confirm this is actually in a transaction.\r\n    TransactionalSupport.checkForTransactionInThreadLocalStorage().map((h) -&gt; {\r\n        if (!h.isPresent())\r\n            throw new RuntimeException(\"not in transaction!\");\r\n        return h;\r\n    });\r\n\r\n    AirlineGates fromAirlineGates = template.findById(AirlineGates.class).one(fromId);\r\n    AirlineGates toAirlineGates = template.findById(AirlineGates.class).one(toId);\r\n    toAirlineGates.gates += gatesToTransfer;\r\n    fromAirlineGates.gates -= gatesToTransfer;\r\n    template.save(fromAirlineGates);\r\n    \/\/ maybe simulate an error occurring after the fromAirlineGates doc has been saved\r\n    if(exceptionToThrow != null){\r\n        throw exceptionToThrow;\r\n    }\r\n    template.save(toAirlineGates);\r\n}<\/pre>\n<p><span style=\"font-weight: 400\">Agora use tudo o que constru\u00edmos:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">salvar dois <em>Port\u00f5es de companhias a\u00e9reas<\/em> documentos, cada um dos quais indica 200 port\u00f5es<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">verificar se eles foram salvos.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">executar o <em>transferGates()<\/em> m\u00e9todo do servi\u00e7o para transferir 50 port\u00f5es de uma companhia a\u00e9rea para outra em uma transa\u00e7\u00e3o.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">verificar se a transfer\u00eancia foi realizada.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">tentativa de execu\u00e7\u00e3o <em>transferGates()<\/em> novamente, desta vez com uma exce\u00e7\u00e3o que ocorre ap\u00f3s o primeiro documento ter sido salvo. <\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><em><span style=\"font-weight: 400\">CmdRunner.java<\/span><\/em><\/li>\n<\/ol>\n<pre class=\"nums:false lang:default decode:true\">AirlineGates airlineGates1 = new AirlineGates(\"1\", \"JFK\", \"American Airlines\", Long.valueOf(200)); \/\/1\r\nAirlineGates airlineGates2 = new AirlineGates(\"2\", \"JFK\", \"Lufthansa\", Long.valueOf(200));\r\nAirlineGates saved1 = airlineGatesService.save(airlineGates1);\r\nAirlineGates saved2 = airlineGatesService.save(airlineGates2);\r\nAirlineGates found1 = airlineGatesService.findById(saved1.getId()); \/\/2\r\nAirlineGates found2 = airlineGatesService.findById(saved2.getId());\r\nSystem.err.println(\"found before transferGates: \" + found1);\r\nSystem.err.println(\"found before transferGates: \" + found2);\r\n\/\/ move 50 gates from airline1 to airline2\r\nint gatesToTransfer=50;\r\nairlineGatesService.transferGates(airlineGates1.getId(), airlineGates2.getId(), gatesToTransfer, null); \/\/3\r\nfound1 = airlineGatesService.findById(saved1.getId());\r\nfound2 = airlineGatesService.findById(saved2.getId());\r\nSystem.err.println(\"found after\u00a0 transferGates: \" + found1); \/\/4\r\nSystem.err.println(\"found after\u00a0 transferGates: \" + found2);\r\nAssert.isTrue(found1.getGates().equals(airlineGates1.getGates()-gatesToTransfer), \"should have transferred\");\r\nAssert.isTrue(found2.getGates().equals(airlineGates1.getGates()+gatesToTransfer), \"should have transferred\");\r\n\/\/ attempt to move 44 gates from airline1 to airline2, but it fails.\r\ntry {\r\n    \/\/ 5\r\n    airlineGatesService.transferGates(airlineGates1.getId(), airlineGates2.getId(), 44, new SimulateErrorException());\r\n} catch (RuntimeException rte) {\r\n    if (!(rte instanceof TransactionSystemUnambiguousException) &amp;&amp; rte != null\r\n            &amp;&amp; rte.getCause() instanceof SimulateErrorException) {\r\n        throw rte;\r\n    }\r\n}\r\nSystem.err.println(\"found after\u00a0 transferGates: \" + airlineGatesService.findById(airlineGates1.getId()));\r\nSystem.err.println(\"found after\u00a0 transferGates: \" + airlineGatesService.findById(airlineGates2.getId()));\r\nAssert.isTrue(found1.getGates().equals(airlineGates1.getGates()-gatesToTransfer), \"should be same as previous\");\r\nAssert.isTrue(found2.getGates().equals(airlineGates1.getGates()+gatesToTransfer), \"should be same as previous\");<\/pre>\n<p><span style=\"font-weight: 400\">Como funciona:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">O <\/span><i><span style=\"font-weight: 400\">Interceptador de transa\u00e7\u00f5es<\/span><\/i><span style=\"font-weight: 400\"> @Bean in <\/span><i><span style=\"font-weight: 400\">AbstractCouchbaseConfiguration<\/span><\/i><span style=\"font-weight: 400\"> substitui o <\/span><i><span style=\"font-weight: 400\">Interceptador de transa\u00e7\u00f5es<\/span><\/i><span style=\"font-weight: 400\"> para m\u00e9todos anotados @Transactional.\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">A anota\u00e7\u00e3o @Transactional faz com que o proxy para <\/span><i><span style=\"font-weight: 400\">AirportGatesService<\/span><\/i><span style=\"font-weight: 400\"> para usar o <\/span><i><span style=\"font-weight: 400\">Interceptador de transa\u00e7\u00f5es<\/span><\/i><span style=\"font-weight: 400\"> para chamar o m\u00e9todo anotado usando o <\/span><i><span style=\"font-weight: 400\">CouchbaseCallbackTransactionManager<\/span><\/i><span style=\"font-weight: 400\">.\u00a0\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">O <\/span><i><span style=\"font-weight: 400\">CouchbaseCallbackTransactionManager<\/span><\/i><span style=\"font-weight: 400\"> inicializa uma transa\u00e7\u00e3o e, em seguida, chama o m\u00e9todo de servi\u00e7o real no contexto da transa\u00e7\u00e3o.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Se a chamada do m\u00e9todo for bem-sucedida, o <\/span><i><span style=\"font-weight: 400\">CouchbaseCallbackTransactionManager<\/span><\/i><span style=\"font-weight: 400\"> confirma a transa\u00e7\u00e3o.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Se o commit for bem-sucedido, a chamada ser\u00e1 retornada.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Se o commit falhar com uma exce\u00e7\u00e3o que pode ser tentada novamente, o <\/span><i><span style=\"font-weight: 400\">CouchbaseCallbackTransactionManger<\/span><\/i><span style=\"font-weight: 400\"> tentar\u00e1 novamente o processo completo de inicializa\u00e7\u00e3o de uma nova transa\u00e7\u00e3o, executando o m\u00e9todo de servi\u00e7o real e, em seguida, confirmando a transa\u00e7\u00e3o.\u00a0<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">O <\/span><i><span style=\"font-weight: 400\">CouchbaseCallbackTransactionManager<\/span><\/i><span style=\"font-weight: 400\"> repetir\u00e1 isso at\u00e9 que o commit seja bem-sucedido ou o n\u00famero m\u00e1ximo de tentativas seja atingido. <\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><\/p>\n<h2><span style=\"font-weight: 400\">Op\u00e7\u00f5es para as pr\u00f3ximas etapas<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><\/h2>\n<ul>\n<li><span style=\"font-weight: 400\">As transa\u00e7\u00f5es do Couchbase podem ser aproveitadas em <a href=\"https:\/\/docs.couchbase.com\/sdk-extensions\/spring-data-couchbase.html\">Dados do Spring Couchbase<\/a> usando o <em>Operador transacional<\/em> - veja o <a href=\"https:\/\/docs.spring.io\/spring-data\/couchbase\/docs\/5.0.0-M6\/reference\/html\/\" target=\"_blank\" rel=\"noopener\">Documentos do Spring Data aqui<\/a>.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">As transa\u00e7\u00f5es podem <\/span>tamb\u00e9m pode ser usado diretamente pelo Couchbase Java SDK - consulte a se\u00e7\u00e3o <a href=\"https:\/\/docs.couchbase.com\/java-sdk\/current\/howtos\/distributed-acid-transactions-from-the-sdk.html\" target=\"_blank\" rel=\"noopener\">Documentos sobre transa\u00e7\u00f5es Java ACID aqui<\/a>.<\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Transaction support has been recently added to the Couchbase SDKs. Starting in Spring Data Couchbase 5.0.0-M5, support for transactions has been added to Spring Data Couchbase. In this blog, we will describe using the Spring Data @Transactional annotation to leverage [&hellip;]<\/p>","protected":false},"author":63094,"featured_media":13811,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1818,6342,2201,2396],"tags":[9499,1595],"ppma_author":[9730],"class_list":["post-13810","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","category-spring","category-tools-sdks","category-transactions","tag-acid-transactions","tag-spring-data-couchbase"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.7.1 (Yoast SEO v25.7) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Spring Data @Transactional Annotation for Transactions<\/title>\n<meta name=\"description\" content=\"Transaction support has been added to the Couchbase SDKs. Learn to use the Spring Data @Transactional annotation to leverage Couchbase Transactions.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/pt\/couchbase-transaction-support-in-spring-data-couchbase\/\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Couchbase Transaction Support in Spring Data Couchbase\" \/>\n<meta property=\"og:description\" content=\"Transaction support has been added to the Couchbase SDKs. Learn to use the Spring Data @Transactional annotation to leverage Couchbase Transactions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/pt\/couchbase-transaction-support-in-spring-data-couchbase\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2022-10-18T17:34:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-29T21:29:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/10\/image_2022-10-18_102737984-732x1024.png\" \/>\n\t<meta property=\"og:image:width\" content=\"732\" \/>\n\t<meta property=\"og:image:height\" content=\"1024\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Michael Reiche, Sr. Software Engineer\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Michael Reiche, Sr. Software Engineer\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/\"},\"author\":{\"name\":\"Michael Reiche\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/1f3668e21ec9e1fd3fab0790831ca621\"},\"headline\":\"Couchbase Transaction Support in Spring Data Couchbase\",\"datePublished\":\"2022-10-18T17:34:58+00:00\",\"dateModified\":\"2023-08-29T21:29:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/\"},\"wordCount\":484,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/10\/image_2022-10-18_102737984.png\",\"keywords\":[\"ACID transactions\",\"spring-data-couchbase\"],\"articleSection\":[\"Java\",\"Spring\",\"Tools &amp; SDKs\",\"Transactions\"],\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/\",\"name\":\"Spring Data @Transactional Annotation for Transactions\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/10\/image_2022-10-18_102737984.png\",\"datePublished\":\"2022-10-18T17:34:58+00:00\",\"dateModified\":\"2023-08-29T21:29:03+00:00\",\"description\":\"Transaction support has been added to the Couchbase SDKs. Learn to use the Spring Data @Transactional annotation to leverage Couchbase Transactions.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/10\/image_2022-10-18_102737984.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/10\/image_2022-10-18_102737984.png\",\"width\":2814,\"height\":3939},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Couchbase Transaction Support in Spring Data Couchbase\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"pt-BR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/1f3668e21ec9e1fd3fab0790831ca621\",\"name\":\"Michael Reiche\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/06464ab0fa0dc64206e47efd804851d4\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/10\/image_2022-10-18_103343548.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/10\/image_2022-10-18_103343548.png\",\"caption\":\"Michael Reiche\"},\"url\":\"https:\/\/www.couchbase.com\/blog\/pt\/author\/michael-reichecouchbase-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Spring Data @Transactional Annotation for Transactions","description":"Transaction support has been added to the Couchbase SDKs. Learn to use the Spring Data @Transactional annotation to leverage Couchbase Transactions.","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:\/\/www.couchbase.com\/blog\/pt\/couchbase-transaction-support-in-spring-data-couchbase\/","og_locale":"pt_BR","og_type":"article","og_title":"Couchbase Transaction Support in Spring Data Couchbase","og_description":"Transaction support has been added to the Couchbase SDKs. Learn to use the Spring Data @Transactional annotation to leverage Couchbase Transactions.","og_url":"https:\/\/www.couchbase.com\/blog\/pt\/couchbase-transaction-support-in-spring-data-couchbase\/","og_site_name":"The Couchbase Blog","article_published_time":"2022-10-18T17:34:58+00:00","article_modified_time":"2023-08-29T21:29:03+00:00","og_image":[{"width":732,"height":1024,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/10\/image_2022-10-18_102737984-732x1024.png","type":"image\/png"}],"author":"Michael Reiche, Sr. Software Engineer","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Michael Reiche, Sr. Software Engineer","Est. reading time":"3 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/"},"author":{"name":"Michael Reiche","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/1f3668e21ec9e1fd3fab0790831ca621"},"headline":"Couchbase Transaction Support in Spring Data Couchbase","datePublished":"2022-10-18T17:34:58+00:00","dateModified":"2023-08-29T21:29:03+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/"},"wordCount":484,"commentCount":5,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/10\/image_2022-10-18_102737984.png","keywords":["ACID transactions","spring-data-couchbase"],"articleSection":["Java","Spring","Tools &amp; SDKs","Transactions"],"inLanguage":"pt-BR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/","url":"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/","name":"Spring Data @Transactional Annotation for Transactions","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/10\/image_2022-10-18_102737984.png","datePublished":"2022-10-18T17:34:58+00:00","dateModified":"2023-08-29T21:29:03+00:00","description":"Transaction support has been added to the Couchbase SDKs. Learn to use the Spring Data @Transactional annotation to leverage Couchbase Transactions.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/"]}]},{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/10\/image_2022-10-18_102737984.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/10\/image_2022-10-18_102737984.png","width":2814,"height":3939},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/couchbase-transaction-support-in-spring-data-couchbase\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Couchbase Transaction Support in Spring Data Couchbase"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"Blog do Couchbase","description":"Couchbase, o banco de dados NoSQL","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pt-BR"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"Blog do Couchbase","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/1f3668e21ec9e1fd3fab0790831ca621","name":"Michael Reiche","image":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/06464ab0fa0dc64206e47efd804851d4","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/10\/image_2022-10-18_103343548.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/10\/image_2022-10-18_103343548.png","caption":"Michael Reiche"},"url":"https:\/\/www.couchbase.com\/blog\/pt\/author\/michael-reichecouchbase-com\/"}]}},"authors":[{"term_id":9730,"user_id":63094,"is_guest":0,"slug":"michael-reichecouchbase-com","display_name":"Michael Reiche, Sr. Software Engineer","avatar_url":{"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/10\/image_2022-10-18_103343548.png","url2x":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/10\/image_2022-10-18_103343548.png"},"first_name":"Michael","last_name":"Reiche","user_url":"","author_category":"","description":""}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts\/13810","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/users\/63094"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/comments?post=13810"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts\/13810\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/media\/13811"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/media?parent=13810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/categories?post=13810"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/tags?post=13810"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/ppma_author?post=13810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}