fixed some code

This commit is contained in:
Liesheng Long 2019-05-20 21:59:47 -04:00
parent 552b2b2fa9
commit 2c9c96a811
3 changed files with 6 additions and 2 deletions

View File

@ -12,6 +12,8 @@ public class PersistOptionalTypeExample {
static EntityManager entityManager = emf.createEntityManager(); static EntityManager entityManager = emf.createEntityManager();
//to run this app, uncomment the follow line in META-INF/persistence.xml
//<class>com.baeldung.optionalReturnType.UserOptionalField</class>
public static void main(String[] args) { public static void main(String[] args) {
UserOptionalField user1 = new UserOptionalField(); UserOptionalField user1 = new UserOptionalField();
user1.setUserId(1l); user1.setUserId(1l);

View File

@ -4,7 +4,7 @@ import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory; import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence; import javax.persistence.Persistence;
public class PersistUserNoOptionalExample { public class PersistUserExample {
static String persistenceUnit = "com.baeldung.optionalReturnType"; static String persistenceUnit = "com.baeldung.optionalReturnType";
static EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit); static EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit);

View File

@ -9,9 +9,11 @@
transaction-type="RESOURCE_LOCAL"> transaction-type="RESOURCE_LOCAL">
<description>Persist Optional Return Type Demo</description> <description>Persist Optional Return Type Demo</description>
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.baeldung.optionalReturnType.UserNoOptional</class> <class>com.baeldung.optionalReturnType.User</class>
<class>com.baeldung.optionalReturnType.UserOptional</class> <class>com.baeldung.optionalReturnType.UserOptional</class>
<!--
<class>com.baeldung.optionalReturnType.UserOptionalField</class> <class>com.baeldung.optionalReturnType.UserOptionalField</class>
-->
<exclude-unlisted-classes>true</exclude-unlisted-classes> <exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties> <properties>