Split or move persistence-modules/java-jpa module (#7887)

This commit is contained in:
Catalin Burcea 2019-09-28 21:06:14 +03:00 committed by Josh Cummings
parent 0b834830b9
commit c5e7773a51
34 changed files with 296 additions and 301 deletions

View File

@ -1,4 +1,8 @@
# Relevant Articles
- [JPA Query Parameters Usage](http://www.baeldung.com/jpa-query-parameters-usage)
- [JPA Query Parameters Usage](https://www.baeldung.com/jpa-query-parameters-usage)
- [Mapping Entitiy Class Names to SQL Table Names with JPA](https://www.baeldung.com/jpa-entity-table-names)
- [Default Column Values in JPA](https://www.baeldung.com/jpa-default-column-values)
- [Types of JPA Queries](https://www.baeldung.com/jpa-queries)
- [JPA/Hibernate Projections](https://www.baeldung.com/jpa-hibernate-projections)
- [Combining JPA And/Or Criteria Predicates](https://www.baeldung.com/jpa-and-or-criteria-predicates)

View File

@ -1,12 +1,10 @@
package com.baeldung.jpa.criteria.repository;
import java.util.List;
import com.baeldung.jpa.criteria.entity.Item;
public interface CustomItemRepository {
List<Item> findItemsByColorAndGrade();
List<Item> findItemByColorOrGrade();
}
package com.baeldung.jpa.criteria;
import java.util.List;
public interface CustomItemRepository {
List<Item> findItemsByColorAndGrade();
List<Item> findItemByColorOrGrade();
}

View File

@ -1,77 +1,72 @@
package com.baeldung.jpa.criteria.repository.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.baeldung.jpa.criteria.entity.Item;
import com.baeldung.jpa.criteria.repository.CustomItemRepository;
public class CustomItemRepositoryImpl implements CustomItemRepository {
private EntityManager entityManager;
public CustomItemRepositoryImpl() {
super();
EntityManagerFactory factory = Persistence.createEntityManagerFactory("jpa-h2-criteria");
entityManager = factory.createEntityManager();
}
@Override
public List<Item> findItemsByColorAndGrade() {
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Item> criteriaQuery = criteriaBuilder.createQuery(Item.class);
Root<Item> itemRoot = criteriaQuery.from(Item.class);
Predicate predicateForBlueColor = criteriaBuilder.equal(itemRoot.get("color"), "blue");
Predicate predicateForRedColor = criteriaBuilder.equal(itemRoot.get("color"), "red");
Predicate predicateForColor = criteriaBuilder.or(predicateForBlueColor, predicateForRedColor);
Predicate predicateForGradeA = criteriaBuilder.equal(itemRoot.get("grade"), "A");
Predicate predicateForGradeB = criteriaBuilder.equal(itemRoot.get("grade"), "B");
Predicate predicateForGrade = criteriaBuilder.or(predicateForGradeA, predicateForGradeB);
// final search filter
Predicate finalPredicate = criteriaBuilder.and(predicateForColor, predicateForGrade);
criteriaQuery.where(finalPredicate);
List<Item> items = entityManager.createQuery(criteriaQuery)
.getResultList();
return items;
}
@Override
public List<Item> findItemByColorOrGrade() {
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Item> criteriaQuery = criteriaBuilder.createQuery(Item.class);
Root<Item> itemRoot = criteriaQuery.from(Item.class);
Predicate predicateForBlueColor = criteriaBuilder.equal(itemRoot.get("color"), "red");
Predicate predicateForGradeA = criteriaBuilder.equal(itemRoot.get("grade"), "D");
Predicate predicateForBlueColorAndGradeA = criteriaBuilder.and(predicateForBlueColor, predicateForGradeA);
Predicate predicateForRedColor = criteriaBuilder.equal(itemRoot.get("color"), "blue");
Predicate predicateForGradeB = criteriaBuilder.equal(itemRoot.get("grade"), "B");
Predicate predicateForRedColorAndGradeB = criteriaBuilder.and(predicateForRedColor, predicateForGradeB);
// final search filter
Predicate finalPredicate = criteriaBuilder.or(predicateForBlueColorAndGradeA, predicateForRedColorAndGradeB);
criteriaQuery.where(finalPredicate);
List<Item> items = entityManager.createQuery(criteriaQuery)
.getResultList();
return items;
}
}
package com.baeldung.jpa.criteria;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
public class CustomItemRepositoryImpl implements CustomItemRepository {
private EntityManager entityManager;
public CustomItemRepositoryImpl() {
super();
EntityManagerFactory factory = Persistence.createEntityManagerFactory("jpa-h2-criteria");
entityManager = factory.createEntityManager();
}
@Override
public List<Item> findItemsByColorAndGrade() {
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Item> criteriaQuery = criteriaBuilder.createQuery(Item.class);
Root<Item> itemRoot = criteriaQuery.from(Item.class);
Predicate predicateForBlueColor = criteriaBuilder.equal(itemRoot.get("color"), "blue");
Predicate predicateForRedColor = criteriaBuilder.equal(itemRoot.get("color"), "red");
Predicate predicateForColor = criteriaBuilder.or(predicateForBlueColor, predicateForRedColor);
Predicate predicateForGradeA = criteriaBuilder.equal(itemRoot.get("grade"), "A");
Predicate predicateForGradeB = criteriaBuilder.equal(itemRoot.get("grade"), "B");
Predicate predicateForGrade = criteriaBuilder.or(predicateForGradeA, predicateForGradeB);
// final search filter
Predicate finalPredicate = criteriaBuilder.and(predicateForColor, predicateForGrade);
criteriaQuery.where(finalPredicate);
List<Item> items = entityManager.createQuery(criteriaQuery)
.getResultList();
return items;
}
@Override
public List<Item> findItemByColorOrGrade() {
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Item> criteriaQuery = criteriaBuilder.createQuery(Item.class);
Root<Item> itemRoot = criteriaQuery.from(Item.class);
Predicate predicateForBlueColor = criteriaBuilder.equal(itemRoot.get("color"), "red");
Predicate predicateForGradeA = criteriaBuilder.equal(itemRoot.get("grade"), "D");
Predicate predicateForBlueColorAndGradeA = criteriaBuilder.and(predicateForBlueColor, predicateForGradeA);
Predicate predicateForRedColor = criteriaBuilder.equal(itemRoot.get("color"), "blue");
Predicate predicateForGradeB = criteriaBuilder.equal(itemRoot.get("grade"), "B");
Predicate predicateForRedColorAndGradeB = criteriaBuilder.and(predicateForRedColor, predicateForGradeB);
// final search filter
Predicate finalPredicate = criteriaBuilder.or(predicateForBlueColorAndGradeA, predicateForRedColorAndGradeB);
criteriaQuery.where(finalPredicate);
List<Item> items = entityManager.createQuery(criteriaQuery)
.getResultList();
return items;
}
}

View File

@ -1,49 +1,49 @@
package com.baeldung.jpa.criteria.entity;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Table(name = "item")
@Entity
public class Item {
@Id
private Long id;
private String color;
private String grade;
private String name;
public String getColor() {
return color;
}
public String getGrade() {
return grade;
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
public void setColor(String color) {
this.color = color;
}
public void setGrade(String grade) {
this.grade = grade;
}
public void setId(Long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
}
package com.baeldung.jpa.criteria;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Table(name = "item")
@Entity
public class Item {
@Id
private Long id;
private String color;
private String grade;
private String name;
public String getColor() {
return color;
}
public String getGrade() {
return grade;
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
public void setColor(String color) {
this.color = color;
}
public void setGrade(String grade) {
this.grade = grade;
}
public void setId(Long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -32,4 +32,91 @@
value="queryparams.sql" />
</properties>
</persistence-unit>
<persistence-unit name="entity-default-values">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.baeldung.jpa.defaultvalues.User</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.driver"
value="org.h2.Driver" />
<property name="javax.persistence.jdbc.url"
value="jdbc:h2:mem:test" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="hibernate.dialect"
value="org.hibernate.dialect.H2Dialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="show_sql" value="true" />
<property name="hibernate.temp.use_jdbc_metadata_defaults"
value="false" />
</properties>
</persistence-unit>
<persistence-unit name="jpa-query-types">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.baeldung.jpa.querytypes.UserEntity</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.driver"
value="org.h2.Driver" />
<property name="javax.persistence.jdbc.url"
value="jdbc:h2:mem:test" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="hibernate.dialect"
value="org.hibernate.dialect.H2Dialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="show_sql" value="true" />
<property name="hibernate.temp.use_jdbc_metadata_defaults"
value="false" />
<property name="javax.persistence.sql-load-script-source"
value="users.sql" />
</properties>
</persistence-unit>
<persistence-unit name="jpa-projections">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.baeldung.jpa.projections.Product</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.driver"
value="org.h2.Driver" />
<property name="javax.persistence.jdbc.url"
value="jdbc:h2:mem:test" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="hibernate.dialect"
value="org.hibernate.dialect.H2Dialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="show_sql" value="true" />
<property name="hibernate.temp.use_jdbc_metadata_defaults"
value="false" />
<property name="javax.persistence.sql-load-script-source"
value="products_jpa.sql" />
</properties>
</persistence-unit>
<persistence-unit name="jpa-h2-criteria">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.baeldung.jpa.criteria.Item</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.driver"
value="org.h2.Driver" />
<property name="javax.persistence.jdbc.url"
value="jdbc:h2:mem:test" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="hibernate.dialect"
value="org.hibernate.dialect.H2Dialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="show_sql" value="true" />
<property name="hibernate.temp.use_jdbc_metadata_defaults"
value="false" />
<property name="javax.persistence.sql-load-script-source"
value="item.sql" />
</properties>
</persistence-unit>
</persistence>

View File

@ -1,4 +1,4 @@
insert into item(id,grade,color) values (10,'C','blue');
insert into item(id,grade,color) values (11,'C','red');
insert into item(id,grade,color) values (12,'A','blue');
insert into item(id,grade,color) values (10,'C','blue');
insert into item(id,grade,color) values (11,'C','red');
insert into item(id,grade,color) values (12,'A','blue');
insert into item(id,grade,color) values (13,'D','red');

View File

@ -1,44 +1,44 @@
package com.baeldung.jpa.criteria.repository.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import java.util.List;
import org.junit.Test;
import com.baeldung.jpa.criteria.entity.Item;
import com.baeldung.jpa.criteria.repository.CustomItemRepository;
public class CustomItemRepositoryIntegrationTest {
CustomItemRepository customItemRepository = new CustomItemRepositoryImpl();
@Test
public void givenItems_whenFindItemsByColorAndGrade_thenReturnItems() {
List<Item> items = customItemRepository.findItemsByColorAndGrade();
assertFalse("No items found", items.isEmpty());
assertEquals("There should be only one item", 1, items.size());
Item item = items.get(0);
assertEquals("this item do not have blue color", "blue", item.getColor());
assertEquals("this item does not belong to A grade", "A", item.getGrade());
}
@Test
public void givenItems_whenFindItemByColorOrGrade_thenReturnItems() {
List<Item> items = customItemRepository.findItemByColorOrGrade();
assertFalse("No items found", items.isEmpty());
assertEquals("There should be only one item", 1, items.size());
Item item = items.get(0);
assertEquals("this item do not have red color", "red", item.getColor());
assertEquals("this item does not belong to D grade", "D", item.getGrade());
}
}
package com.baeldung.jpa.criteria;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import java.util.List;
import org.junit.Test;
import com.baeldung.jpa.criteria.Item;
import com.baeldung.jpa.criteria.CustomItemRepository;
public class CustomItemRepositoryIntegrationTest {
CustomItemRepository customItemRepository = new CustomItemRepositoryImpl();
@Test
public void givenItems_whenFindItemsByColorAndGrade_thenReturnItems() {
List<Item> items = customItemRepository.findItemsByColorAndGrade();
assertFalse("No items found", items.isEmpty());
assertEquals("There should be only one item", 1, items.size());
Item item = items.get(0);
assertEquals("this item do not have blue color", "blue", item.getColor());
assertEquals("this item does not belong to A grade", "A", item.getGrade());
}
@Test
public void givenItems_whenFindItemByColorOrGrade_thenReturnItems() {
List<Item> items = customItemRepository.findItemByColorOrGrade();
assertFalse("No items found", items.isEmpty());
assertEquals("There should be only one item", 1, items.size());
Item item = items.get(0);
assertEquals("this item do not have red color", "red", item.getColor());
assertEquals("this item does not belong to D grade", "D", item.getGrade());
}
}

View File

@ -1,16 +1,12 @@
# Relevant Articles
- [A Guide to SqlResultSetMapping](http://www.baeldung.com/jpa-sql-resultset-mapping)
- [A Guide to Stored Procedures with JPA](http://www.baeldung.com/jpa-stored-procedures)
- [A Guide to SqlResultSetMapping](https://www.baeldung.com/jpa-sql-resultset-mapping)
- [A Guide to Stored Procedures with JPA](https://www.baeldung.com/jpa-stored-procedures)
- [Fixing the JPA error “java.lang.String cannot be cast to Ljava.lang.String;”](https://www.baeldung.com/jpa-error-java-lang-string-cannot-be-cast)
- [JPA Entity Graph](https://www.baeldung.com/jpa-entity-graph)
- [JPA 2.2 Support for Java 8 Date/Time Types](https://www.baeldung.com/jpa-java-time)
- [Converting Between LocalDate and SQL Date](https://www.baeldung.com/java-convert-localdate-sql-date)
- [Combining JPA And/Or Criteria Predicates](https://www.baeldung.com/jpa-and-or-criteria-predicates)
- [Types of JPA Queries](https://www.baeldung.com/jpa-queries)
- [JPA/Hibernate Projections](https://www.baeldung.com/jpa-hibernate-projections)
- [Composite Primary Keys in JPA](https://www.baeldung.com/jpa-composite-primary-keys)
- [Defining JPA Entities](https://www.baeldung.com/jpa-entities)
- [JPA @Basic Annotation](https://www.baeldung.com/jpa-basic-annotation)
- [Default Column Values in JPA](https://www.baeldung.com/jpa-default-column-values)
- [Persisting Enums in JPA](https://www.baeldung.com/jpa-persisting-enums-in-jpa)

View File

@ -1,4 +1,4 @@
package com.baeldung.util;
package com.baeldung.jpa.convertdates;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

View File

@ -1,4 +1,4 @@
package com.baeldung.util;
package com.baeldung.jpa.entity;
public enum Gender {
MALE,

View File

@ -14,8 +14,6 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import com.baeldung.util.Gender;
@Entity
@Table(name="STUDENT")
public class Student {

View File

@ -1,4 +1,4 @@
package com.baeldung.jpa.entity;
package com.baeldung.jpa.primarykeys;
import javax.persistence.Entity;
import javax.persistence.Id;

View File

@ -1,4 +1,4 @@
package com.baeldung.jpa.entity;
package com.baeldung.jpa.primarykeys;
import java.io.Serializable;

View File

@ -1,4 +1,4 @@
package com.baeldung.jpa.entity;
package com.baeldung.jpa.primarykeys;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;

View File

@ -1,4 +1,4 @@
package com.baeldung.jpa.entity;
package com.baeldung.jpa.primarykeys;
import java.io.Serializable;

View File

@ -1,4 +1,4 @@
package com.baeldung.sqlresultsetmapping;
package com.baeldung.jpa.sqlresultsetmapping;
import javax.persistence.*;
@ -7,7 +7,7 @@ import javax.persistence.*;
name="EmployeeResult",
entities={
@EntityResult(
entityClass = com.baeldung.sqlresultsetmapping.Employee.class,
entityClass = com.baeldung.jpa.sqlresultsetmapping.Employee.class,
fields={@FieldResult(name="id",column="employeeNumber"),
@FieldResult(name="name", column="name")}
)

View File

@ -1,18 +1,18 @@
package com.baeldung.sqlresultsetmapping;
package com.baeldung.jpa.sqlresultsetmapping;
import javax.persistence.*;
@SqlResultSetMappings(value = {
@SqlResultSetMapping(name = "ScheduleResult",
classes = { @ConstructorResult(targetClass = com.baeldung.sqlresultsetmapping.ScheduledDay.class,
classes = { @ConstructorResult(targetClass = com.baeldung.jpa.sqlresultsetmapping.ScheduledDay.class,
columns = { @ColumnResult(name = "id", type = Long.class),
@ColumnResult(name = "employeeId", type = Long.class),
@ColumnResult(name = "dayOfWeek") }) }),
@SqlResultSetMapping(name = "FridayEmployeeResult",
columns = { @ColumnResult(name = "employeeId") }),
@SqlResultSetMapping(name = "EmployeeScheduleResults",
entities = { @EntityResult(entityClass = com.baeldung.sqlresultsetmapping.Employee.class),
@EntityResult(entityClass = com.baeldung.sqlresultsetmapping.ScheduledDay.class)
entities = { @EntityResult(entityClass = com.baeldung.jpa.sqlresultsetmapping.Employee.class),
@EntityResult(entityClass = com.baeldung.jpa.sqlresultsetmapping.ScheduledDay.class)
}) })
@NamedNativeQuery(name = "FridayEmployees",
query = "SELECT employeeId FROM schedule_days WHERE dayOfWeek = 'FRIDAY'",

View File

@ -7,8 +7,8 @@
<persistence-unit name="java-jpa-scheduled-day">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.baeldung.sqlresultsetmapping.ScheduledDay</class>
<class>com.baeldung.sqlresultsetmapping.Employee</class>
<class>com.baeldung.jpa.sqlresultsetmapping.ScheduledDay</class>
<class>com.baeldung.jpa.sqlresultsetmapping.Employee</class>
<class>com.baeldung.jpa.basicannotation.Course</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
@ -115,77 +115,13 @@
</properties>
</persistence-unit>
<persistence-unit name="jpa-h2-criteria">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.baeldung.jpa.criteria.entity.Item</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.driver"
value="org.h2.Driver" />
<property name="javax.persistence.jdbc.url"
value="jdbc:h2:mem:test" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="hibernate.dialect"
value="org.hibernate.dialect.H2Dialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="show_sql" value="true" />
<property name="hibernate.temp.use_jdbc_metadata_defaults"
value="false" />
<property name="javax.persistence.sql-load-script-source"
value="item.sql" />
</properties>
</persistence-unit>
<persistence-unit name="jpa-query-types">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.baeldung.jpa.querytypes.UserEntity</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.driver"
value="org.h2.Driver" />
<property name="javax.persistence.jdbc.url"
value="jdbc:h2:mem:test" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="hibernate.dialect"
value="org.hibernate.dialect.H2Dialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="show_sql" value="true" />
<property name="hibernate.temp.use_jdbc_metadata_defaults"
value="false" />
<property name="javax.persistence.sql-load-script-source"
value="users.sql" />
</properties>
</persistence-unit>
<persistence-unit name="entity-default-values">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.baeldung.jpa.defaultvalues.User</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.driver"
value="org.h2.Driver" />
<property name="javax.persistence.jdbc.url"
value="jdbc:h2:mem:test" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="hibernate.dialect"
value="org.hibernate.dialect.H2Dialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="show_sql" value="true" />
<property name="hibernate.temp.use_jdbc_metadata_defaults"
value="false" />
</properties>
</persistence-unit>
<persistence-unit name="jpa-entity-definition">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.baeldung.jpa.entity.Student</class>
<class>com.baeldung.jpa.entity.Book</class>
<class>com.baeldung.jpa.entity.BookId</class>
<class>com.baeldung.jpa.entity.Account</class>
<class>com.baeldung.jpa.entity.AccountId</class>
<class>com.baeldung.jpa.primarykeys.Book</class>
<class>com.baeldung.jpa.primarykeys.BookId</class>
<class>com.baeldung.jpa.primarykeys.Account</class>
<class>com.baeldung.jpa.primarykeys.AccountId</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.driver"
@ -203,25 +139,4 @@
</properties>
</persistence-unit>
<persistence-unit name="jpa-projections">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.baeldung.jpa.projections.Product</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.driver"
value="org.h2.Driver" />
<property name="javax.persistence.jdbc.url"
value="jdbc:h2:mem:test" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="hibernate.dialect"
value="org.hibernate.dialect.H2Dialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="show_sql" value="true" />
<property name="hibernate.temp.use_jdbc_metadata_defaults"
value="false" />
<property name="javax.persistence.sql-load-script-source"
value="products_jpa.sql" />
</properties>
</persistence-unit>
</persistence>

View File

@ -16,8 +16,6 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.baeldung.util.Gender;
public class StudentEntityIntegrationTest {
private EntityManagerFactory emf;

View File

@ -1,4 +1,4 @@
package com.baeldung.jpa.entity;
package com.baeldung.jpa.primarykeys;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -7,6 +7,10 @@ import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import com.baeldung.jpa.primarykeys.Account;
import com.baeldung.jpa.primarykeys.AccountId;
import com.baeldung.jpa.primarykeys.Book;
import com.baeldung.jpa.primarykeys.BookId;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

View File

@ -1,4 +1,4 @@
package com.baeldung.sqlresultsetmapping;
package com.baeldung.jpa.sqlresultsetmapping;
import static org.junit.Assert.*;