Rename package to conform to standards
This commit is contained in:
parent
825940ba7c
commit
226e23b603
|
@ -1,6 +1,6 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>spring-hibernate4</artifactId>
|
<artifactId>spring-hibernate4</artifactId>
|
||||||
<version>0.1-SNAPSHOT</version>
|
<version>0.1-SNAPSHOT</version>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.baeldung.persistence.dao;
|
||||||
|
|
||||||
|
import com.baeldung.persistence.dao.common.IAuditOperations;
|
||||||
|
import com.baeldung.persistence.model.Bar;
|
||||||
|
|
||||||
|
public interface IBarAuditableDao extends IBarDao, IAuditOperations<Bar> {
|
||||||
|
//
|
||||||
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
package org.baeldung.persistence.dao;
|
package com.baeldung.persistence.dao;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.baeldung.persistence.model.Bar;
|
import com.baeldung.persistence.model.Bar;
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
|
||||||
public interface IBarCrudRepository extends CrudRepository<Bar, Serializable> {
|
public interface IBarCrudRepository extends CrudRepository<Bar, Serializable> {
|
||||||
//
|
//
|
||||||
}
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.baeldung.persistence.dao;
|
||||||
|
|
||||||
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
|
import com.baeldung.persistence.model.Bar;
|
||||||
|
|
||||||
|
public interface IBarDao extends IOperations<Bar> {
|
||||||
|
//
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.baeldung.persistence.dao;
|
||||||
|
|
||||||
|
import com.baeldung.persistence.model.Child;
|
||||||
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
|
|
||||||
|
public interface IChildDao extends IOperations<Child> {
|
||||||
|
//
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.baeldung.persistence.dao;
|
||||||
|
|
||||||
|
import com.baeldung.persistence.dao.common.IAuditOperations;
|
||||||
|
import com.baeldung.persistence.model.Foo;
|
||||||
|
|
||||||
|
public interface IFooAuditableDao extends IFooDao, IAuditOperations<Foo> {
|
||||||
|
//
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.baeldung.persistence.dao;
|
||||||
|
|
||||||
|
import com.baeldung.persistence.model.Foo;
|
||||||
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
|
|
||||||
|
public interface IFooDao extends IOperations<Foo> {
|
||||||
|
//
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.baeldung.persistence.dao;
|
||||||
|
|
||||||
|
import com.baeldung.persistence.model.Parent;
|
||||||
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
|
|
||||||
|
public interface IParentDao extends IOperations<Parent> {
|
||||||
|
//
|
||||||
|
}
|
|
@ -1,14 +1,14 @@
|
||||||
package org.baeldung.persistence.dao.common;
|
package com.baeldung.persistence.dao.common;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
public abstract class AbstractDao<T extends Serializable> implements IOperations<T> {
|
public abstract class AbstractDao<T extends Serializable> implements IOperations<T> {
|
||||||
|
|
||||||
protected Class<T> clazz;
|
protected Class<T> clazz;
|
||||||
|
|
||||||
protected final void setClazz(final Class<T> clazzToSet) {
|
protected final void setClazz(final Class<T> clazzToSet) {
|
||||||
clazz = Preconditions.checkNotNull(clazzToSet);
|
clazz = Preconditions.checkNotNull(clazzToSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,37 +1,37 @@
|
||||||
package org.baeldung.persistence.dao.common;
|
package com.baeldung.persistence.dao.common;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.envers.AuditReader;
|
import org.hibernate.envers.AuditReader;
|
||||||
import org.hibernate.envers.AuditReaderFactory;
|
import org.hibernate.envers.AuditReaderFactory;
|
||||||
import org.hibernate.envers.query.AuditQuery;
|
import org.hibernate.envers.query.AuditQuery;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class AbstractHibernateAuditableDao<T extends Serializable> extends AbstractHibernateDao<T> implements IAuditOperations<T> {
|
public class AbstractHibernateAuditableDao<T extends Serializable> extends AbstractHibernateDao<T> implements IAuditOperations<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> getEntitiesAtRevision(final Number revision) {
|
public List<T> getEntitiesAtRevision(final Number revision) {
|
||||||
final AuditReader auditReader = AuditReaderFactory.get(getCurrentSession());
|
final AuditReader auditReader = AuditReaderFactory.get(getCurrentSession());
|
||||||
final AuditQuery query = auditReader.createQuery().forEntitiesAtRevision(clazz, revision);
|
final AuditQuery query = auditReader.createQuery().forEntitiesAtRevision(clazz, revision);
|
||||||
final List<T> resultList = query.getResultList();
|
final List<T> resultList = query.getResultList();
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> getEntitiesModifiedAtRevision(final Number revision) {
|
public List<T> getEntitiesModifiedAtRevision(final Number revision) {
|
||||||
final AuditReader auditReader = AuditReaderFactory.get(getCurrentSession());
|
final AuditReader auditReader = AuditReaderFactory.get(getCurrentSession());
|
||||||
final AuditQuery query = auditReader.createQuery().forEntitiesModifiedAtRevision(clazz, revision);
|
final AuditQuery query = auditReader.createQuery().forEntitiesModifiedAtRevision(clazz, revision);
|
||||||
final List<T> resultList = query.getResultList();
|
final List<T> resultList = query.getResultList();
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> getRevisions() {
|
public List<T> getRevisions() {
|
||||||
final AuditReader auditReader = AuditReaderFactory.get(getCurrentSession());
|
final AuditReader auditReader = AuditReaderFactory.get(getCurrentSession());
|
||||||
final AuditQuery query = auditReader.createQuery().forRevisionsOfEntity(clazz, true, true);
|
final AuditQuery query = auditReader.createQuery().forRevisionsOfEntity(clazz, true, true);
|
||||||
final List<T> resultList = query.getResultList();
|
final List<T> resultList = query.getResultList();
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.persistence.dao.common;
|
package com.baeldung.persistence.dao.common;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
|
@ -1,56 +1,56 @@
|
||||||
package org.baeldung.persistence.dao.common;
|
package com.baeldung.persistence.dao.common;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
import javax.persistence.TypedQuery;
|
import javax.persistence.TypedQuery;
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
public class AbstractJpaDao<T extends Serializable> extends AbstractDao<T> implements IOperations<T> {
|
public class AbstractJpaDao<T extends Serializable> extends AbstractDao<T> implements IOperations<T> {
|
||||||
|
|
||||||
@PersistenceContext
|
@PersistenceContext
|
||||||
private EntityManager em;
|
private EntityManager em;
|
||||||
|
|
||||||
// API
|
// API
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T findOne(final long id) {
|
public T findOne(final long id) {
|
||||||
return em.find(clazz, Long.valueOf(id).intValue());
|
return em.find(clazz, Long.valueOf(id).intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> findAll() {
|
public List<T> findAll() {
|
||||||
final CriteriaBuilder cb = em.getCriteriaBuilder();
|
final CriteriaBuilder cb = em.getCriteriaBuilder();
|
||||||
final CriteriaQuery<T> cq = cb.createQuery(clazz);
|
final CriteriaQuery<T> cq = cb.createQuery(clazz);
|
||||||
final Root<T> rootEntry = cq.from(clazz);
|
final Root<T> rootEntry = cq.from(clazz);
|
||||||
final CriteriaQuery<T> all = cq.select(rootEntry);
|
final CriteriaQuery<T> all = cq.select(rootEntry);
|
||||||
final TypedQuery<T> allQuery = em.createQuery(all);
|
final TypedQuery<T> allQuery = em.createQuery(all);
|
||||||
return allQuery.getResultList();
|
return allQuery.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create(final T entity) {
|
public void create(final T entity) {
|
||||||
em.persist(entity);
|
em.persist(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T update(final T entity) {
|
public T update(final T entity) {
|
||||||
em.merge(entity);
|
em.merge(entity);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(final T entity) {
|
public void delete(final T entity) {
|
||||||
em.remove(entity);
|
em.remove(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteById(final long entityId) {
|
public void deleteById(final long entityId) {
|
||||||
delete(findOne(entityId));
|
delete(findOne(entityId));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.persistence.dao.common;
|
package com.baeldung.persistence.dao.common;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package org.baeldung.persistence.dao.common;
|
package com.baeldung.persistence.dao.common;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface IAuditOperations<T extends Serializable> {
|
public interface IAuditOperations<T extends Serializable> {
|
||||||
|
|
||||||
List<T> getEntitiesAtRevision(Number revision);
|
List<T> getEntitiesAtRevision(Number revision);
|
||||||
|
|
||||||
List<T> getEntitiesModifiedAtRevision(Number revision);
|
List<T> getEntitiesModifiedAtRevision(Number revision);
|
||||||
|
|
||||||
List<T> getRevisions();
|
List<T> getRevisions();
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.persistence.dao.common;
|
package com.baeldung.persistence.dao.common;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.persistence.dao.common;
|
package com.baeldung.persistence.dao.common;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
|
@ -1,28 +1,28 @@
|
||||||
package org.baeldung.persistence.dao.impl;
|
package com.baeldung.persistence.dao.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.IBarAuditableDao;
|
import com.baeldung.persistence.dao.IBarAuditableDao;
|
||||||
import org.baeldung.persistence.dao.common.AbstractHibernateAuditableDao;
|
import com.baeldung.persistence.dao.common.AbstractHibernateAuditableDao;
|
||||||
import org.baeldung.persistence.model.Bar;
|
import com.baeldung.persistence.model.Bar;
|
||||||
|
|
||||||
public class BarAuditableDao extends AbstractHibernateAuditableDao<Bar> implements IBarAuditableDao {
|
public class BarAuditableDao extends AbstractHibernateAuditableDao<Bar> implements IBarAuditableDao {
|
||||||
|
|
||||||
public BarAuditableDao() {
|
public BarAuditableDao() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
setClazz(Bar.class);
|
setClazz(Bar.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// API
|
// API
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Bar> getRevisions() {
|
public List<Bar> getRevisions() {
|
||||||
final List<Bar> resultList = super.getRevisions();
|
final List<Bar> resultList = super.getRevisions();
|
||||||
for (final Bar bar : resultList) {
|
for (final Bar bar : resultList) {
|
||||||
bar.getFooSet().size(); // force FooSet initialization
|
bar.getFooSet().size(); // force FooSet initialization
|
||||||
}
|
}
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,19 +1,19 @@
|
||||||
package org.baeldung.persistence.dao.impl;
|
package com.baeldung.persistence.dao.impl;
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.IBarDao;
|
import com.baeldung.persistence.dao.common.AbstractHibernateDao;
|
||||||
import org.baeldung.persistence.dao.common.AbstractHibernateDao;
|
import com.baeldung.persistence.dao.IBarDao;
|
||||||
import org.baeldung.persistence.model.Bar;
|
import com.baeldung.persistence.model.Bar;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public class BarDao extends AbstractHibernateDao<Bar> implements IBarDao {
|
public class BarDao extends AbstractHibernateDao<Bar> implements IBarDao {
|
||||||
|
|
||||||
public BarDao() {
|
public BarDao() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
setClazz(Bar.class);
|
setClazz(Bar.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// API
|
// API
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,19 +1,19 @@
|
||||||
package org.baeldung.persistence.dao.impl;
|
package com.baeldung.persistence.dao.impl;
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.IBarDao;
|
import com.baeldung.persistence.dao.IBarDao;
|
||||||
import org.baeldung.persistence.dao.common.AbstractJpaDao;
|
import com.baeldung.persistence.dao.common.AbstractJpaDao;
|
||||||
import org.baeldung.persistence.model.Bar;
|
import com.baeldung.persistence.model.Bar;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public class BarJpaDao extends AbstractJpaDao<Bar> implements IBarDao {
|
public class BarJpaDao extends AbstractJpaDao<Bar> implements IBarDao {
|
||||||
|
|
||||||
public BarJpaDao() {
|
public BarJpaDao() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
setClazz(Bar.class);
|
setClazz(Bar.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// API
|
// API
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.baeldung.persistence.dao.impl;
|
||||||
|
|
||||||
|
import com.baeldung.persistence.dao.common.AbstractHibernateDao;
|
||||||
|
import com.baeldung.persistence.model.Child;
|
||||||
|
import com.baeldung.persistence.dao.IChildDao;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class ChildDao extends AbstractHibernateDao<Child> implements IChildDao {
|
||||||
|
|
||||||
|
public ChildDao() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
setClazz(Child.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// API
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.baeldung.persistence.dao.impl;
|
||||||
|
|
||||||
|
import com.baeldung.persistence.dao.common.AbstractHibernateAuditableDao;
|
||||||
|
import com.baeldung.persistence.model.Foo;
|
||||||
|
import com.baeldung.persistence.dao.IFooAuditableDao;
|
||||||
|
|
||||||
|
public class FooAuditableDao extends AbstractHibernateAuditableDao<Foo> implements IFooAuditableDao {
|
||||||
|
|
||||||
|
public FooAuditableDao() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
setClazz(Foo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// API
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package org.baeldung.persistence.dao.impl;
|
package com.baeldung.persistence.dao.impl;
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.IFooDao;
|
import com.baeldung.persistence.dao.common.AbstractHibernateDao;
|
||||||
import org.baeldung.persistence.dao.common.AbstractHibernateDao;
|
import com.baeldung.persistence.dao.IFooDao;
|
||||||
import org.baeldung.persistence.model.Foo;
|
import com.baeldung.persistence.model.Foo;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.baeldung.persistence.dao.impl;
|
||||||
|
|
||||||
|
import com.baeldung.persistence.dao.IParentDao;
|
||||||
|
import com.baeldung.persistence.dao.common.AbstractHibernateDao;
|
||||||
|
import com.baeldung.persistence.model.Parent;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class ParentDao extends AbstractHibernateDao<Parent> implements IParentDao {
|
||||||
|
|
||||||
|
public ParentDao() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
setClazz(Parent.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// API
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.persistence.model;
|
package com.baeldung.persistence.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.persistence.model;
|
package com.baeldung.persistence.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.persistence.model;
|
package com.baeldung.persistence.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.persistence.model;
|
package com.baeldung.persistence.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.baeldung.persistence.service;
|
||||||
|
|
||||||
|
import com.baeldung.persistence.dao.common.IAuditOperations;
|
||||||
|
import com.baeldung.persistence.model.Bar;
|
||||||
|
|
||||||
|
public interface IBarAuditableService extends IBarService, IAuditOperations<Bar> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.baeldung.persistence.service;
|
||||||
|
|
||||||
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
|
import com.baeldung.persistence.model.Bar;
|
||||||
|
|
||||||
|
public interface IBarService extends IOperations<Bar> {
|
||||||
|
//
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.baeldung.persistence.service;
|
||||||
|
|
||||||
|
import com.baeldung.persistence.model.Child;
|
||||||
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
|
|
||||||
|
public interface IChildService extends IOperations<Child> {
|
||||||
|
//
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.baeldung.persistence.service;
|
||||||
|
|
||||||
|
import com.baeldung.persistence.dao.common.IAuditOperations;
|
||||||
|
import com.baeldung.persistence.model.Foo;
|
||||||
|
|
||||||
|
public interface IFooAuditableService extends IFooService, IAuditOperations<Foo> {
|
||||||
|
//
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.baeldung.persistence.service;
|
||||||
|
|
||||||
|
import com.baeldung.persistence.model.Foo;
|
||||||
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
|
|
||||||
|
public interface IFooService extends IOperations<Foo> {
|
||||||
|
//
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.baeldung.persistence.service;
|
||||||
|
|
||||||
|
import com.baeldung.persistence.model.Parent;
|
||||||
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
|
|
||||||
|
public interface IParentService extends IOperations<Parent> {
|
||||||
|
//
|
||||||
|
}
|
|
@ -1,30 +1,30 @@
|
||||||
package org.baeldung.persistence.service.common;
|
package com.baeldung.persistence.service.common;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.common.IAuditOperations;
|
import com.baeldung.persistence.dao.common.IAuditOperations;
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@Transactional(value = "hibernateTransactionManager")
|
@Transactional(value = "hibernateTransactionManager")
|
||||||
public abstract class AbstractHibernateAuditableService<T extends Serializable> extends AbstractHibernateService<T> implements IOperations<T>, IAuditOperations<T> {
|
public abstract class AbstractHibernateAuditableService<T extends Serializable> extends AbstractHibernateService<T> implements IOperations<T>, IAuditOperations<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> getEntitiesAtRevision(final Number revision) {
|
public List<T> getEntitiesAtRevision(final Number revision) {
|
||||||
return getAuditableDao().getEntitiesAtRevision(revision);
|
return getAuditableDao().getEntitiesAtRevision(revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> getEntitiesModifiedAtRevision(final Number revision) {
|
public List<T> getEntitiesModifiedAtRevision(final Number revision) {
|
||||||
return getAuditableDao().getEntitiesModifiedAtRevision(revision);
|
return getAuditableDao().getEntitiesModifiedAtRevision(revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> getRevisions() {
|
public List<T> getRevisions() {
|
||||||
return getAuditableDao().getRevisions();
|
return getAuditableDao().getRevisions();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected IAuditOperations<T> getAuditableDao();
|
abstract protected IAuditOperations<T> getAuditableDao();
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,42 +1,42 @@
|
||||||
package org.baeldung.persistence.service.common;
|
package com.baeldung.persistence.service.common;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@Transactional(value = "hibernateTransactionManager")
|
@Transactional(value = "hibernateTransactionManager")
|
||||||
public abstract class AbstractHibernateService<T extends Serializable> extends AbstractService<T> implements IOperations<T> {
|
public abstract class AbstractHibernateService<T extends Serializable> extends AbstractService<T> implements IOperations<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T findOne(final long id) {
|
public T findOne(final long id) {
|
||||||
return super.findOne(id);
|
return super.findOne(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> findAll() {
|
public List<T> findAll() {
|
||||||
return super.findAll();
|
return super.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create(final T entity) {
|
public void create(final T entity) {
|
||||||
super.create(entity);
|
super.create(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T update(final T entity) {
|
public T update(final T entity) {
|
||||||
return super.update(entity);
|
return super.update(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(final T entity) {
|
public void delete(final T entity) {
|
||||||
super.delete(entity);
|
super.delete(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteById(final long entityId) {
|
public void deleteById(final long entityId) {
|
||||||
super.deleteById(entityId);
|
super.deleteById(entityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,42 +1,42 @@
|
||||||
package org.baeldung.persistence.service.common;
|
package com.baeldung.persistence.service.common;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@Transactional(value = "jpaTransactionManager")
|
@Transactional(value = "jpaTransactionManager")
|
||||||
public abstract class AbstractJpaService<T extends Serializable> extends AbstractService<T> implements IOperations<T> {
|
public abstract class AbstractJpaService<T extends Serializable> extends AbstractService<T> implements IOperations<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T findOne(final long id) {
|
public T findOne(final long id) {
|
||||||
return super.findOne(id);
|
return super.findOne(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> findAll() {
|
public List<T> findAll() {
|
||||||
return super.findAll();
|
return super.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create(final T entity) {
|
public void create(final T entity) {
|
||||||
super.create(entity);
|
super.create(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T update(final T entity) {
|
public T update(final T entity) {
|
||||||
return super.update(entity);
|
return super.update(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(final T entity) {
|
public void delete(final T entity) {
|
||||||
super.delete(entity);
|
super.delete(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteById(final long entityId) {
|
public void deleteById(final long entityId) {
|
||||||
super.deleteById(entityId);
|
super.deleteById(entityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
package org.baeldung.persistence.service.common;
|
package com.baeldung.persistence.service.common;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
|
|
||||||
public abstract class AbstractService<T extends Serializable> implements IOperations<T> {
|
public abstract class AbstractService<T extends Serializable> implements IOperations<T> {
|
||||||
|
|
|
@ -1,46 +1,46 @@
|
||||||
package org.baeldung.persistence.service.common;
|
package com.baeldung.persistence.service.common;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
@Transactional(value = "jpaTransactionManager")
|
@Transactional(value = "jpaTransactionManager")
|
||||||
public abstract class AbstractSpringDataJpaService<T extends Serializable> implements IOperations<T> {
|
public abstract class AbstractSpringDataJpaService<T extends Serializable> implements IOperations<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T findOne(final long id) {
|
public T findOne(final long id) {
|
||||||
return getDao().findOne(Long.valueOf(id));
|
return getDao().findOne(Long.valueOf(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> findAll() {
|
public List<T> findAll() {
|
||||||
return Lists.newArrayList(getDao().findAll());
|
return Lists.newArrayList(getDao().findAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create(final T entity) {
|
public void create(final T entity) {
|
||||||
getDao().save(entity);
|
getDao().save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T update(final T entity) {
|
public T update(final T entity) {
|
||||||
return getDao().save(entity);
|
return getDao().save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(final T entity) {
|
public void delete(final T entity) {
|
||||||
getDao().delete(entity);
|
getDao().delete(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteById(final long entityId) {
|
public void deleteById(final long entityId) {
|
||||||
getDao().delete(Long.valueOf(entityId));
|
getDao().delete(Long.valueOf(entityId));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract CrudRepository<T, Serializable> getDao();
|
protected abstract CrudRepository<T, Serializable> getDao();
|
||||||
}
|
}
|
|
@ -1,41 +1,41 @@
|
||||||
package org.baeldung.persistence.service.impl;
|
package com.baeldung.persistence.service.impl;
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.IBarAuditableDao;
|
import com.baeldung.persistence.dao.common.IAuditOperations;
|
||||||
import org.baeldung.persistence.dao.IBarDao;
|
import com.baeldung.persistence.service.common.AbstractHibernateAuditableService;
|
||||||
import org.baeldung.persistence.dao.common.IAuditOperations;
|
import com.baeldung.persistence.dao.IBarAuditableDao;
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
import com.baeldung.persistence.dao.IBarDao;
|
||||||
import org.baeldung.persistence.model.Bar;
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
import org.baeldung.persistence.service.IBarAuditableService;
|
import com.baeldung.persistence.model.Bar;
|
||||||
import org.baeldung.persistence.service.common.AbstractHibernateAuditableService;
|
import com.baeldung.persistence.service.IBarAuditableService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class BarAuditableService extends AbstractHibernateAuditableService<Bar> implements IBarAuditableService {
|
public class BarAuditableService extends AbstractHibernateAuditableService<Bar> implements IBarAuditableService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("barHibernateDao")
|
@Qualifier("barHibernateDao")
|
||||||
private IBarDao dao;
|
private IBarDao dao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("barHibernateAuditableDao")
|
@Qualifier("barHibernateAuditableDao")
|
||||||
private IBarAuditableDao auditDao;
|
private IBarAuditableDao auditDao;
|
||||||
|
|
||||||
public BarAuditableService() {
|
public BarAuditableService() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
// API
|
// API
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IOperations<Bar> getDao() {
|
protected IOperations<Bar> getDao() {
|
||||||
return dao;
|
return dao;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IAuditOperations<Bar> getAuditableDao() {
|
protected IAuditOperations<Bar> getAuditableDao() {
|
||||||
return auditDao;
|
return auditDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,30 +1,30 @@
|
||||||
package org.baeldung.persistence.service.impl;
|
package com.baeldung.persistence.service.impl;
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.IBarDao;
|
import com.baeldung.persistence.dao.IBarDao;
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
import org.baeldung.persistence.model.Bar;
|
import com.baeldung.persistence.model.Bar;
|
||||||
import org.baeldung.persistence.service.IBarService;
|
import com.baeldung.persistence.service.IBarService;
|
||||||
import org.baeldung.persistence.service.common.AbstractJpaService;
|
import com.baeldung.persistence.service.common.AbstractJpaService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class BarJpaService extends AbstractJpaService<Bar> implements IBarService {
|
public class BarJpaService extends AbstractJpaService<Bar> implements IBarService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("barJpaDao")
|
@Qualifier("barJpaDao")
|
||||||
private IBarDao dao;
|
private IBarDao dao;
|
||||||
|
|
||||||
public BarJpaService() {
|
public BarJpaService() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
// API
|
// API
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IOperations<Bar> getDao() {
|
protected IOperations<Bar> getDao() {
|
||||||
return dao;
|
return dao;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,30 +1,30 @@
|
||||||
package org.baeldung.persistence.service.impl;
|
package com.baeldung.persistence.service.impl;
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.IBarDao;
|
import com.baeldung.persistence.dao.IBarDao;
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
import org.baeldung.persistence.model.Bar;
|
import com.baeldung.persistence.model.Bar;
|
||||||
import org.baeldung.persistence.service.IBarService;
|
import com.baeldung.persistence.service.IBarService;
|
||||||
import org.baeldung.persistence.service.common.AbstractHibernateService;
|
import com.baeldung.persistence.service.common.AbstractHibernateService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class BarService extends AbstractHibernateService<Bar> implements IBarService {
|
public class BarService extends AbstractHibernateService<Bar> implements IBarService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("barHibernateDao")
|
@Qualifier("barHibernateDao")
|
||||||
private IBarDao dao;
|
private IBarDao dao;
|
||||||
|
|
||||||
public BarService() {
|
public BarService() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
// API
|
// API
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IOperations<Bar> getDao() {
|
protected IOperations<Bar> getDao() {
|
||||||
return dao;
|
return dao;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,26 +1,26 @@
|
||||||
package org.baeldung.persistence.service.impl;
|
package com.baeldung.persistence.service.impl;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.IBarCrudRepository;
|
import com.baeldung.persistence.service.common.AbstractSpringDataJpaService;
|
||||||
import org.baeldung.persistence.model.Bar;
|
import com.baeldung.persistence.dao.IBarCrudRepository;
|
||||||
import org.baeldung.persistence.service.IBarService;
|
import com.baeldung.persistence.model.Bar;
|
||||||
import org.baeldung.persistence.service.common.AbstractSpringDataJpaService;
|
import com.baeldung.persistence.service.IBarService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
|
||||||
public class BarSpringDataJpaService extends AbstractSpringDataJpaService<Bar> implements IBarService {
|
public class BarSpringDataJpaService extends AbstractSpringDataJpaService<Bar> implements IBarService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IBarCrudRepository dao;
|
private IBarCrudRepository dao;
|
||||||
|
|
||||||
public BarSpringDataJpaService() {
|
public BarSpringDataJpaService() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CrudRepository<Bar, Serializable> getDao() {
|
protected CrudRepository<Bar, Serializable> getDao() {
|
||||||
return dao;
|
return dao;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
package org.baeldung.persistence.service.impl;
|
package com.baeldung.persistence.service.impl;
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.IChildDao;
|
import com.baeldung.persistence.model.Child;
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
import com.baeldung.persistence.service.IChildService;
|
||||||
import org.baeldung.persistence.model.Child;
|
import com.baeldung.persistence.dao.IChildDao;
|
||||||
import org.baeldung.persistence.service.IChildService;
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
import org.baeldung.persistence.service.common.AbstractHibernateService;
|
import com.baeldung.persistence.service.common.AbstractHibernateService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
|
@ -1,41 +1,41 @@
|
||||||
package org.baeldung.persistence.service.impl;
|
package com.baeldung.persistence.service.impl;
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.IFooAuditableDao;
|
import com.baeldung.persistence.dao.common.IAuditOperations;
|
||||||
import org.baeldung.persistence.dao.IFooDao;
|
import com.baeldung.persistence.service.IFooAuditableService;
|
||||||
import org.baeldung.persistence.dao.common.IAuditOperations;
|
import com.baeldung.persistence.service.common.AbstractHibernateAuditableService;
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
import com.baeldung.persistence.dao.IFooAuditableDao;
|
||||||
import org.baeldung.persistence.model.Foo;
|
import com.baeldung.persistence.dao.IFooDao;
|
||||||
import org.baeldung.persistence.service.IFooAuditableService;
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
import org.baeldung.persistence.service.common.AbstractHibernateAuditableService;
|
import com.baeldung.persistence.model.Foo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class FooAuditableService extends AbstractHibernateAuditableService<Foo> implements IFooAuditableService {
|
public class FooAuditableService extends AbstractHibernateAuditableService<Foo> implements IFooAuditableService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("fooHibernateDao")
|
@Qualifier("fooHibernateDao")
|
||||||
private IFooDao dao;
|
private IFooDao dao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("fooHibernateAuditableDao")
|
@Qualifier("fooHibernateAuditableDao")
|
||||||
private IFooAuditableDao auditDao;
|
private IFooAuditableDao auditDao;
|
||||||
|
|
||||||
public FooAuditableService() {
|
public FooAuditableService() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
// API
|
// API
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IOperations<Foo> getDao() {
|
protected IOperations<Foo> getDao() {
|
||||||
return dao;
|
return dao;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IAuditOperations<Foo> getAuditableDao() {
|
protected IAuditOperations<Foo> getAuditableDao() {
|
||||||
return auditDao;
|
return auditDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
package org.baeldung.persistence.service.impl;
|
package com.baeldung.persistence.service.impl;
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.IFooDao;
|
import com.baeldung.persistence.dao.IFooDao;
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
import org.baeldung.persistence.model.Foo;
|
import com.baeldung.persistence.model.Foo;
|
||||||
import org.baeldung.persistence.service.IFooService;
|
import com.baeldung.persistence.service.IFooService;
|
||||||
import org.baeldung.persistence.service.common.AbstractHibernateService;
|
import com.baeldung.persistence.service.common.AbstractHibernateService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
|
@ -1,10 +1,10 @@
|
||||||
package org.baeldung.persistence.service.impl;
|
package com.baeldung.persistence.service.impl;
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.IParentDao;
|
import com.baeldung.persistence.model.Parent;
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
import com.baeldung.persistence.service.IParentService;
|
||||||
import org.baeldung.persistence.model.Parent;
|
import com.baeldung.persistence.dao.IParentDao;
|
||||||
import org.baeldung.persistence.service.IParentService;
|
import com.baeldung.persistence.dao.common.IOperations;
|
||||||
import org.baeldung.persistence.service.common.AbstractHibernateService;
|
import com.baeldung.persistence.service.common.AbstractHibernateService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
package org.baeldung.spring;
|
package com.baeldung.spring;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
import com.baeldung.persistence.dao.impl.BarDao;
|
||||||
|
import com.baeldung.persistence.dao.impl.FooDao;
|
||||||
|
import com.baeldung.persistence.service.IBarAuditableService;
|
||||||
|
import com.baeldung.persistence.service.IFooAuditableService;
|
||||||
|
import com.baeldung.persistence.service.IFooService;
|
||||||
import org.apache.tomcat.dbcp.dbcp.BasicDataSource;
|
import org.apache.tomcat.dbcp.dbcp.BasicDataSource;
|
||||||
import org.baeldung.persistence.dao.IBarAuditableDao;
|
import com.baeldung.persistence.dao.IBarAuditableDao;
|
||||||
import org.baeldung.persistence.dao.IBarDao;
|
import com.baeldung.persistence.dao.IBarDao;
|
||||||
import org.baeldung.persistence.dao.IFooAuditableDao;
|
import com.baeldung.persistence.dao.IFooAuditableDao;
|
||||||
import org.baeldung.persistence.dao.IFooDao;
|
import com.baeldung.persistence.dao.IFooDao;
|
||||||
import org.baeldung.persistence.dao.impl.BarAuditableDao;
|
import com.baeldung.persistence.dao.impl.BarAuditableDao;
|
||||||
import org.baeldung.persistence.dao.impl.BarDao;
|
import com.baeldung.persistence.dao.impl.BarJpaDao;
|
||||||
import org.baeldung.persistence.dao.impl.BarJpaDao;
|
import com.baeldung.persistence.dao.impl.FooAuditableDao;
|
||||||
import org.baeldung.persistence.dao.impl.FooAuditableDao;
|
import com.baeldung.persistence.service.IBarService;
|
||||||
import org.baeldung.persistence.dao.impl.FooDao;
|
import com.baeldung.persistence.service.impl.BarAuditableService;
|
||||||
import org.baeldung.persistence.service.IBarAuditableService;
|
import com.baeldung.persistence.service.impl.BarJpaService;
|
||||||
import org.baeldung.persistence.service.IBarService;
|
import com.baeldung.persistence.service.impl.BarSpringDataJpaService;
|
||||||
import org.baeldung.persistence.service.IFooAuditableService;
|
import com.baeldung.persistence.service.impl.FooAuditableService;
|
||||||
import org.baeldung.persistence.service.IFooService;
|
import com.baeldung.persistence.service.impl.FooService;
|
||||||
import org.baeldung.persistence.service.impl.BarAuditableService;
|
|
||||||
import org.baeldung.persistence.service.impl.BarJpaService;
|
|
||||||
import org.baeldung.persistence.service.impl.BarSpringDataJpaService;
|
|
||||||
import org.baeldung.persistence.service.impl.FooAuditableService;
|
|
||||||
import org.baeldung.persistence.service.impl.FooService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
@ -45,10 +45,10 @@ import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@EnableJpaRepositories(basePackages = { "org.baeldung.persistence" }, transactionManagerRef = "jpaTransactionManager")
|
@EnableJpaRepositories(basePackages = { "com.baeldung.persistence" }, transactionManagerRef = "jpaTransactionManager")
|
||||||
@EnableJpaAuditing
|
@EnableJpaAuditing
|
||||||
@PropertySource({ "classpath:persistence-mysql.properties" })
|
@PropertySource({ "classpath:persistence-mysql.properties" })
|
||||||
@ComponentScan({ "org.baeldung.persistence" })
|
@ComponentScan({ "com.baeldung.persistence" })
|
||||||
public class PersistenceConfig {
|
public class PersistenceConfig {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -62,7 +62,7 @@ public class PersistenceConfig {
|
||||||
public LocalSessionFactoryBean sessionFactory() {
|
public LocalSessionFactoryBean sessionFactory() {
|
||||||
final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
|
final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
|
||||||
sessionFactory.setDataSource(restDataSource());
|
sessionFactory.setDataSource(restDataSource());
|
||||||
sessionFactory.setPackagesToScan(new String[] { "org.baeldung.persistence.model" });
|
sessionFactory.setPackagesToScan(new String[] { "com.baeldung.persistence.model" });
|
||||||
sessionFactory.setHibernateProperties(hibernateProperties());
|
sessionFactory.setHibernateProperties(hibernateProperties());
|
||||||
|
|
||||||
return sessionFactory;
|
return sessionFactory;
|
||||||
|
@ -72,7 +72,7 @@ public class PersistenceConfig {
|
||||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||||
final LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
|
final LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
|
||||||
emf.setDataSource(restDataSource());
|
emf.setDataSource(restDataSource());
|
||||||
emf.setPackagesToScan(new String[] { "org.baeldung.persistence.model" });
|
emf.setPackagesToScan(new String[] { "com.baeldung.persistence.model" });
|
||||||
|
|
||||||
final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
|
final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
|
||||||
emf.setJpaVendorAdapter(vendorAdapter);
|
emf.setJpaVendorAdapter(vendorAdapter);
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.spring;
|
package com.baeldung.spring;
|
||||||
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
@ -7,7 +7,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@ComponentScan({ "org.baeldung.persistence.dao", "org.baeldung.persistence.service" })
|
@ComponentScan({ "com.baeldung.persistence.dao", "com.baeldung.persistence.service" })
|
||||||
@ImportResource({ "classpath:hibernate4Config.xml" })
|
@ImportResource({ "classpath:hibernate4Config.xml" })
|
||||||
public class PersistenceXmlConfig {
|
public class PersistenceXmlConfig {
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
package org.baeldung.persistence.dao;
|
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.common.IAuditOperations;
|
|
||||||
import org.baeldung.persistence.model.Bar;
|
|
||||||
|
|
||||||
public interface IBarAuditableDao extends IBarDao, IAuditOperations<Bar> {
|
|
||||||
//
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package org.baeldung.persistence.dao;
|
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
|
||||||
import org.baeldung.persistence.model.Bar;
|
|
||||||
|
|
||||||
public interface IBarDao extends IOperations<Bar> {
|
|
||||||
//
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package org.baeldung.persistence.dao;
|
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
|
||||||
import org.baeldung.persistence.model.Child;
|
|
||||||
|
|
||||||
public interface IChildDao extends IOperations<Child> {
|
|
||||||
//
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package org.baeldung.persistence.dao;
|
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.common.IAuditOperations;
|
|
||||||
import org.baeldung.persistence.model.Foo;
|
|
||||||
|
|
||||||
public interface IFooAuditableDao extends IFooDao, IAuditOperations<Foo> {
|
|
||||||
//
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package org.baeldung.persistence.dao;
|
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
|
||||||
import org.baeldung.persistence.model.Foo;
|
|
||||||
|
|
||||||
public interface IFooDao extends IOperations<Foo> {
|
|
||||||
//
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package org.baeldung.persistence.dao;
|
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
|
||||||
import org.baeldung.persistence.model.Parent;
|
|
||||||
|
|
||||||
public interface IParentDao extends IOperations<Parent> {
|
|
||||||
//
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package org.baeldung.persistence.dao.impl;
|
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.IChildDao;
|
|
||||||
import org.baeldung.persistence.dao.common.AbstractHibernateDao;
|
|
||||||
import org.baeldung.persistence.model.Child;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public class ChildDao extends AbstractHibernateDao<Child>implements IChildDao {
|
|
||||||
|
|
||||||
public ChildDao() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
setClazz(Child.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
// API
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package org.baeldung.persistence.dao.impl;
|
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.IFooAuditableDao;
|
|
||||||
import org.baeldung.persistence.dao.common.AbstractHibernateAuditableDao;
|
|
||||||
import org.baeldung.persistence.model.Foo;
|
|
||||||
|
|
||||||
public class FooAuditableDao extends AbstractHibernateAuditableDao<Foo> implements IFooAuditableDao {
|
|
||||||
|
|
||||||
public FooAuditableDao() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
setClazz(Foo.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
// API
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package org.baeldung.persistence.dao.impl;
|
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.IParentDao;
|
|
||||||
import org.baeldung.persistence.dao.common.AbstractHibernateDao;
|
|
||||||
import org.baeldung.persistence.model.Parent;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public class ParentDao extends AbstractHibernateDao<Parent>implements IParentDao {
|
|
||||||
|
|
||||||
public ParentDao() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
setClazz(Parent.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
// API
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package org.baeldung.persistence.service;
|
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.common.IAuditOperations;
|
|
||||||
import org.baeldung.persistence.model.Bar;
|
|
||||||
|
|
||||||
public interface IBarAuditableService extends IBarService, IAuditOperations<Bar> {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package org.baeldung.persistence.service;
|
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
|
||||||
import org.baeldung.persistence.model.Bar;
|
|
||||||
|
|
||||||
public interface IBarService extends IOperations<Bar> {
|
|
||||||
//
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package org.baeldung.persistence.service;
|
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
|
||||||
import org.baeldung.persistence.model.Child;
|
|
||||||
|
|
||||||
public interface IChildService extends IOperations<Child> {
|
|
||||||
//
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package org.baeldung.persistence.service;
|
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.common.IAuditOperations;
|
|
||||||
import org.baeldung.persistence.model.Foo;
|
|
||||||
|
|
||||||
public interface IFooAuditableService extends IFooService, IAuditOperations<Foo> {
|
|
||||||
//
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package org.baeldung.persistence.service;
|
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
|
||||||
import org.baeldung.persistence.model.Foo;
|
|
||||||
|
|
||||||
public interface IFooService extends IOperations<Foo> {
|
|
||||||
//
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package org.baeldung.persistence.service;
|
|
||||||
|
|
||||||
import org.baeldung.persistence.dao.common.IOperations;
|
|
||||||
import org.baeldung.persistence.model.Parent;
|
|
||||||
|
|
||||||
public interface IParentService extends IOperations<Parent> {
|
|
||||||
//
|
|
||||||
}
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
|
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
|
||||||
<property name="dataSource" ref="dataSource"/>
|
<property name="dataSource" ref="dataSource"/>
|
||||||
<property name="packagesToScan" value="org.baeldung.persistence.model"/>
|
<property name="packagesToScan" value="com.baeldung.persistence.model"/>
|
||||||
<property name="hibernateProperties">
|
<property name="hibernateProperties">
|
||||||
<props>
|
<props>
|
||||||
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
|
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package org.baeldung.persistence;
|
package com.baeldung.persistence;
|
||||||
|
|
||||||
import org.baeldung.persistence.hibernate.FooPaginationPersistenceIntegrationTest;
|
import com.baeldung.persistence.hibernate.FooPaginationPersistenceIntegrationTest;
|
||||||
import org.baeldung.persistence.hibernate.FooSortingPersistenceServiceTest;
|
import com.baeldung.persistence.hibernate.FooSortingPersistenceServiceTest;
|
||||||
import org.baeldung.persistence.service.FooServiceBasicPersistenceIntegrationTest;
|
import com.baeldung.persistence.service.FooServicePersistenceIntegrationTest;
|
||||||
import org.baeldung.persistence.service.FooServicePersistenceIntegrationTest;
|
import com.baeldung.persistence.service.FooServiceBasicPersistenceIntegrationTest;
|
||||||
import org.baeldung.persistence.service.ParentServicePersistenceIntegrationTest;
|
import com.baeldung.persistence.service.ParentServicePersistenceIntegrationTest;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Suite;
|
import org.junit.runners.Suite;
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package org.baeldung.persistence.audit;
|
package com.baeldung.persistence.audit;
|
||||||
|
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Suite;
|
import org.junit.runners.Suite;
|
||||||
|
|
||||||
@RunWith(Suite.class)
|
@RunWith(Suite.class)
|
||||||
@Suite.SuiteClasses({ // @formatter:off
|
@Suite.SuiteClasses({ // @formatter:off
|
||||||
EnversFooBarAuditTest.class,
|
EnversFooBarAuditTest.class,
|
||||||
JPABarAuditTest.class,
|
JPABarAuditTest.class,
|
||||||
SpringDataJPABarAuditTest.class
|
SpringDataJPABarAuditTest.class
|
||||||
}) // @formatter:on
|
}) // @formatter:on
|
||||||
public class AuditTestSuite {
|
public class AuditTestSuite {
|
||||||
//
|
//
|
||||||
}
|
}
|
|
@ -1,142 +1,142 @@
|
||||||
package org.baeldung.persistence.audit;
|
package com.baeldung.persistence.audit;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.baeldung.persistence.model.Bar;
|
import com.baeldung.persistence.model.Foo;
|
||||||
import org.baeldung.persistence.model.Foo;
|
import com.baeldung.persistence.service.IBarAuditableService;
|
||||||
import org.baeldung.persistence.service.IBarAuditableService;
|
import com.baeldung.persistence.service.IFooAuditableService;
|
||||||
import org.baeldung.persistence.service.IFooAuditableService;
|
import com.baeldung.spring.PersistenceConfig;
|
||||||
import org.baeldung.spring.PersistenceConfig;
|
import com.baeldung.persistence.model.Bar;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class)
|
@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||||
public class EnversFooBarAuditTest {
|
public class EnversFooBarAuditTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(EnversFooBarAuditTest.class);
|
private static Logger logger = LoggerFactory.getLogger(EnversFooBarAuditTest.class);
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public static void setUpBeforeClass() throws Exception {
|
||||||
logger.info("setUpBeforeClass()");
|
logger.info("setUpBeforeClass()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void tearDownAfterClass() throws Exception {
|
public static void tearDownAfterClass() throws Exception {
|
||||||
logger.info("tearDownAfterClass()");
|
logger.info("tearDownAfterClass()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("fooHibernateAuditableService")
|
@Qualifier("fooHibernateAuditableService")
|
||||||
private IFooAuditableService fooService;
|
private IFooAuditableService fooService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("barHibernateAuditableService")
|
@Qualifier("barHibernateAuditableService")
|
||||||
private IBarAuditableService barService;
|
private IBarAuditableService barService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SessionFactory sessionFactory;
|
private SessionFactory sessionFactory;
|
||||||
|
|
||||||
private Session session;
|
private Session session;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
logger.info("setUp()");
|
logger.info("setUp()");
|
||||||
makeRevisions();
|
makeRevisions();
|
||||||
session = sessionFactory.openSession();
|
session = sessionFactory.openSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
logger.info("tearDown()");
|
logger.info("tearDown()");
|
||||||
session.close();
|
session.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeRevisions() {
|
private void makeRevisions() {
|
||||||
final Bar bar = rev1();
|
final Bar bar = rev1();
|
||||||
rev2(bar);
|
rev2(bar);
|
||||||
rev3(bar);
|
rev3(bar);
|
||||||
rev4(bar);
|
rev4(bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
// REV #1: insert BAR & FOO1
|
// REV #1: insert BAR & FOO1
|
||||||
private Bar rev1() {
|
private Bar rev1() {
|
||||||
final Bar bar = new Bar("BAR");
|
final Bar bar = new Bar("BAR");
|
||||||
final Foo foo1 = new Foo("FOO1");
|
final Foo foo1 = new Foo("FOO1");
|
||||||
foo1.setBar(bar);
|
foo1.setBar(bar);
|
||||||
fooService.create(foo1);
|
fooService.create(foo1);
|
||||||
return bar;
|
return bar;
|
||||||
}
|
}
|
||||||
|
|
||||||
// REV #2: insert FOO2 & update BAR
|
// REV #2: insert FOO2 & update BAR
|
||||||
private void rev2(final Bar bar) {
|
private void rev2(final Bar bar) {
|
||||||
final Foo foo2 = new Foo("FOO2");
|
final Foo foo2 = new Foo("FOO2");
|
||||||
foo2.setBar(bar);
|
foo2.setBar(bar);
|
||||||
fooService.create(foo2);
|
fooService.create(foo2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// REV #3: update BAR
|
// REV #3: update BAR
|
||||||
private void rev3(final Bar bar) {
|
private void rev3(final Bar bar) {
|
||||||
|
|
||||||
bar.setName("BAR1");
|
bar.setName("BAR1");
|
||||||
barService.update(bar);
|
barService.update(bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
// REV #4: insert FOO3 & update BAR
|
// REV #4: insert FOO3 & update BAR
|
||||||
private void rev4(final Bar bar) {
|
private void rev4(final Bar bar) {
|
||||||
|
|
||||||
final Foo foo3 = new Foo("FOO3");
|
final Foo foo3 = new Foo("FOO3");
|
||||||
foo3.setBar(bar);
|
foo3.setBar(bar);
|
||||||
fooService.create(foo3);
|
fooService.create(foo3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public final void whenFooBarsModified_thenFooBarsAudited() {
|
public final void whenFooBarsModified_thenFooBarsAudited() {
|
||||||
|
|
||||||
List<Bar> barRevisionList;
|
List<Bar> barRevisionList;
|
||||||
List<Foo> fooRevisionList;
|
List<Foo> fooRevisionList;
|
||||||
|
|
||||||
// test Bar revisions
|
// test Bar revisions
|
||||||
|
|
||||||
barRevisionList = barService.getRevisions();
|
barRevisionList = barService.getRevisions();
|
||||||
|
|
||||||
assertNotNull(barRevisionList);
|
assertNotNull(barRevisionList);
|
||||||
assertEquals(4, barRevisionList.size());
|
assertEquals(4, barRevisionList.size());
|
||||||
|
|
||||||
assertEquals("BAR", barRevisionList.get(0).getName());
|
assertEquals("BAR", barRevisionList.get(0).getName());
|
||||||
assertEquals("BAR", barRevisionList.get(1).getName());
|
assertEquals("BAR", barRevisionList.get(1).getName());
|
||||||
assertEquals("BAR1", barRevisionList.get(2).getName());
|
assertEquals("BAR1", barRevisionList.get(2).getName());
|
||||||
assertEquals("BAR1", barRevisionList.get(3).getName());
|
assertEquals("BAR1", barRevisionList.get(3).getName());
|
||||||
|
|
||||||
assertEquals(1, barRevisionList.get(0).getFooSet().size());
|
assertEquals(1, barRevisionList.get(0).getFooSet().size());
|
||||||
assertEquals(2, barRevisionList.get(1).getFooSet().size());
|
assertEquals(2, barRevisionList.get(1).getFooSet().size());
|
||||||
assertEquals(2, barRevisionList.get(2).getFooSet().size());
|
assertEquals(2, barRevisionList.get(2).getFooSet().size());
|
||||||
assertEquals(3, barRevisionList.get(3).getFooSet().size());
|
assertEquals(3, barRevisionList.get(3).getFooSet().size());
|
||||||
|
|
||||||
// test Foo revisions
|
// test Foo revisions
|
||||||
|
|
||||||
fooRevisionList = fooService.getRevisions();
|
fooRevisionList = fooService.getRevisions();
|
||||||
assertNotNull(fooRevisionList);
|
assertNotNull(fooRevisionList);
|
||||||
assertEquals(3, fooRevisionList.size());
|
assertEquals(3, fooRevisionList.size());
|
||||||
assertEquals("FOO1", fooRevisionList.get(0).getName());
|
assertEquals("FOO1", fooRevisionList.get(0).getName());
|
||||||
assertEquals("FOO2", fooRevisionList.get(1).getName());
|
assertEquals("FOO2", fooRevisionList.get(1).getName());
|
||||||
assertEquals("FOO3", fooRevisionList.get(2).getName());
|
assertEquals("FOO3", fooRevisionList.get(2).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,106 +1,106 @@
|
||||||
package org.baeldung.persistence.audit;
|
package com.baeldung.persistence.audit;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.EntityManagerFactory;
|
import javax.persistence.EntityManagerFactory;
|
||||||
|
|
||||||
import org.baeldung.persistence.model.Bar;
|
import com.baeldung.persistence.model.Bar;
|
||||||
import org.baeldung.persistence.model.Bar.OPERATION;
|
import com.baeldung.persistence.model.Bar.OPERATION;
|
||||||
import org.baeldung.persistence.service.IBarService;
|
import com.baeldung.persistence.service.IBarService;
|
||||||
import org.baeldung.spring.PersistenceConfig;
|
import com.baeldung.spring.PersistenceConfig;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class)
|
@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||||
public class JPABarAuditTest {
|
public class JPABarAuditTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(JPABarAuditTest.class);
|
private static Logger logger = LoggerFactory.getLogger(JPABarAuditTest.class);
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public static void setUpBeforeClass() throws Exception {
|
||||||
logger.info("setUpBeforeClass()");
|
logger.info("setUpBeforeClass()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void tearDownAfterClass() throws Exception {
|
public static void tearDownAfterClass() throws Exception {
|
||||||
logger.info("tearDownAfterClass()");
|
logger.info("tearDownAfterClass()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("barJpaService")
|
@Qualifier("barJpaService")
|
||||||
private IBarService barService;
|
private IBarService barService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EntityManagerFactory entityManagerFactory;
|
private EntityManagerFactory entityManagerFactory;
|
||||||
|
|
||||||
private EntityManager em;
|
private EntityManager em;
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
logger.info("setUp()");
|
logger.info("setUp()");
|
||||||
em = entityManagerFactory.createEntityManager();
|
em = entityManagerFactory.createEntityManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
logger.info("tearDown()");
|
logger.info("tearDown()");
|
||||||
em.close();
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public final void whenBarsModified_thenBarsAudited() {
|
public final void whenBarsModified_thenBarsAudited() {
|
||||||
|
|
||||||
// insert BAR1
|
// insert BAR1
|
||||||
Bar bar1 = new Bar("BAR1");
|
Bar bar1 = new Bar("BAR1");
|
||||||
barService.create(bar1);
|
barService.create(bar1);
|
||||||
|
|
||||||
// update BAR1
|
// update BAR1
|
||||||
bar1.setName("BAR1a");
|
bar1.setName("BAR1a");
|
||||||
barService.update(bar1);
|
barService.update(bar1);
|
||||||
|
|
||||||
// insert BAR2
|
// insert BAR2
|
||||||
Bar bar2 = new Bar("BAR2");
|
Bar bar2 = new Bar("BAR2");
|
||||||
barService.create(bar2);
|
barService.create(bar2);
|
||||||
|
|
||||||
// update BAR1
|
// update BAR1
|
||||||
bar1.setName("BAR1b");
|
bar1.setName("BAR1b");
|
||||||
barService.update(bar1);
|
barService.update(bar1);
|
||||||
|
|
||||||
|
|
||||||
// get BAR1 and BAR2 from the DB and check the audit values
|
// get BAR1 and BAR2 from the DB and check the audit values
|
||||||
// detach instances from persistence context to make sure we fire db
|
// detach instances from persistence context to make sure we fire db
|
||||||
em.detach(bar1);
|
em.detach(bar1);
|
||||||
em.detach(bar2);
|
em.detach(bar2);
|
||||||
bar1 = barService.findOne(bar1.getId());
|
bar1 = barService.findOne(bar1.getId());
|
||||||
bar2 = barService.findOne(bar2.getId());
|
bar2 = barService.findOne(bar2.getId());
|
||||||
|
|
||||||
assertNotNull(bar1);
|
assertNotNull(bar1);
|
||||||
assertNotNull(bar2);
|
assertNotNull(bar2);
|
||||||
assertEquals(OPERATION.UPDATE, bar1.getOperation());
|
assertEquals(OPERATION.UPDATE, bar1.getOperation());
|
||||||
assertEquals(OPERATION.INSERT, bar2.getOperation());
|
assertEquals(OPERATION.INSERT, bar2.getOperation());
|
||||||
assertTrue(bar1.getTimestamp() > bar2.getTimestamp());
|
assertTrue(bar1.getTimestamp() > bar2.getTimestamp());
|
||||||
|
|
||||||
barService.deleteById(bar1.getId());
|
barService.deleteById(bar1.getId());
|
||||||
barService.deleteById(bar2.getId());
|
barService.deleteById(bar2.getId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,76 +1,76 @@
|
||||||
package org.baeldung.persistence.audit;
|
package com.baeldung.persistence.audit;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.EntityManagerFactory;
|
import javax.persistence.EntityManagerFactory;
|
||||||
|
|
||||||
import org.baeldung.persistence.model.Bar;
|
import com.baeldung.persistence.model.Bar;
|
||||||
import org.baeldung.persistence.service.IBarService;
|
import com.baeldung.persistence.service.IBarService;
|
||||||
import org.baeldung.spring.PersistenceConfig;
|
import com.baeldung.spring.PersistenceConfig;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.security.test.context.support.WithMockUser;
|
import org.springframework.security.test.context.support.WithMockUser;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class)
|
@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||||
public class SpringDataJPABarAuditTest {
|
public class SpringDataJPABarAuditTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(SpringDataJPABarAuditTest.class);
|
private static Logger logger = LoggerFactory.getLogger(SpringDataJPABarAuditTest.class);
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public static void setUpBeforeClass() throws Exception {
|
||||||
logger.info("setUpBeforeClass()");
|
logger.info("setUpBeforeClass()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void tearDownAfterClass() throws Exception {
|
public static void tearDownAfterClass() throws Exception {
|
||||||
logger.info("tearDownAfterClass()");
|
logger.info("tearDownAfterClass()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("barSpringDataJpaService")
|
@Qualifier("barSpringDataJpaService")
|
||||||
private IBarService barService;
|
private IBarService barService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EntityManagerFactory entityManagerFactory;
|
private EntityManagerFactory entityManagerFactory;
|
||||||
|
|
||||||
private EntityManager em;
|
private EntityManager em;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
logger.info("setUp()");
|
logger.info("setUp()");
|
||||||
em = entityManagerFactory.createEntityManager();
|
em = entityManagerFactory.createEntityManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
logger.info("tearDown()");
|
logger.info("tearDown()");
|
||||||
em.close();
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@WithMockUser(username = "tutorialuser")
|
@WithMockUser(username = "tutorialuser")
|
||||||
public final void whenBarsModified_thenBarsAudited() {
|
public final void whenBarsModified_thenBarsAudited() {
|
||||||
Bar bar = new Bar("BAR1");
|
Bar bar = new Bar("BAR1");
|
||||||
barService.create(bar);
|
barService.create(bar);
|
||||||
assertEquals(bar.getCreatedDate(), bar.getModifiedDate());
|
assertEquals(bar.getCreatedDate(), bar.getModifiedDate());
|
||||||
assertEquals("tutorialuser", bar.getCreatedBy(), bar.getModifiedBy());
|
assertEquals("tutorialuser", bar.getCreatedBy(), bar.getModifiedBy());
|
||||||
bar.setName("BAR2");
|
bar.setName("BAR2");
|
||||||
bar = barService.update(bar);
|
bar = barService.update(bar);
|
||||||
assertTrue(bar.getCreatedDate() < bar.getModifiedDate());
|
assertTrue(bar.getCreatedDate() < bar.getModifiedDate());
|
||||||
assertEquals("tutorialuser", bar.getCreatedBy(), bar.getModifiedBy());
|
assertEquals("tutorialuser", bar.getCreatedBy(), bar.getModifiedBy());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
package org.baeldung.persistence.hibernate;
|
package com.baeldung.persistence.hibernate;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.baeldung.persistence.model.Bar;
|
import com.baeldung.persistence.model.Foo;
|
||||||
import org.baeldung.persistence.model.Foo;
|
import com.baeldung.persistence.model.Bar;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.persistence.hibernate;
|
package com.baeldung.persistence.hibernate;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
||||||
import static org.hamcrest.Matchers.hasSize;
|
import static org.hamcrest.Matchers.hasSize;
|
||||||
|
@ -7,9 +7,9 @@ import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.baeldung.persistence.model.Foo;
|
import com.baeldung.persistence.model.Foo;
|
||||||
import org.baeldung.persistence.service.IFooService;
|
import com.baeldung.persistence.service.IFooService;
|
||||||
import org.baeldung.spring.PersistenceConfig;
|
import com.baeldung.spring.PersistenceConfig;
|
||||||
import org.hibernate.Criteria;
|
import org.hibernate.Criteria;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.hibernate.ScrollMode;
|
import org.hibernate.ScrollMode;
|
|
@ -1,13 +1,13 @@
|
||||||
package org.baeldung.persistence.hibernate;
|
package com.baeldung.persistence.hibernate;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.baeldung.persistence.model.Bar;
|
import com.baeldung.persistence.model.Bar;
|
||||||
import org.baeldung.persistence.model.Foo;
|
import com.baeldung.persistence.model.Foo;
|
||||||
import org.baeldung.spring.PersistenceConfig;
|
import com.baeldung.spring.PersistenceConfig;
|
||||||
import org.hibernate.Criteria;
|
import org.hibernate.Criteria;
|
||||||
import org.hibernate.NullPrecedence;
|
import org.hibernate.NullPrecedence;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
|
@ -1,10 +1,9 @@
|
||||||
package org.baeldung.persistence.service;
|
package com.baeldung.persistence.service;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
||||||
|
|
||||||
import org.baeldung.persistence.model.Foo;
|
import com.baeldung.persistence.model.Foo;
|
||||||
import org.baeldung.persistence.service.IFooService;
|
import com.baeldung.spring.PersistenceConfig;
|
||||||
import org.baeldung.spring.PersistenceConfig;
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
|
@ -1,9 +1,9 @@
|
||||||
package org.baeldung.persistence.service;
|
package com.baeldung.persistence.service;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
||||||
|
|
||||||
import org.baeldung.persistence.model.Foo;
|
import com.baeldung.persistence.model.Foo;
|
||||||
import org.baeldung.spring.PersistenceConfig;
|
import com.baeldung.spring.PersistenceConfig;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
|
@ -1,8 +1,8 @@
|
||||||
package org.baeldung.persistence.service;
|
package com.baeldung.persistence.service;
|
||||||
|
|
||||||
import org.baeldung.persistence.model.Child;
|
import com.baeldung.persistence.model.Child;
|
||||||
import org.baeldung.persistence.model.Parent;
|
import com.baeldung.persistence.model.Parent;
|
||||||
import org.baeldung.spring.PersistenceConfig;
|
import com.baeldung.spring.PersistenceConfig;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
Loading…
Reference in New Issue