1. Micha Kops
  2. flyway-migrations-tutorial

Commits

Micha Kops  committed 8f1f3dd

Persistence context setup fixed.

  • Participants
  • Parent commits 807f80c
  • Branches master

Comments (0)

Files changed (4)

File src/main/java/com/hascode/ejb/BookEJB.java

View file
  • Ignore whitespace
 
 import javax.ejb.Stateless;
 import javax.persistence.EntityManager;
-import javax.persistence.PersistenceUnit;
+import javax.persistence.PersistenceContext;
 
 import com.hascode.entity.Book;
 
 @Stateless
 public class BookEJB implements BookService {
-	@PersistenceUnit(unitName = "hascode-jta-unit")
+	@PersistenceContext(unitName = "hascode-jta-unit")
 	private EntityManager em;
 
-	/* (non-Javadoc)
+	/*
+	 * (non-Javadoc)
+	 * 
 	 * @see com.hascode.ejb.BookService#findAll()
 	 */
 	@Override

File src/main/java/com/hascode/servlet/BookServlet.java

View file
  • Ignore whitespace
 			return;
 		}
 
-		resp.getWriter().append(books.size() + " books");
+		resp.getWriter().append(
+				books.size() + " books:\n---------------------------------\n");
 		for (Book book : books) {
-			resp.getWriter().append(book.getTitle() + "\n");
+			resp.getWriter().append("- " + book.getTitle() + "\n");
 		}
 	}
 

File src/main/resources/META-INF/persistence.xml

View file
  • Ignore whitespace
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+	version="1.0">
+	<persistence-unit name="hascode-jta-unit"
+		transaction-type="JTA">
+		<provider>org.hibernate.ejb.HibernatePersistence</provider>
+		<jta-data-source>jdbc/__default</jta-data-source>
+		<class>com.hascode.entity.Book</class>
+	</persistence-unit>
+</persistence>

File src/test/resources/META-INF/persistence.xml

  • Ignore whitespace
-<?xml version="1.0" encoding="UTF-8"?>
-<persistence xmlns="http://java.sun.com/xml/ns/persistence"
-	version="1.0">
-	<persistence-unit name="hascode-jta-unit"
-		transaction-type="JTA">
-		<provider>org.hibernate.ejb.HibernatePersistence</provider>
-		<jta-data-source>jdbc/__default</jta-data-source>
-		<class>com.hascode.entity.Book</class>
-	</persistence-unit>
-</persistence>