diff --git a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.fdt b/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.fdt deleted file mode 100644 index d71a081502..0000000000 Binary files a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.fdt and /dev/null differ diff --git a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.fdx b/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.fdx deleted file mode 100644 index 72359255c6..0000000000 Binary files a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.fdx and /dev/null differ diff --git a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.fnm b/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.fnm deleted file mode 100644 index b0143e1ac5..0000000000 Binary files a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.fnm and /dev/null differ diff --git a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.nvd b/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.nvd deleted file mode 100644 index 7073f8f836..0000000000 Binary files a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.nvd and /dev/null differ diff --git a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.nvm b/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.nvm deleted file mode 100644 index 19f60a39bc..0000000000 Binary files a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.nvm and /dev/null differ diff --git a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.si b/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.si deleted file mode 100644 index 3d537083b4..0000000000 Binary files a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.si and /dev/null differ diff --git a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.tvd b/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.tvd deleted file mode 100644 index b46c8d109c..0000000000 Binary files a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.tvd and /dev/null differ diff --git a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.tvx b/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.tvx deleted file mode 100644 index 1c5e0738f7..0000000000 Binary files a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2.tvx and /dev/null differ diff --git a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2_Lucene50_0.doc b/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2_Lucene50_0.doc deleted file mode 100644 index af3ffab275..0000000000 Binary files a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2_Lucene50_0.doc and /dev/null differ diff --git a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2_Lucene50_0.pos b/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2_Lucene50_0.pos deleted file mode 100644 index a4c2b9d15a..0000000000 Binary files a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2_Lucene50_0.pos and /dev/null differ diff --git a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2_Lucene50_0.tim b/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2_Lucene50_0.tim deleted file mode 100644 index 6196bdee5f..0000000000 Binary files a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2_Lucene50_0.tim and /dev/null differ diff --git a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2_Lucene50_0.tip b/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2_Lucene50_0.tip deleted file mode 100644 index 9803f1b398..0000000000 Binary files a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_2_Lucene50_0.tip and /dev/null differ diff --git a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_3.cfe b/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_3.cfe deleted file mode 100644 index 8fb074f30e..0000000000 Binary files a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_3.cfe and /dev/null differ diff --git a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_3.cfs b/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_3.cfs deleted file mode 100644 index e26078b9e7..0000000000 Binary files a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_3.cfs and /dev/null differ diff --git a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_3.si b/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_3.si deleted file mode 100644 index f2d6b6a030..0000000000 Binary files a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/_3.si and /dev/null differ diff --git a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/segments_5 b/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/segments_5 deleted file mode 100644 index 66a4c385a5..0000000000 Binary files a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/segments_5 and /dev/null differ diff --git a/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/write.lock b/persistence-modules/hibernate-many-to-many/com.baeldung.hibernatesearch.model.Product/write.lock deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/manytomany/dao/IEmployeeDao.java b/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/manytomany/dao/IEmployeeDao.java deleted file mode 100644 index 5ba018dc52..0000000000 --- a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/manytomany/dao/IEmployeeDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.persistence.manytomany.dao; - -import com.baeldung.hibernate.manytomany.model.Employee; -import com.baeldung.persistence.dao.common.IOperations; - -public interface IEmployeeDao extends IOperations{ - -} diff --git a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/manytomany/dao/IProjectDao.java b/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/manytomany/dao/IProjectDao.java deleted file mode 100644 index 48fbb8bf6b..0000000000 --- a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/manytomany/dao/IProjectDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.persistence.manytomany.dao; - -import com.baeldung.hibernate.manytomany.model.Project; -import com.baeldung.persistence.dao.common.IOperations; - -public interface IProjectDao extends IOperations{ - -} diff --git a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/spring/PersistenceConfig.java b/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/spring/PersistenceConfig.java deleted file mode 100644 index e1ea3e2024..0000000000 --- a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/spring/PersistenceConfig.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.baeldung.spring; - -import com.google.common.base.Preconditions; -import org.apache.tomcat.dbcp.dbcp2.BasicDataSource; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.core.env.Environment; -import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; -import org.springframework.orm.hibernate5.HibernateTransactionManager; -import org.springframework.orm.hibernate5.LocalSessionFactoryBean; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -import javax.sql.DataSource; -import java.util.Properties; - -@Configuration -@EnableTransactionManagement -@PropertySource({ "classpath:persistence-h2.properties" }) -@ComponentScan({ "com.baeldung.persistence" }) -public class PersistenceConfig { - - @Autowired - private Environment env; - - @Bean - public LocalSessionFactoryBean sessionFactory() { - final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); - sessionFactory.setDataSource(dataSource()); - sessionFactory.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); - sessionFactory.setHibernateProperties(hibernateProperties()); - - return sessionFactory; - } - - @Bean - public DataSource dataSource() { - final BasicDataSource dataSource = new BasicDataSource(); - dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); - dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); - dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); - dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); - - return dataSource; - } - - @Bean - public PlatformTransactionManager hibernateTransactionManager() { - final HibernateTransactionManager transactionManager = new HibernateTransactionManager(); - transactionManager.setSessionFactory(sessionFactory().getObject()); - return transactionManager; - } - - @Bean - public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { - return new PersistenceExceptionTranslationPostProcessor(); - } - - private final Properties hibernateProperties() { - final Properties hibernateProperties = new Properties(); - hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); - hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - - hibernateProperties.setProperty("hibernate.show_sql", "false"); - - // Envers properties - hibernateProperties.setProperty("org.hibernate.envers.audit_table_suffix", env.getProperty("envers.audit_table_suffix")); - - return hibernateProperties; - } - -} \ No newline at end of file diff --git a/persistence-modules/hibernate-many-to-many/src/main/resources/import.sql b/persistence-modules/hibernate-many-to-many/src/main/resources/import.sql deleted file mode 100644 index ae008f29bc..0000000000 --- a/persistence-modules/hibernate-many-to-many/src/main/resources/import.sql +++ /dev/null @@ -1,31 +0,0 @@ -insert into item (item_id, item_name, item_desc, item_price) -values(1,'item One', 'test 1', 35.12); - -insert into item (item_id, item_name, item_desc, item_price) -values(2,'Pogo stick', 'Pogo stick', 466.12); -insert into item (item_id, item_name, item_desc, item_price) -values(3,'Raft', 'Raft', 345.12); - -insert into item (item_id, item_name, item_desc, item_price) -values(4,'Skate Board', 'Skating', 135.71); - -insert into item (item_id, item_name, item_desc, item_price) -values(5,'Umbrella', 'Umbrella for Rain', 619.25); - -insert into item (item_id, item_name, item_desc, item_price) -values(6,'Glue', 'Glue for home', 432.73); - -insert into item (item_id, item_name, item_desc, item_price) -values(7,'Paint', 'Paint for Room', 1311.40); - -insert into item (item_id, item_name, item_desc, item_price) -values(8,'Red paint', 'Red paint for room', 1135.71); - -insert into item (item_id, item_name, item_desc, item_price) -values(9,'Household Chairs', 'Chairs for house', 25.71); - -insert into item (item_id, item_name, item_desc, item_price) -values(10,'Office Chairs', 'Chairs for office', 395.98); - -insert into item (item_id, item_name, item_desc, item_price) -values(11,'Outdoor Chairs', 'Chairs for outdoor activities', 1234.36); diff --git a/persistence-modules/hibernate-many-to-many/src/main/resources/manytomany.cfg.xml b/persistence-modules/hibernate-many-to-many/src/main/resources/manytomany.cfg.xml deleted file mode 100644 index d7c8f24fb0..0000000000 --- a/persistence-modules/hibernate-many-to-many/src/main/resources/manytomany.cfg.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - com.mysql.jdbc.Driver - tutorialmy5ql - jdbc:mysql://localhost:3306/spring_hibernate_many_to_many - tutorialuser - org.hibernate.dialect.MySQLDialect - thread - false - - diff --git a/persistence-modules/hibernate-many-to-many/src/main/resources/persistence-h2.properties b/persistence-modules/hibernate-many-to-many/src/main/resources/persistence-h2.properties deleted file mode 100644 index e3544d354a..0000000000 --- a/persistence-modules/hibernate-many-to-many/src/main/resources/persistence-h2.properties +++ /dev/null @@ -1,21 +0,0 @@ -# jdbc.X -jdbc.driverClassName=org.h2.Driver -jdbc.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 -jdbc.eventGeneratedId=sa -jdbc.user=sa -jdbc.pass= - -# hibernate.X -hibernate.dialect=org.hibernate.dialect.H2Dialect -hibernate.show_sql=false -hibernate.hbm2ddl.auto=create-drop -hibernate.cache.use_second_level_cache=true -hibernate.cache.use_query_cache=true -hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory - -# hibernate.search.X -hibernate.search.default.directory_provider = filesystem -hibernate.search.default.indexBase = /data/index/default - -# envers.X -envers.audit_table_suffix=_audit_log diff --git a/persistence-modules/hibernate-many-to-many/src/test/resources/.gitignore b/persistence-modules/hibernate-many-to-many/src/test/resources/.gitignore deleted file mode 100644 index 83c05e60c8..0000000000 --- a/persistence-modules/hibernate-many-to-many/src/test/resources/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file diff --git a/persistence-modules/hibernate-many-to-many/src/test/resources/com/baeldung/hibernate/criteria/model/Item.hbm.xml b/persistence-modules/hibernate-many-to-many/src/test/resources/com/baeldung/hibernate/criteria/model/Item.hbm.xml deleted file mode 100644 index 9e0109aae2..0000000000 --- a/persistence-modules/hibernate-many-to-many/src/test/resources/com/baeldung/hibernate/criteria/model/Item.hbm.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/persistence-modules/hibernate-many-to-many/src/test/resources/import.sql b/persistence-modules/hibernate-many-to-many/src/test/resources/import.sql deleted file mode 100644 index 087d62d331..0000000000 --- a/persistence-modules/hibernate-many-to-many/src/test/resources/import.sql +++ /dev/null @@ -1,21 +0,0 @@ -insert into item (item_id, item_name, item_desc, item_price) values(1,'item One', 'test 1', 35.12); - -insert into item (item_id, item_name, item_desc, item_price) values(2,'Pogo stick', 'Pogo stick', 466.12); - -insert into item (item_id, item_name, item_desc, item_price) values(3,'Raft', 'Raft', 345.12); - -insert into item (item_id, item_name, item_desc, item_price) values(4,'Skate Board', 'Skating', 135.71); - -insert into item (item_id, item_name, item_desc, item_price) values(5,'Umbrella', 'Umbrella for Rain', 619.25); - -insert into item (item_id, item_name, item_desc, item_price) values(6,'Glue', 'Glue for home', 432.73); - -insert into item (item_id, item_name, item_desc, item_price) values(7,'Paint', 'Paint for Room', 1311.40); - -insert into item (item_id, item_name, item_desc, item_price) values(8,'Red paint', 'Red paint for room', 1135.71); - -insert into item (item_id, item_name, item_desc, item_price) values(9,'Household Chairs', 'Chairs for house', 25.71); - -insert into item (item_id, item_name, item_desc, item_price) values(10,'Office Chairs', 'Chairs for office', 395.98); - -insert into item (item_id, item_name, item_desc, item_price) values(11,'Outdoor Chairs', 'Chairs for outdoor activities', 1234.36); diff --git a/persistence-modules/hibernate-many-to-many/.gitignore b/persistence-modules/hibernate-mapping-2/.gitignore similarity index 100% rename from persistence-modules/hibernate-many-to-many/.gitignore rename to persistence-modules/hibernate-mapping-2/.gitignore diff --git a/persistence-modules/hibernate-many-to-many/README.md b/persistence-modules/hibernate-mapping-2/README.md similarity index 57% rename from persistence-modules/hibernate-many-to-many/README.md rename to persistence-modules/hibernate-mapping-2/README.md index 19b865d4e1..7a811e17cf 100644 --- a/persistence-modules/hibernate-many-to-many/README.md +++ b/persistence-modules/hibernate-mapping-2/README.md @@ -1,6 +1,6 @@ -## Hibernate 5 with Spring +## Hibernate Mapping -This module contains articles about Hibernate 5 with Spring. +This module contains articles about Hibernate Mappings. ### Relevant articles diff --git a/persistence-modules/hibernate-many-to-many/pom.xml b/persistence-modules/hibernate-mapping-2/pom.xml similarity index 54% rename from persistence-modules/hibernate-many-to-many/pom.xml rename to persistence-modules/hibernate-mapping-2/pom.xml index 6f1abb6a7a..10c07c95eb 100644 --- a/persistence-modules/hibernate-many-to-many/pom.xml +++ b/persistence-modules/hibernate-mapping-2/pom.xml @@ -3,9 +3,9 @@ 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"> 4.0.0 - hibernate-many-to-many + hibernate-mapping-2y 0.1-SNAPSHOT - hibernate-many-to-many + hibernate-mapping-2 com.baeldung @@ -19,24 +19,8 @@ org.springframework spring-context ${org.springframework.version} - - - commons-logging - commons-logging - - - - - org.springframework - spring-aspects - ${org.springframework.version} - - org.springframework - spring-orm - ${org.springframework.version} - org.springframework.data spring-data-jpa @@ -47,16 +31,6 @@ hibernate-core ${hibernate.version} - - javax.transaction - jta - ${jta.version} - - - org.hibernate - hibernate-search-orm - ${hibernatesearch.version} - org.apache.tomcat tomcat-dbcp @@ -70,53 +44,31 @@ ${guava.version} - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - test - org.springframework spring-test ${org.springframework.version} test - - org.springframework.security - spring-security-test - ${org.springframework.security.version} - test - - - org.hsqldb - hsqldb - ${hsqldb.version} - com.h2database h2 ${h2.version} - - - jakarta.xml.bind - jakarta.xml.bind-api - 2.3.2 - + com.sun.xml.bind jaxb-core - 2.3.0.1 + ${com.sun.xml.version} javax.xml.bind jaxb-api - 2.3.1 + ${javax.xml.bind.version} com.sun.xml.bind jaxb-impl - 2.3.1 + ${com.sun.xml.version} @@ -124,13 +76,11 @@ 5.0.2.RELEASE 1.10.6.RELEASE - 4.2.1.RELEASE 5.2.10.Final - 5.8.2.Final 9.0.0.M26 - 1.1 - 2.3.4 + 2.3.0.1 + 2.3.1 \ No newline at end of file diff --git a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/manytomany/spring/PersistenceConfig.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/PersistenceConfig.java similarity index 95% rename from persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/manytomany/spring/PersistenceConfig.java rename to persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/PersistenceConfig.java index f7179b07e5..0d7b8bdbcf 100644 --- a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/manytomany/spring/PersistenceConfig.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/PersistenceConfig.java @@ -1,7 +1,9 @@ -package com.baeldung.manytomany.spring; +package com.baeldung.manytomany; import java.util.Properties; + import javax.sql.DataSource; + import org.apache.tomcat.dbcp.dbcp2.BasicDataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -20,7 +22,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-h2.properties" }) -@ComponentScan({ "com.baeldung.hibernate.manytomany" }) +@ComponentScan({ "com.baeldung.manytomany" }) public class PersistenceConfig { @Autowired @@ -30,7 +32,7 @@ public class PersistenceConfig { public LocalSessionFactoryBean sessionFactory() { final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "com.baeldung.hibernate.manytomany" }); + sessionFactory.setPackagesToScan(new String[] { "com.baeldung.manytomany" }); sessionFactory.setHibernateProperties(hibernateProperties()); return sessionFactory; diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/IEmployeeDao.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/IEmployeeDao.java new file mode 100644 index 0000000000..68bf5d5bad --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/IEmployeeDao.java @@ -0,0 +1,8 @@ +package com.baeldung.manytomany.dao; + +import com.baeldung.manytomany.dao.common.IOperations; +import com.baeldung.manytomany.model.Employee; + +public interface IEmployeeDao extends IOperations{ + +} diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/IProjectDao.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/IProjectDao.java new file mode 100644 index 0000000000..d2645db44a --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/IProjectDao.java @@ -0,0 +1,8 @@ +package com.baeldung.manytomany.dao; + +import com.baeldung.manytomany.dao.common.IOperations; +import com.baeldung.manytomany.model.Project; + +public interface IProjectDao extends IOperations{ + +} diff --git a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/AbstractDao.java similarity index 87% rename from persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java rename to persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/AbstractDao.java index 5a6c76a93a..b37b48e645 100644 --- a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/AbstractDao.java @@ -1,4 +1,4 @@ -package com.baeldung.persistence.dao.common; +package com.baeldung.manytomany.dao.common; import java.io.Serializable; diff --git a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/AbstractHibernateDao.java similarity index 97% rename from persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java rename to persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/AbstractHibernateDao.java index f34866d883..9c8a8faa2e 100644 --- a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/AbstractHibernateDao.java @@ -1,4 +1,4 @@ -package com.baeldung.persistence.dao.common; +package com.baeldung.manytomany.dao.common; import java.io.Serializable; import java.util.List; diff --git a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/dao/common/IOperations.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/IOperations.java similarity index 87% rename from persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/dao/common/IOperations.java rename to persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/IOperations.java index 4ef99221ab..8a85b52fc9 100644 --- a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/dao/common/IOperations.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/IOperations.java @@ -1,4 +1,4 @@ -package com.baeldung.persistence.dao.common; +package com.baeldung.manytomany.dao.common; import java.io.Serializable; import java.util.List; diff --git a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/manytomany/dao/impl/EmployeeDao.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/impl/EmployeeDao.java similarity index 50% rename from persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/manytomany/dao/impl/EmployeeDao.java rename to persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/impl/EmployeeDao.java index 25fee8c379..b24013c567 100644 --- a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/manytomany/dao/impl/EmployeeDao.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/impl/EmployeeDao.java @@ -1,9 +1,10 @@ -package com.baeldung.persistence.manytomany.dao.impl; +package com.baeldung.manytomany.dao.impl; import org.springframework.stereotype.Repository; -import com.baeldung.hibernate.manytomany.model.Employee; -import com.baeldung.persistence.dao.common.AbstractHibernateDao; -import com.baeldung.persistence.manytomany.dao.IEmployeeDao; + +import com.baeldung.manytomany.dao.IEmployeeDao; +import com.baeldung.manytomany.dao.common.AbstractHibernateDao; +import com.baeldung.manytomany.model.Employee; @Repository public class EmployeeDao extends AbstractHibernateDao implements IEmployeeDao { diff --git a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/manytomany/dao/impl/ProjectDao.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/impl/ProjectDao.java similarity index 50% rename from persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/manytomany/dao/impl/ProjectDao.java rename to persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/impl/ProjectDao.java index 8fc29a5de3..a70212f519 100644 --- a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/persistence/manytomany/dao/impl/ProjectDao.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/impl/ProjectDao.java @@ -1,9 +1,10 @@ -package com.baeldung.persistence.manytomany.dao.impl; +package com.baeldung.manytomany.dao.impl; import org.springframework.stereotype.Repository; -import com.baeldung.hibernate.manytomany.model.Project; -import com.baeldung.persistence.dao.common.AbstractHibernateDao; -import com.baeldung.persistence.manytomany.dao.IProjectDao; + +import com.baeldung.manytomany.dao.IProjectDao; +import com.baeldung.manytomany.dao.common.AbstractHibernateDao; +import com.baeldung.manytomany.model.Project; @Repository diff --git a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/hibernate/manytomany/model/Employee.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Employee.java similarity index 97% rename from persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/hibernate/manytomany/model/Employee.java rename to persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Employee.java index bfe1b5ad29..39671c21bc 100644 --- a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/hibernate/manytomany/model/Employee.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Employee.java @@ -1,4 +1,4 @@ -package com.baeldung.hibernate.manytomany.model; +package com.baeldung.manytomany.model; import java.io.Serializable; import java.util.HashSet; diff --git a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/hibernate/manytomany/model/Project.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Project.java similarity index 96% rename from persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/hibernate/manytomany/model/Project.java rename to persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Project.java index c291d7d7af..b5dc3cb856 100644 --- a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/hibernate/manytomany/model/Project.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Project.java @@ -1,8 +1,9 @@ -package com.baeldung.hibernate.manytomany.model; +package com.baeldung.manytomany.model; import java.io.Serializable; import java.util.HashSet; import java.util.Set; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/hibernate/manytomany/util/HibernateUtil.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/util/HibernateUtil.java similarity index 90% rename from persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/hibernate/manytomany/util/HibernateUtil.java rename to persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/util/HibernateUtil.java index ff035c0c37..d429564564 100644 --- a/persistence-modules/hibernate-many-to-many/src/main/java/com/baeldung/hibernate/manytomany/util/HibernateUtil.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/util/HibernateUtil.java @@ -1,14 +1,15 @@ -package com.baeldung.hibernate.manytomany.util; +package com.baeldung.manytomany.util; import org.hibernate.SessionFactory; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.service.ServiceRegistry; -import com.baeldung.hibernate.manytomany.model.Employee; -import com.baeldung.hibernate.manytomany.model.Project; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.baeldung.manytomany.model.Employee; +import com.baeldung.manytomany.model.Project; + public class HibernateUtil { private static final Logger LOGGER = LoggerFactory.getLogger(HibernateUtil.class); diff --git a/persistence-modules/hibernate-many-to-many/src/main/resources/logback.xml b/persistence-modules/hibernate-mapping-2/src/main/resources/logback.xml similarity index 100% rename from persistence-modules/hibernate-many-to-many/src/main/resources/logback.xml rename to persistence-modules/hibernate-mapping-2/src/main/resources/logback.xml diff --git a/persistence-modules/hibernate-mapping-2/src/main/resources/persistence-h2.properties b/persistence-modules/hibernate-mapping-2/src/main/resources/persistence-h2.properties new file mode 100644 index 0000000000..9c8cf6e02b --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/main/resources/persistence-h2.properties @@ -0,0 +1,11 @@ +# jdbc.X +jdbc.driverClassName=org.h2.Driver +jdbc.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 +jdbc.eventGeneratedId=sa +jdbc.user=sa +jdbc.pass= + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.H2Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop \ No newline at end of file diff --git a/persistence-modules/hibernate-many-to-many/src/test/java/com/baeldung/SpringContextTest.java b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/SpringContextTest.java similarity index 91% rename from persistence-modules/hibernate-many-to-many/src/test/java/com/baeldung/SpringContextTest.java rename to persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/SpringContextTest.java index 24c038aeb6..f1a6f675ce 100644 --- a/persistence-modules/hibernate-many-to-many/src/test/java/com/baeldung/SpringContextTest.java +++ b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/SpringContextTest.java @@ -6,8 +6,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; - -import com.baeldung.spring.PersistenceConfig; +import com.baeldung.manytomany.PersistenceConfig; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) diff --git a/persistence-modules/hibernate-many-to-many/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationJavaConfigMainIntegrationTest.java b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationJavaConfigMainIntegrationTest.java similarity index 89% rename from persistence-modules/hibernate-many-to-many/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationJavaConfigMainIntegrationTest.java rename to persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationJavaConfigMainIntegrationTest.java index 797d3384a0..19d1a5ff50 100644 --- a/persistence-modules/hibernate-many-to-many/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationJavaConfigMainIntegrationTest.java +++ b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationJavaConfigMainIntegrationTest.java @@ -2,6 +2,7 @@ package com.baeldung.hibernate.manytomany; import java.util.HashSet; import java.util.Set; + import org.hibernate.Session; import org.hibernate.SessionFactory; import org.junit.After; @@ -12,9 +13,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; -import com.baeldung.hibernate.manytomany.model.Employee; -import com.baeldung.hibernate.manytomany.model.Project; -import com.baeldung.manytomany.spring.PersistenceConfig; +import com.baeldung.manytomany.PersistenceConfig; +import com.baeldung.manytomany.model.Employee; +import com.baeldung.manytomany.model.Project; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) diff --git a/persistence-modules/hibernate-many-to-many/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationMainIntegrationTest.java b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationMainIntegrationTest.java similarity index 92% rename from persistence-modules/hibernate-many-to-many/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationMainIntegrationTest.java rename to persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationMainIntegrationTest.java index d09b2888df..bfa158d43f 100644 --- a/persistence-modules/hibernate-many-to-many/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationMainIntegrationTest.java +++ b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationMainIntegrationTest.java @@ -1,10 +1,12 @@ package com.baeldung.hibernate.manytomany; -import static org.junit.Assert.assertNotNull; import static junit.framework.TestCase.assertEquals; +import static org.junit.Assert.assertNotNull; + import java.util.HashSet; import java.util.List; import java.util.Set; + import org.hibernate.Session; import org.hibernate.SessionFactory; import org.junit.After; @@ -13,9 +15,9 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import com.baeldung.hibernate.manytomany.util.HibernateUtil; -import com.baeldung.hibernate.manytomany.model.Employee; -import com.baeldung.hibernate.manytomany.model.Project; +import com.baeldung.manytomany.model.Employee; +import com.baeldung.manytomany.model.Project; +import com.baeldung.manytomany.util.HibernateUtil; /** * Configured in: manytomany.cfg.xml diff --git a/persistence-modules/hibernate-many-to-many/src/test/resources/manytomany.cfg.xml b/persistence-modules/hibernate-mapping-2/src/test/resources/manytomany.cfg.xml similarity index 97% rename from persistence-modules/hibernate-many-to-many/src/test/resources/manytomany.cfg.xml rename to persistence-modules/hibernate-mapping-2/src/test/resources/manytomany.cfg.xml index 2ca23d57d3..3ddff9a993 100644 --- a/persistence-modules/hibernate-many-to-many/src/test/resources/manytomany.cfg.xml +++ b/persistence-modules/hibernate-mapping-2/src/test/resources/manytomany.cfg.xml @@ -13,4 +13,4 @@ false create-drop - + \ No newline at end of file