fix spring-data-jpa module
This commit is contained in:
@@ -80,5 +80,9 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<start-class>com.baeldung.boot.Application</start-class>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
+3
-2
@@ -1,10 +1,11 @@
|
||||
package com.baeldung;
|
||||
package com.baeldung.boot;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
|
||||
import com.baeldung.dao.repositories.impl.ExtendedRepositoryImpl;
|
||||
import com.baeldung.boot.daos.impl.ExtendedRepositoryImpl;
|
||||
import com.baeldung.multipledb.MultipleDbApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableJpaRepositories(repositoryBaseClass = ExtendedRepositoryImpl.class)
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.baeldung.boot.config;
|
||||
|
||||
import com.baeldung.boot.daos.impl.ExtendedRepositoryImpl;
|
||||
import com.baeldung.boot.services.IBarService;
|
||||
import com.baeldung.boot.services.impl.BarSpringDataJpaService;
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.*;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.orm.jpa.JpaVendorAdapter;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Properties;
|
||||
|
||||
@Configuration
|
||||
@Profile("!tc")
|
||||
public class PersistenceConfiguration {
|
||||
|
||||
@Bean
|
||||
public IBarService barSpringDataJpaService() {
|
||||
return new BarSpringDataJpaService();
|
||||
}
|
||||
|
||||
}
|
||||
+3
-2
@@ -1,10 +1,11 @@
|
||||
package com.baeldung.dao.repositories;
|
||||
package com.baeldung.boot.daos;
|
||||
|
||||
import com.baeldung.domain.Article;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import com.baeldung.boot.domain.Article;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package com.baeldung.dao.repositories;
|
||||
package com.baeldung.boot.daos;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.baeldung.domain.Item;
|
||||
import com.baeldung.boot.domain.Item;
|
||||
|
||||
@Repository
|
||||
public interface CustomItemRepository {
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package com.baeldung.dao.repositories;
|
||||
package com.baeldung.boot.daos;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.baeldung.domain.ItemType;
|
||||
import com.baeldung.boot.domain.ItemType;
|
||||
|
||||
@Repository
|
||||
public interface CustomItemTypeRepository {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.baeldung.dao.repositories;
|
||||
package com.baeldung.boot.daos;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.baeldung.dao.repositories;
|
||||
package com.baeldung.boot.daos;
|
||||
|
||||
import com.baeldung.domain.Student;
|
||||
import com.baeldung.boot.domain.Student;
|
||||
|
||||
public interface ExtendedStudentRepository extends ExtendedRepository<Student, Long> {
|
||||
}
|
||||
+3
-2
@@ -1,8 +1,9 @@
|
||||
package com.baeldung.dao.repositories;
|
||||
package com.baeldung.boot.daos;
|
||||
|
||||
import com.baeldung.domain.Bar;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
import com.baeldung.boot.domain.Bar;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface IBarCrudRepository extends CrudRepository<Bar, Serializable> {
|
||||
+3
-2
@@ -1,10 +1,11 @@
|
||||
package com.baeldung.dao;
|
||||
package com.baeldung.boot.daos;
|
||||
|
||||
import com.baeldung.domain.Foo;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import com.baeldung.boot.domain.Foo;
|
||||
|
||||
public interface IFooDao extends JpaRepository<Foo, Long> {
|
||||
|
||||
@Query("SELECT f FROM Foo f WHERE LOWER(f.name) = LOWER(:name)")
|
||||
+3
-2
@@ -1,7 +1,8 @@
|
||||
package com.baeldung.dao.repositories;
|
||||
package com.baeldung.boot.daos;
|
||||
|
||||
import com.baeldung.domain.MerchandiseEntity;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
import com.baeldung.boot.domain.MerchandiseEntity;
|
||||
|
||||
public interface InventoryRepository extends CrudRepository<MerchandiseEntity, Long> {
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
package com.baeldung.dao.repositories;
|
||||
package com.baeldung.boot.daos;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.baeldung.domain.ItemType;
|
||||
import com.baeldung.boot.domain.ItemType;
|
||||
|
||||
@Repository
|
||||
public interface ItemTypeRepository extends JpaRepository<ItemType, Long>, CustomItemTypeRepository, CustomItemRepository {
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
package com.baeldung.dao.repositories;
|
||||
package com.baeldung.boot.daos;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.baeldung.domain.Location;
|
||||
import com.baeldung.boot.domain.Location;
|
||||
|
||||
@Repository
|
||||
public interface LocationRepository extends JpaRepository<Location, Long> {
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
package com.baeldung.dao.repositories;
|
||||
package com.baeldung.boot.daos;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
import com.baeldung.domain.Location;
|
||||
import com.baeldung.boot.domain.Location;
|
||||
|
||||
@org.springframework.stereotype.Repository
|
||||
public interface ReadOnlyLocationRepository extends Repository<Location, Long> {
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
package com.baeldung.dao.repositories;
|
||||
package com.baeldung.boot.daos;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.baeldung.domain.Store;
|
||||
import com.baeldung.boot.domain.Store;
|
||||
|
||||
@Repository
|
||||
public interface StoreRepository extends JpaRepository<Store, Long> {
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
package com.baeldung.dao.repositories.impl;
|
||||
package com.baeldung.boot.daos.impl;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.baeldung.domain.Item;
|
||||
import com.baeldung.dao.repositories.CustomItemRepository;
|
||||
import com.baeldung.boot.daos.CustomItemRepository;
|
||||
import com.baeldung.boot.domain.Item;
|
||||
|
||||
@Repository
|
||||
public class CustomItemRepositoryImpl implements CustomItemRepository {
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package com.baeldung.dao.repositories.impl;
|
||||
package com.baeldung.boot.daos.impl;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
@@ -7,8 +7,8 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.baeldung.domain.ItemType;
|
||||
import com.baeldung.dao.repositories.CustomItemTypeRepository;
|
||||
import com.baeldung.boot.daos.CustomItemTypeRepository;
|
||||
import com.baeldung.boot.domain.ItemType;
|
||||
|
||||
@Repository
|
||||
public class CustomItemTypeRepositoryImpl implements CustomItemTypeRepository {
|
||||
+3
-2
@@ -1,4 +1,4 @@
|
||||
package com.baeldung.dao.repositories.impl;
|
||||
package com.baeldung.boot.daos.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
@@ -10,10 +10,11 @@ import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import com.baeldung.dao.repositories.ExtendedRepository;
|
||||
import org.springframework.data.jpa.repository.support.JpaEntityInformation;
|
||||
import org.springframework.data.jpa.repository.support.SimpleJpaRepository;
|
||||
|
||||
import com.baeldung.boot.daos.ExtendedRepository;
|
||||
|
||||
public class ExtendedRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRepository<T, ID> implements ExtendedRepository<T, ID> {
|
||||
|
||||
private EntityManager entityManager;
|
||||
+3
-2
@@ -1,8 +1,9 @@
|
||||
package com.baeldung.dao.repositories.impl;
|
||||
package com.baeldung.boot.daos.impl;
|
||||
|
||||
import com.baeldung.domain.Person;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.baeldung.boot.domain.Person;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.transaction.Transactional;
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.baeldung.ddd.event;
|
||||
package com.baeldung.boot.ddd.event;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.baeldung.ddd.event;
|
||||
package com.baeldung.boot.ddd.event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.baeldung.ddd.event;
|
||||
package com.baeldung.boot.ddd.event;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.baeldung.ddd.event;
|
||||
package com.baeldung.boot.ddd.event;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.baeldung.ddd.event;
|
||||
package com.baeldung.boot.ddd.event;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.baeldung.ddd.event;
|
||||
package com.baeldung.boot.ddd.event;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.baeldung.ddd.event;
|
||||
package com.baeldung.boot.ddd.event;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.baeldung.boot.ddd.event;
|
||||
|
||||
class DomainEvent {
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.baeldung.ddd.event;
|
||||
package com.baeldung.boot.ddd.event;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.baeldung.domain;
|
||||
package com.baeldung.boot.domain;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.baeldung.domain;
|
||||
package com.baeldung.boot.domain;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.hibernate.annotations.OrderBy;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user