Commits

Micha Kops committed fa2fb99

Persistence properties fixed.

Comments (0)

Files changed (5)

 
 	<dependencies>
 		<dependency>
-			<groupId>org.hamcrest</groupId>
-			<artifactId>hamcrest-all</artifactId>
-			<version>1.3</version>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit</artifactId>
-			<version>4.11</version>
-			<scope>test</scope>
-		</dependency>
-		<!-- be sure not to load an old version of junit-dep by accident -->
-		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit-dep</artifactId>
-			<version>4.11</version>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
 			<groupId>org.eclipse.persistence</groupId>
 			<artifactId>eclipselink</artifactId>
 			<version>2.4.0</version>

src/main/java/com/hascode/tutorial/app/Main.java

 				"Book.findAll.toSimpleBook", SimpleBook.class).getResultList();
 		System.out.println(bookDtos.size()
 				+ " SimpleBook entities' guessed size is: " + sizeOf(bookDtos));
-		printAsJson(books);
-		printAsJson(bookDtos);
+		printAsXml(books);
+		printAsXml(bookDtos);
 		em.close();
 		emf.close();
 	}
 
-	private <T> void printAsJson(final List<T> list) throws JAXBException {
+	private <T> void printAsXml(final List<T> list) throws JAXBException {
 		XStream xs = new XStream();
 		xs.alias("books", Vector.class);
 		xs.alias("book", Book.class);

src/main/java/com/hascode/tutorial/dto/SimpleBook.java

 package com.hascode.tutorial.dto;
 
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement(name = "book")
 public class SimpleBook {
-	private Long id;
-	private String title;
-	private String author;
-
-	public SimpleBook() {
-	}
+	private final Long id;
+	private final String title;
+	private final String author;
 
 	public SimpleBook(final Long id, final String title, final String author) {
 		this.id = id;

src/main/java/com/hascode/tutorial/entity/Book.java

 import javax.persistence.Id;
 import javax.persistence.NamedQueries;
 import javax.persistence.NamedQuery;
-import javax.xml.bind.annotation.XmlRootElement;
 
 @Entity
 @NamedQueries({
 		@NamedQuery(name = "Book.findAll", query = "SELECT b FROM Book b"),
 		@NamedQuery(name = "Book.countAll", query = "SELECT COUNT(b) FROM Book b"),
 		@NamedQuery(name = "Book.findAll.toSimpleBook", query = "SELECT NEW com.hascode.tutorial.dto.SimpleBook(b.id, b.title, b.author) FROM Book b") })
-@XmlRootElement
 public class Book {
 	@Id
 	@GeneratedValue

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

 		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
 		<class>com.hascode.tutorial.entity.Book</class>
 		<properties>
-			<property name="eclipselink.target-database" value="DERBY" />
-			<property name="eclipselink.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
-			<property name="eclipselink.jdbc.url" value="jdbc:derby:test2db;create=true" />
-			<property name="eclipselink.jdbc.user" value="APPT" />
-			<property name="eclipselink.jdbc.password" value="APPT" />
+			<property name="javax.persistence.target-database" value="DERBY" />
+			<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
+			<property name="javax.persistence.jdbc.url" value="jdbc:derby:test2db;create=true" />
+			<property name="javax.persistence.jdbc.user" value="APPT" />
+			<property name="javax.persistence.jdbc.password" value="APPT" />
 			<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
 			<property name="eclipselink.logging.level" value="FINE" />
 		</properties>