From 233891c10775e7259c12384757996aa1b9a30bed Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Mon, 17 Feb 2020 20:57:44 +0100 Subject: [PATCH] JAVA-143: Migrate spring-hibernate-3 to com.baeldung --- .../spring-hibernate-3/README.md | 4 +- .../persistence/dao/AbstractHibernateDao.java | 2 +- .../baeldung/persistence/dao/EventDao.java | 36 ++++---- .../baeldung/persistence/dao/FooDao.java | 4 +- .../baeldung/persistence/dao/IEventDao.java | 8 ++ .../com/baeldung/persistence/dao/IFooDao.java | 7 ++ .../baeldung/persistence/dao/IOperations.java | 2 +- .../baeldung/persistence/model/Event.java | 88 +++++++++---------- .../baeldung/persistence/model/Foo.java | 2 +- .../persistence/service/EventService.java | 54 ++++++------ .../persistence/service/FooService.java | 6 +- .../baeldung/spring/PersistenceConfig.java | 6 +- .../spring/PersistenceConfigHibernate3.java | 4 +- .../baeldung/spring/PersistenceXmlConfig.java | 4 +- .../baeldung/persistence/dao/IEventDao.java | 9 -- .../org/baeldung/persistence/dao/IFooDao.java | 7 -- .../src/main/resources/exceptionDemo.cfg.xml | 2 +- .../exceptionDemoPersistenceConfig.xml | 2 +- .../src/main/resources/persistenceConfig.xml | 2 +- .../src/main/webapp/WEB-INF/web.xml | 2 +- .../baeldung/SpringContextTest.java | 4 +- .../FooServicePersistenceIntegrationTest.java | 7 +- ...nateExceptionScen1MainIntegrationTest.java | 6 +- ...nateExceptionScen2MainIntegrationTest.java | 6 +- ...ingAnnoSessionBeanMainIntegrationTest.java | 84 +++++++++--------- ...ngLocalSessionBeanMainIntegrationTest.java | 77 ++++++++-------- 26 files changed, 216 insertions(+), 219 deletions(-) rename persistence-modules/spring-hibernate-3/src/main/java/{org => com}/baeldung/persistence/dao/AbstractHibernateDao.java (97%) rename persistence-modules/spring-hibernate-3/src/main/java/{org => com}/baeldung/persistence/dao/EventDao.java (70%) rename persistence-modules/spring-hibernate-3/src/main/java/{org => com}/baeldung/persistence/dao/FooDao.java (73%) create mode 100644 persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IEventDao.java create mode 100644 persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IFooDao.java rename persistence-modules/spring-hibernate-3/src/main/java/{org => com}/baeldung/persistence/dao/IOperations.java (89%) rename persistence-modules/spring-hibernate-3/src/main/java/{org => com}/baeldung/persistence/model/Event.java (89%) rename persistence-modules/spring-hibernate-3/src/main/java/{org => com}/baeldung/persistence/model/Foo.java (97%) rename persistence-modules/spring-hibernate-3/src/main/java/{org => com}/baeldung/persistence/service/EventService.java (72%) rename persistence-modules/spring-hibernate-3/src/main/java/{org => com}/baeldung/persistence/service/FooService.java (75%) rename persistence-modules/spring-hibernate-3/src/main/java/{org => com}/baeldung/spring/PersistenceConfig.java (94%) rename persistence-modules/spring-hibernate-3/src/main/java/{org => com}/baeldung/spring/PersistenceConfigHibernate3.java (97%) rename persistence-modules/spring-hibernate-3/src/main/java/{org => com}/baeldung/spring/PersistenceXmlConfig.java (82%) delete mode 100644 persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IEventDao.java delete mode 100644 persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IFooDao.java rename persistence-modules/spring-hibernate-3/src/test/java/{org => com}/baeldung/SpringContextTest.java (88%) rename persistence-modules/spring-hibernate-3/src/test/java/{org => com}/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java (91%) rename persistence-modules/spring-hibernate-3/src/test/java/{org => com}/baeldung/persistence/service/HibernateExceptionScen1MainIntegrationTest.java (90%) rename persistence-modules/spring-hibernate-3/src/test/java/{org => com}/baeldung/persistence/service/HibernateExceptionScen2MainIntegrationTest.java (91%) rename persistence-modules/spring-hibernate-3/src/test/java/{org => com}/baeldung/persistence/service/NoHibernateSessBoundUsingAnnoSessionBeanMainIntegrationTest.java (88%) rename persistence-modules/spring-hibernate-3/src/test/java/{org => com}/baeldung/persistence/service/NoHibernateSessBoundUsingLocalSessionBeanMainIntegrationTest.java (86%) diff --git a/persistence-modules/spring-hibernate-3/README.md b/persistence-modules/spring-hibernate-3/README.md index 898c6522a9..610d586f85 100644 --- a/persistence-modules/spring-hibernate-3/README.md +++ b/persistence-modules/spring-hibernate-3/README.md @@ -4,8 +4,8 @@ This module contains articles about Spring with Hibernate 3 ### Relevant Articles: -- [Hibernate 3 with Spring](http://www.baeldung.com/hibernate3-spring) -- [HibernateException: No Hibernate Session Bound to Thread in Hibernate 3](http://www.baeldung.com/no-hibernate-session-bound-to-thread-exception) +- [Hibernate 3 with Spring](https://www.baeldung.com/hibernate3-spring) +- [HibernateException: No Hibernate Session Bound to Thread in Hibernate 3](https://www.baeldung.com/no-hibernate-session-bound-to-thread-exception) ### Quick Start diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/AbstractHibernateDao.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/AbstractHibernateDao.java similarity index 97% rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/AbstractHibernateDao.java rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/AbstractHibernateDao.java index 0f8b132891..701c6c43c7 100644 --- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/AbstractHibernateDao.java +++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/AbstractHibernateDao.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.dao; +package com.baeldung.persistence.dao; import java.io.Serializable; import java.util.List; diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/EventDao.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/EventDao.java similarity index 70% rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/EventDao.java rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/EventDao.java index 74da643f35..e6519d54c8 100644 --- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/EventDao.java +++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/EventDao.java @@ -1,18 +1,18 @@ -package org.baeldung.persistence.dao; - - -import org.baeldung.persistence.model.Event; -import org.springframework.stereotype.Repository; - -@Repository -public class EventDao extends AbstractHibernateDao implements IEventDao { - - public EventDao() { - super(); - - setClazz(Event.class); - } - - // API - -} +package com.baeldung.persistence.dao; + + +import com.baeldung.persistence.model.Event; +import org.springframework.stereotype.Repository; + +@Repository +public class EventDao extends AbstractHibernateDao implements IEventDao { + + public EventDao() { + super(); + + setClazz(Event.class); + } + + // API + +} diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/FooDao.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/FooDao.java similarity index 73% rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/FooDao.java rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/FooDao.java index 23de04169e..afcd958bc2 100644 --- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/FooDao.java +++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/FooDao.java @@ -1,6 +1,6 @@ -package org.baeldung.persistence.dao; +package com.baeldung.persistence.dao; -import org.baeldung.persistence.model.Foo; +import com.baeldung.persistence.model.Foo; import org.springframework.stereotype.Repository; @Repository diff --git a/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IEventDao.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IEventDao.java new file mode 100644 index 0000000000..da2be1ce1e --- /dev/null +++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IEventDao.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.dao; + +import com.baeldung.persistence.model.Event; + + +public interface IEventDao extends IOperations { + // +} diff --git a/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IFooDao.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IFooDao.java new file mode 100644 index 0000000000..f79883980a --- /dev/null +++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IFooDao.java @@ -0,0 +1,7 @@ +package com.baeldung.persistence.dao; + +import com.baeldung.persistence.model.Foo; + +public interface IFooDao extends IOperations { + // +} diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IOperations.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IOperations.java similarity index 89% rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IOperations.java rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IOperations.java index 8c5a5e1aed..66f8008f27 100644 --- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IOperations.java +++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IOperations.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.dao; +package com.baeldung.persistence.dao; import java.io.Serializable; import java.util.List; diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/model/Event.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/model/Event.java similarity index 89% rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/model/Event.java rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/model/Event.java index 1d659ed75c..37a9758cd5 100644 --- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/model/Event.java +++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/model/Event.java @@ -1,45 +1,45 @@ -package org.baeldung.persistence.model; - -import java.io.Serializable; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; - -@Entity -@Table(name = "EVENTS") -public class Event implements Serializable { - - @Id - @GeneratedValue - private Long id; - - private String description; - - public Event() { - } - - - public Event(String description) { - this.description = description; - } - - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - +package com.baeldung.persistence.model; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "EVENTS") +public class Event implements Serializable { + + @Id + @GeneratedValue + private Long id; + + private String description; + + public Event() { + } + + + public Event(String description) { + this.description = description; + } + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + } \ No newline at end of file diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/model/Foo.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/model/Foo.java similarity index 97% rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/model/Foo.java rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/model/Foo.java index 8e1dee33e8..9af3d07bed 100644 --- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/model/Foo.java +++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/model/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.model; +package com.baeldung.persistence.model; import java.io.Serializable; diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/service/EventService.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/service/EventService.java similarity index 72% rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/service/EventService.java rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/service/EventService.java index 6171751cc5..bf9afed38b 100644 --- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/service/EventService.java +++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/service/EventService.java @@ -1,27 +1,27 @@ -package org.baeldung.persistence.service; - - -import org.baeldung.persistence.dao.IEventDao; -import org.baeldung.persistence.model.Event; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@Transactional -public class EventService { - - @Autowired - private IEventDao dao; - - public EventService() { - super(); - } - - // API - - public void create(final Event entity) { - dao.create(entity); - } - -} +package com.baeldung.persistence.service; + + +import com.baeldung.persistence.model.Event; +import com.baeldung.persistence.dao.IEventDao; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class EventService { + + @Autowired + private IEventDao dao; + + public EventService() { + super(); + } + + // API + + public void create(final Event entity) { + dao.create(entity); + } + +} diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/service/FooService.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/service/FooService.java similarity index 75% rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/service/FooService.java rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/service/FooService.java index b07698c438..ad88062216 100644 --- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/service/FooService.java +++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/service/FooService.java @@ -1,7 +1,7 @@ -package org.baeldung.persistence.service; +package com.baeldung.persistence.service; -import org.baeldung.persistence.dao.IFooDao; -import org.baeldung.persistence.model.Foo; +import com.baeldung.persistence.dao.IFooDao; +import com.baeldung.persistence.model.Foo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceConfig.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceConfig.java similarity index 94% rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceConfig.java rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceConfig.java index 03b9bfac33..29472174b2 100644 --- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring; +package com.baeldung.spring; import java.util.Properties; @@ -22,7 +22,7 @@ import com.google.common.base.Preconditions; @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-h2.properties" }) -@ComponentScan({ "org.baeldung.persistence.dao", "org.baeldung.persistence.service" }) +@ComponentScan({ "com.baeldung.persistence.dao", "com.baeldung.persistence.service" }) public class PersistenceConfig { @Autowired @@ -36,7 +36,7 @@ public class PersistenceConfig { public AnnotationSessionFactoryBean sessionFactory() { final AnnotationSessionFactoryBean sessionFactory = new AnnotationSessionFactoryBean(); sessionFactory.setDataSource(dataSource()); - sessionFactory.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); + sessionFactory.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); sessionFactory.setHibernateProperties(hibernateProperties()); return sessionFactory; diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceConfigHibernate3.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceConfigHibernate3.java similarity index 97% rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceConfigHibernate3.java rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceConfigHibernate3.java index f38da21dc0..08ae9a76df 100644 --- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceConfigHibernate3.java +++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceConfigHibernate3.java @@ -1,4 +1,4 @@ -package org.baeldung.spring; +package com.baeldung.spring; import java.util.Properties; @@ -24,7 +24,7 @@ import com.google.common.base.Preconditions; @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-h2.properties" }) -@ComponentScan({ "org.baeldung.persistence.dao", "org.baeldung.persistence.service" }) +@ComponentScan({ "com.baeldung.persistence.dao", "com.baeldung.persistence.service" }) public class PersistenceConfigHibernate3 { @Autowired diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceXmlConfig.java similarity index 82% rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceXmlConfig.java index 5831d2745c..798fb740a7 100644 --- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java +++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceXmlConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring; +package com.baeldung.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ImportResource; @@ -6,7 +6,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; // @Configuration @EnableTransactionManagement -@ComponentScan({ "org.baeldung.persistence.dao", "org.baeldung.persistence.service" }) +@ComponentScan({ "com.baeldung.persistence.dao", "com.baeldung.persistence.service" }) @ImportResource({ "classpath:persistenceConfig.xml" }) public class PersistenceXmlConfig { diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IEventDao.java b/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IEventDao.java deleted file mode 100644 index f7be705905..0000000000 --- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IEventDao.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.baeldung.persistence.dao; - -import org.baeldung.persistence.model.Event; - - - -public interface IEventDao extends IOperations { - // -} diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IFooDao.java b/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IFooDao.java deleted file mode 100644 index 6a3bd95d71..0000000000 --- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IFooDao.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.baeldung.persistence.dao; - -import org.baeldung.persistence.model.Foo; - -public interface IFooDao extends IOperations { - // -} diff --git a/persistence-modules/spring-hibernate-3/src/main/resources/exceptionDemo.cfg.xml b/persistence-modules/spring-hibernate-3/src/main/resources/exceptionDemo.cfg.xml index 8a710cc559..896c080983 100644 --- a/persistence-modules/spring-hibernate-3/src/main/resources/exceptionDemo.cfg.xml +++ b/persistence-modules/spring-hibernate-3/src/main/resources/exceptionDemo.cfg.xml @@ -4,6 +4,6 @@ "http://hibernate.org/dtd/hibernate-configuration-3.0.dtd"> - + diff --git a/persistence-modules/spring-hibernate-3/src/main/resources/exceptionDemoPersistenceConfig.xml b/persistence-modules/spring-hibernate-3/src/main/resources/exceptionDemoPersistenceConfig.xml index 263e902e7c..5f9e8c0107 100644 --- a/persistence-modules/spring-hibernate-3/src/main/resources/exceptionDemoPersistenceConfig.xml +++ b/persistence-modules/spring-hibernate-3/src/main/resources/exceptionDemoPersistenceConfig.xml @@ -16,7 +16,7 @@ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> - + diff --git a/persistence-modules/spring-hibernate-3/src/main/resources/persistenceConfig.xml b/persistence-modules/spring-hibernate-3/src/main/resources/persistenceConfig.xml index f39817383b..03d4d022e6 100644 --- a/persistence-modules/spring-hibernate-3/src/main/resources/persistenceConfig.xml +++ b/persistence-modules/spring-hibernate-3/src/main/resources/persistenceConfig.xml @@ -9,7 +9,7 @@ - + ${hibernate.hbm2ddl.auto} diff --git a/persistence-modules/spring-hibernate-3/src/main/webapp/WEB-INF/web.xml b/persistence-modules/spring-hibernate-3/src/main/webapp/WEB-INF/web.xml index ad56bf28c7..69ce04fe06 100644 --- a/persistence-modules/spring-hibernate-3/src/main/webapp/WEB-INF/web.xml +++ b/persistence-modules/spring-hibernate-3/src/main/webapp/WEB-INF/web.xml @@ -11,7 +11,7 @@ contextConfigLocation - org.baeldung.spring + com.baeldung.spring org.springframework.web.context.ContextLoaderListener diff --git a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/SpringContextTest.java b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/SpringContextTest.java similarity index 88% rename from persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/SpringContextTest.java rename to persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/SpringContextTest.java index 956d5279a3..8b352b490d 100644 --- a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/SpringContextTest.java +++ b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/SpringContextTest.java @@ -1,6 +1,6 @@ -package org.baeldung; +package com.baeldung; -import org.baeldung.spring.PersistenceConfig; +import com.baeldung.spring.PersistenceConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java similarity index 91% rename from persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java rename to persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java index b6e4a5592f..7874f7c679 100644 --- a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -1,10 +1,9 @@ -package org.baeldung.persistence.service; +package com.baeldung.persistence.service; import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import org.baeldung.persistence.model.Foo; -import org.baeldung.persistence.service.FooService; -import org.baeldung.spring.PersistenceConfig; +import com.baeldung.spring.PersistenceConfig; +import com.baeldung.persistence.model.Foo; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/HibernateExceptionScen1MainIntegrationTest.java b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/HibernateExceptionScen1MainIntegrationTest.java similarity index 90% rename from persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/HibernateExceptionScen1MainIntegrationTest.java rename to persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/HibernateExceptionScen1MainIntegrationTest.java index 08032660c0..99dc7b42be 100644 --- a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/HibernateExceptionScen1MainIntegrationTest.java +++ b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/HibernateExceptionScen1MainIntegrationTest.java @@ -1,7 +1,7 @@ -package org.baeldung.persistence.service; +package com.baeldung.persistence.service; -import org.baeldung.persistence.model.Event; -import org.baeldung.spring.PersistenceConfigHibernate3; +import com.baeldung.persistence.model.Event; +import com.baeldung.spring.PersistenceConfigHibernate3; import org.hamcrest.core.IsInstanceOf; import org.hibernate.HibernateException; import org.junit.Ignore; diff --git a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/HibernateExceptionScen2MainIntegrationTest.java b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/HibernateExceptionScen2MainIntegrationTest.java similarity index 91% rename from persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/HibernateExceptionScen2MainIntegrationTest.java rename to persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/HibernateExceptionScen2MainIntegrationTest.java index 44cc6ca010..d3e475a244 100644 --- a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/HibernateExceptionScen2MainIntegrationTest.java +++ b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/HibernateExceptionScen2MainIntegrationTest.java @@ -1,7 +1,7 @@ -package org.baeldung.persistence.service; +package com.baeldung.persistence.service; -import org.baeldung.persistence.model.Event; -import org.baeldung.spring.PersistenceConfig; +import com.baeldung.persistence.model.Event; +import com.baeldung.spring.PersistenceConfig; import org.hamcrest.core.IsInstanceOf; import org.hibernate.HibernateException; import org.junit.Ignore; diff --git a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/NoHibernateSessBoundUsingAnnoSessionBeanMainIntegrationTest.java b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/NoHibernateSessBoundUsingAnnoSessionBeanMainIntegrationTest.java similarity index 88% rename from persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/NoHibernateSessBoundUsingAnnoSessionBeanMainIntegrationTest.java rename to persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/NoHibernateSessBoundUsingAnnoSessionBeanMainIntegrationTest.java index 2b29dcb7a9..d1c5cc04e6 100644 --- a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/NoHibernateSessBoundUsingAnnoSessionBeanMainIntegrationTest.java +++ b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/NoHibernateSessBoundUsingAnnoSessionBeanMainIntegrationTest.java @@ -1,42 +1,42 @@ -package org.baeldung.persistence.service; - -import org.baeldung.persistence.model.Event; -import org.baeldung.spring.PersistenceXmlConfig; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.orm.hibernate3.HibernateSystemException; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceXmlConfig.class }, loader = AnnotationConfigContextLoader.class) -public class NoHibernateSessBoundUsingAnnoSessionBeanMainIntegrationTest { - - @Autowired - EventService service; - - @Rule - public ExpectedException expectedEx = ExpectedException.none(); - - @Test - public final void whenEntityIsCreated_thenNoExceptions() { - service.create(new Event("from Annotation Session Bean Factory")); - } - - @Test - @Ignore - public final void whenNoTransBoundToSession_thenException() { - expectedEx.expect(HibernateSystemException.class); - expectedEx.expectMessage("No Hibernate Session bound to thread, " - + "and configuration does not allow creation of " - + "non-transactional one here"); - service.create(new Event("from Annotation Session Bean Factory")); - } - -} +package com.baeldung.persistence.service; + +import com.baeldung.persistence.model.Event; +import com.baeldung.spring.PersistenceXmlConfig; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.orm.hibernate3.HibernateSystemException; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceXmlConfig.class }, loader = AnnotationConfigContextLoader.class) +public class NoHibernateSessBoundUsingAnnoSessionBeanMainIntegrationTest { + + @Autowired + EventService service; + + @Rule + public ExpectedException expectedEx = ExpectedException.none(); + + @Test + public final void whenEntityIsCreated_thenNoExceptions() { + service.create(new Event("from Annotation Session Bean Factory")); + } + + @Test + @Ignore + public final void whenNoTransBoundToSession_thenException() { + expectedEx.expect(HibernateSystemException.class); + expectedEx.expectMessage("No Hibernate Session bound to thread, " + + "and configuration does not allow creation of " + + "non-transactional one here"); + service.create(new Event("from Annotation Session Bean Factory")); + } + +} diff --git a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/NoHibernateSessBoundUsingLocalSessionBeanMainIntegrationTest.java b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/NoHibernateSessBoundUsingLocalSessionBeanMainIntegrationTest.java similarity index 86% rename from persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/NoHibernateSessBoundUsingLocalSessionBeanMainIntegrationTest.java rename to persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/NoHibernateSessBoundUsingLocalSessionBeanMainIntegrationTest.java index 1bc6c07b18..1df6aa172c 100644 --- a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/NoHibernateSessBoundUsingLocalSessionBeanMainIntegrationTest.java +++ b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/NoHibernateSessBoundUsingLocalSessionBeanMainIntegrationTest.java @@ -1,39 +1,38 @@ -package org.baeldung.persistence.service; - -import org.baeldung.persistence.model.Event; -import org.hibernate.HibernateException; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.orm.hibernate3.HibernateSystemException; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:exceptionDemoPersistenceConfig.xml" }) -public class NoHibernateSessBoundUsingLocalSessionBeanMainIntegrationTest { - - @Autowired - EventService service; - - @Rule - public ExpectedException expectedEx = ExpectedException.none(); - - @Test - public final void whenEntityIsCreated_thenNoExceptions() { - service.create(new Event("from local session bean factory")); - } - - @Test - @Ignore - public final void whenNoTransBoundToSession_thenException() { - expectedEx.expect(HibernateException.class); - expectedEx.expectMessage("No Hibernate Session bound to thread, " - + "and configuration does not allow creation " - + "of non-transactional one here"); - service.create(new Event("from local session bean factory")); - } -} +package com.baeldung.persistence.service; + +import com.baeldung.persistence.model.Event; +import org.hibernate.HibernateException; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath:exceptionDemoPersistenceConfig.xml" }) +public class NoHibernateSessBoundUsingLocalSessionBeanMainIntegrationTest { + + @Autowired + EventService service; + + @Rule + public ExpectedException expectedEx = ExpectedException.none(); + + @Test + public final void whenEntityIsCreated_thenNoExceptions() { + service.create(new Event("from local session bean factory")); + } + + @Test + @Ignore + public final void whenNoTransBoundToSession_thenException() { + expectedEx.expect(HibernateException.class); + expectedEx.expectMessage("No Hibernate Session bound to thread, " + + "and configuration does not allow creation " + + "of non-transactional one here"); + service.create(new Event("from local session bean factory")); + } +}