From 2c9c96a811f2cd1ebf90af4f2f042e795c598eb6 Mon Sep 17 00:00:00 2001 From: Liesheng Long Date: Mon, 20 May 2019 21:59:47 -0400 Subject: [PATCH] fixed some code --- .../optionalReturnType/PersistOptionalTypeExample.java | 2 ++ ...sistUserNoOptionalExample.java => PersistUserExample.java} | 2 +- .../core-java-8-2/src/main/resources/META-INF/persistence.xml | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) rename core-java-modules/core-java-8-2/src/main/java/com/baeldung/optionalReturnType/{PersistUserNoOptionalExample.java => PersistUserExample.java} (93%) diff --git a/core-java-modules/core-java-8-2/src/main/java/com/baeldung/optionalReturnType/PersistOptionalTypeExample.java b/core-java-modules/core-java-8-2/src/main/java/com/baeldung/optionalReturnType/PersistOptionalTypeExample.java index afe46ca7eb..681fae565b 100644 --- a/core-java-modules/core-java-8-2/src/main/java/com/baeldung/optionalReturnType/PersistOptionalTypeExample.java +++ b/core-java-modules/core-java-8-2/src/main/java/com/baeldung/optionalReturnType/PersistOptionalTypeExample.java @@ -12,6 +12,8 @@ public class PersistOptionalTypeExample { static EntityManager entityManager = emf.createEntityManager(); + //to run this app, uncomment the follow line in META-INF/persistence.xml + //com.baeldung.optionalReturnType.UserOptionalField public static void main(String[] args) { UserOptionalField user1 = new UserOptionalField(); user1.setUserId(1l); diff --git a/core-java-modules/core-java-8-2/src/main/java/com/baeldung/optionalReturnType/PersistUserNoOptionalExample.java b/core-java-modules/core-java-8-2/src/main/java/com/baeldung/optionalReturnType/PersistUserExample.java similarity index 93% rename from core-java-modules/core-java-8-2/src/main/java/com/baeldung/optionalReturnType/PersistUserNoOptionalExample.java rename to core-java-modules/core-java-8-2/src/main/java/com/baeldung/optionalReturnType/PersistUserExample.java index dba67feecd..af17f83c6e 100644 --- a/core-java-modules/core-java-8-2/src/main/java/com/baeldung/optionalReturnType/PersistUserNoOptionalExample.java +++ b/core-java-modules/core-java-8-2/src/main/java/com/baeldung/optionalReturnType/PersistUserExample.java @@ -4,7 +4,7 @@ import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; -public class PersistUserNoOptionalExample { +public class PersistUserExample { static String persistenceUnit = "com.baeldung.optionalReturnType"; static EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit); diff --git a/core-java-modules/core-java-8-2/src/main/resources/META-INF/persistence.xml b/core-java-modules/core-java-8-2/src/main/resources/META-INF/persistence.xml index 3a05c733ee..e8cd723ec2 100644 --- a/core-java-modules/core-java-8-2/src/main/resources/META-INF/persistence.xml +++ b/core-java-modules/core-java-8-2/src/main/resources/META-INF/persistence.xml @@ -9,9 +9,11 @@ transaction-type="RESOURCE_LOCAL"> Persist Optional Return Type Demo org.hibernate.jpa.HibernatePersistenceProvider - com.baeldung.optionalReturnType.UserNoOptional + com.baeldung.optionalReturnType.User com.baeldung.optionalReturnType.UserOptional + true