You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2019/02/28 13:37:00 UTC

[tomee] branch master updated: TOMEE-2474 Translate to Portuguese: examples/jpa-hibernate. And some improvement in the English version.

This is an automated email from the ASF dual-hosted git repository.

jgallimore pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git


The following commit(s) were added to refs/heads/master by this push:
     new dec1840  TOMEE-2474 Translate to Portuguese: examples/jpa-hibernate. And some improvement in the English version.
     new b783cca  Merge pull request #421 from gabrielferreirapro/TOMEE-2474
dec1840 is described below

commit dec1840900c4402642f5195823ceba988e81a41d
Author: Gabriel Ferreira <ga...@gmail.com>
AuthorDate: Tue Feb 26 22:48:02 2019 -0300

    TOMEE-2474 Translate to Portuguese: examples/jpa-hibernate.
    And some improvement in the English version.
---
 examples/jpa-hibernate/README.adoc                 | 36 +++++++++++++++--
 .../jpa-hibernate/{README.adoc => README_pt.adoc}  | 46 ++++++++++++++++++----
 2 files changed, 71 insertions(+), 11 deletions(-)

diff --git a/examples/jpa-hibernate/README.adoc b/examples/jpa-hibernate/README.adoc
index 0bb85f1..36dddcf 100644
--- a/examples/jpa-hibernate/README.adoc
+++ b/examples/jpa-hibernate/README.adoc
@@ -6,9 +6,19 @@
 This example shows the persist, remove and creation a query in JPA Hibernate.
 The Java Persistence API (JPA) is a Java specification for accessing, persisting, and managing data between Java objects / classes and a relational database.
 
+To exemplify the use of JPA, we will persist an Object (Movie) in the database.
+
+Links to the documentation have been added in key parts of the example for the case of doubts and as a way to encourage their reading for details.
+
 == Movie
 
-Define the class Movie as an entity with de annotation @Entity
+Here we have a class with some details. See the annotation 
+link:https://tomee.apache.org/tomee-8.0/javadoc/javax/persistence/Entity.html[@Entity] 
+above the declaration, with it we are saying that this class is an entity (a table in the database). We still have two more annotations above the attribute id, one of them is 
+link:https://tomee.apache.org/tomee-8.0/javadoc/javax/persistence/Id.html[@Id] 
+annotation, it indicates that this attribute is the identifier of the entity and the other annotation 
+link:https://tomee.apache.org/tomee-8.0/javadoc/javax/persistence/GeneratedValue.html[@GeneratedValue] 
+indicates that the unique identifier value generation of the entity will be managed by the persistence provider.
 
 ....
 package org.superbiz.injection.h3jpa;
@@ -67,8 +77,18 @@ public class Movie {
 
 == Movies
 
-@PersistenceContext A persistence context is a set of entities such that for any persistent identity there is a unique entity instance.
-@EntityManager is associated with a persistence context. Is at the core of JPA, supported by some methods: persist, remove,merge, find,
+Now we have two important things: 
+link:https://tomee.apache.org/tomee-8.0/javadoc/javax/persistence/PersistenceContext.html[@PersistenceContext] 
+annotation and the 
+link:https://tomee.apache.org/tomee-8.0/javadoc/javax/persistence/EntityManager.html[EntityManager] 
+declaration.
+The 
+link:https://tomee.apache.org/tomee-8.0/javadoc/javax/persistence/EntityManager.html[EntityManager] 
+is the interface with the core methods of JPA like persist, remove, merge, find and others...
+We annotate the 
+link:https://tomee.apache.org/tomee-8.0/javadoc/javax/persistence/EntityManager.html[EntityManager] 
+with 
+link:https://tomee.apache.org/tomee-8.0/javadoc/javax/persistence/PersistenceContext.html[@PersistenceContext], a persistence context is an entity management where  every persistence context associated with a persistence unit, we will create a persistence.xml soon for this.
 
 ....
 package org.superbiz.injection.h3jpa;
@@ -103,6 +123,8 @@ public class Movies {
 
 == persistence.xml
 
+Here we define which database will persist our movies, and we perform other configurations such as: define a persistence-unit with the name movie-unit, followed by the definition of the JPA provider/implementation (in this case Hibernate) and we set some properties for hibernate:
+
  <persistence version="1.0"
               xmlns="http://java.sun.com/xml/ns/persistence"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -120,6 +142,8 @@ public class Movies {
 
 == MoviesTest
 
+Now we do a test, persisting three films, then we perform a search and finally we delete them.
+
 ....
 package org.superbiz.injection.h3jpa;
 
@@ -164,8 +188,14 @@ public class MoviesTest extends TestCase {
 
 To run the example via maven:
 
+Access the project folder:
+....
 cd jpa-hibernate
+....
+And execute:
+....
 mvn clean install
+....
 
 Which will generate output similar to the following:
 
diff --git a/examples/jpa-hibernate/README.adoc b/examples/jpa-hibernate/README_pt.adoc
similarity index 72%
copy from examples/jpa-hibernate/README.adoc
copy to examples/jpa-hibernate/README_pt.adoc
index 0bb85f1..838e81a 100644
--- a/examples/jpa-hibernate/README.adoc
+++ b/examples/jpa-hibernate/README_pt.adoc
@@ -3,12 +3,22 @@
 :jbake-type: page
 :jbake-status: published
 
-This example shows the persist, remove and creation a query in JPA Hibernate.
-The Java Persistence API (JPA) is a Java specification for accessing, persisting, and managing data between Java objects / classes and a relational database.
+Este exemplo mostra a persistência, exclusão e a criação de uma query com JPA Hibernate.
+A Java Persistence API (JPA) é uma especificação Java para acessar, persistir e gerenciar dados entre classes/objetos Java e um banco de dados relacional.
+
+Para exemplificar o uso da JPA vamos persistir um objeto (Movie) no banco de dados.
+
+Links para a documentação foram adicionados em partes chave do exemplo para o caso de duvidas e como forma de incentivar sua leitura em busca de detalhes. 
 
 == Movie
 
-Define the class Movie as an entity with de annotation @Entity
+Aqui nós temos uma classe com alguns detalhes. Perceba a anotação 
+link:https://tomee.apache.org/tomee-8.0/javadoc/javax/persistence/Entity.html[@Entity] 
+acima da declaração da classe, com ela estamos dizendo que esta classe é uma entidade (uma tabela no banco de dados). Nós ainda temos mais duas anotações acima do atributo id, uma delas é o 
+link:https://tomee.apache.org/tomee-8.0/javadoc/javax/persistence/Id.html[@Id], 
+ele indica que este atributo é o identificador da entidade e a outra anotação 
+link:https://tomee.apache.org/tomee-8.0/javadoc/javax/persistence/GeneratedValue.html[@GeneratedValue] 
+indica que a geração desses identificadores unicos serão gerenciados pelo provedor da persistência.
 
 ....
 package org.superbiz.injection.h3jpa;
@@ -67,8 +77,17 @@ public class Movie {
 
 == Movies
 
-@PersistenceContext A persistence context is a set of entities such that for any persistent identity there is a unique entity instance.
-@EntityManager is associated with a persistence context. Is at the core of JPA, supported by some methods: persist, remove,merge, find,
+Agora nós podemos notar duas coisas diferentes: a anotação  
+link:https://tomee.apache.org/tomee-8.0/javadoc/javax/persistence/PersistenceContext.html[@PersistenceContext] 
+e a declaração de um  
+link:https://tomee.apache.org/tomee-8.0/javadoc/javax/persistence/EntityManager.html[EntityManager].
+O 
+link:https://tomee.apache.org/tomee-8.0/javadoc/javax/persistence/EntityManager.html[EntityManager] 
+é uma interface com as principais funcionalidades do JPA como persist, remove, merge, find e outros...
+Nós anotamos o 
+link:https://tomee.apache.org/tomee-8.0/javadoc/javax/persistence/EntityManager.html[EntityManager] 
+com 
+link:https://tomee.apache.org/tomee-8.0/javadoc/javax/persistence/PersistenceContext.html[@PersistenceContext], um contexto de persistência é um gerenciamento de entidades onde, todo contexto de persistência é associado com uma unidade de persistência (persistence-unit), logo criaremos um persistence.xml para isso.
 
 ....
 package org.superbiz.injection.h3jpa;
@@ -103,6 +122,8 @@ public class Movies {
 
 == persistence.xml
 
+Aqui nós definimos qual banco de dados vai gravar nossos filmes (Movie) e realizamos outras configurações como: definir uma unidade de persistência (persistence-unit) com o nome movie-unit, seguidos pela definição do provedor/implementação do JPA (no caso o hibernate) e definimos algumas properties para o hibernate:
+
  <persistence version="1.0"
               xmlns="http://java.sun.com/xml/ns/persistence"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -120,6 +141,8 @@ public class Movies {
 
 == MoviesTest
 
+Agora vamos realizar um teste, persistindo três filmes, em seguida realizamos uma busca e por fim nós os deletamos.
+
 ....
 package org.superbiz.injection.h3jpa;
 
@@ -160,14 +183,21 @@ public class MoviesTest extends TestCase {
 }
 ....
 
-= Running
+= Executando
 
-To run the example via maven:
+Para executar o exemplo com o maven, acesse a pasta do projeto:
 
+....
 cd jpa-hibernate
+....
+
+E execute:
+
+....
 mvn clean install
+....
 
-Which will generate output similar to the following:
+Com isso teremos uma saida no terminal similar a esta:
 
 ....
 -------------------------------------------------------