From bc6ef10c6db2b88235552650f2735fa8a7473235 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 22 Mar 2020 23:38:04 +0530 Subject: [PATCH] JAVA-4: removed hibernate5-mapping module --- .../hibernate5-mapping/README.md | 11 --- .../hibernate5-mapping/pom.xml | 76 --------------- .../com/baeldung/hibernate/HibernateUtil.java | 96 ------------------- .../main/resources/META-INF/persistence.xml | 18 ---- .../src/main/resources/logback.xml | 13 --- 5 files changed, 214 deletions(-) delete mode 100644 persistence-modules/hibernate5-mapping/README.md delete mode 100644 persistence-modules/hibernate5-mapping/pom.xml delete mode 100644 persistence-modules/hibernate5-mapping/src/main/java/com/baeldung/hibernate/HibernateUtil.java delete mode 100644 persistence-modules/hibernate5-mapping/src/main/resources/META-INF/persistence.xml delete mode 100644 persistence-modules/hibernate5-mapping/src/main/resources/logback.xml diff --git a/persistence-modules/hibernate5-mapping/README.md b/persistence-modules/hibernate5-mapping/README.md deleted file mode 100644 index f18b0b63de..0000000000 --- a/persistence-modules/hibernate5-mapping/README.md +++ /dev/null @@ -1,11 +0,0 @@ -## Hibernate 5 - -This module contains articles about Hibernate 5. - -### Relevant articles: - -- [Dynamic Mapping with Hibernate](http://www.baeldung.com/hibernate-dynamic-mapping) -- [Hibernate Inheritance Mapping](http://www.baeldung.com/hibernate-inheritance) -- [Mapping A Hibernate Query to a Custom Class](https://www.baeldung.com/hibernate-query-to-custom-class) -- [Hibernate – Mapping Date and Time](http://www.baeldung.com/hibernate-date-time) -- [Mapping LOB Data in Hibernate](http://www.baeldung.com/hibernate-lob) \ No newline at end of file diff --git a/persistence-modules/hibernate5-mapping/pom.xml b/persistence-modules/hibernate5-mapping/pom.xml deleted file mode 100644 index 59e0547671..0000000000 --- a/persistence-modules/hibernate5-mapping/pom.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - 4.0.0 - hibernate5-mapping - 0.0.1-SNAPSHOT - hibernate5-mapping - - - com.baeldung - persistence-modules - 1.0.0-SNAPSHOT - - - - - org.hibernate - hibernate-core - ${hibernate.version} - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - com.h2database - h2 - ${h2.version} - - - org.hibernate - hibernate-spatial - ${hibernate.version} - - - org.opengeo - geodb - ${geodb.version} - - - mysql - mysql-connector-java - ${mysql.version} - - - ch.vorburger.mariaDB4j - mariaDB4j - ${mariaDB4j.version} - - - org.hibernate - hibernate-testing - ${hibernate.version} - - - - - - geodb-repo - GeoDB repository - http://repo.boundlessgeo.com/main/ - - - - - 5.3.7.Final - 6.0.6 - 2.2.3 - 3.8.0 - 0.9 - - - diff --git a/persistence-modules/hibernate5-mapping/src/main/java/com/baeldung/hibernate/HibernateUtil.java b/persistence-modules/hibernate5-mapping/src/main/java/com/baeldung/hibernate/HibernateUtil.java deleted file mode 100644 index 28e1af49ed..0000000000 --- a/persistence-modules/hibernate5-mapping/src/main/java/com/baeldung/hibernate/HibernateUtil.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.baeldung.hibernate; - -import java.io.FileInputStream; -import java.io.IOException; -import java.net.URL; -import java.util.Properties; - -import org.apache.commons.lang3.StringUtils; -import org.hibernate.SessionFactory; -import org.hibernate.boot.Metadata; -import org.hibernate.boot.MetadataSources; -import org.hibernate.boot.registry.StandardServiceRegistryBuilder; -import org.hibernate.service.ServiceRegistry; - -import com.baeldung.hibernate.entities.DeptEmployee; -import com.baeldung.hibernate.pojo.Employee; -import com.baeldung.hibernate.pojo.EntityDescription; -import com.baeldung.hibernate.pojo.Phone; -import com.baeldung.hibernate.pojo.TemporalValues; -import com.baeldung.hibernate.pojo.inheritance.Animal; -import com.baeldung.hibernate.pojo.inheritance.Bag; -import com.baeldung.hibernate.pojo.inheritance.Book; -import com.baeldung.hibernate.pojo.inheritance.Car; -import com.baeldung.hibernate.pojo.inheritance.MyEmployee; -import com.baeldung.hibernate.pojo.inheritance.MyProduct; -import com.baeldung.hibernate.pojo.inheritance.Pen; -import com.baeldung.hibernate.pojo.inheritance.Pet; -import com.baeldung.hibernate.pojo.inheritance.Vehicle; - -public class HibernateUtil { - private static String PROPERTY_FILE_NAME; - - public static SessionFactory getSessionFactory() throws IOException { - return getSessionFactory(null); - } - - public static SessionFactory getSessionFactory(String propertyFileName) throws IOException { - PROPERTY_FILE_NAME = propertyFileName; - ServiceRegistry serviceRegistry = configureServiceRegistry(); - return makeSessionFactory(serviceRegistry); - } - - public static SessionFactory getSessionFactoryByProperties(Properties properties) throws IOException { - ServiceRegistry serviceRegistry = configureServiceRegistry(properties); - return makeSessionFactory(serviceRegistry); - } - - private static SessionFactory makeSessionFactory(ServiceRegistry serviceRegistry) { - MetadataSources metadataSources = new MetadataSources(serviceRegistry); - - metadataSources.addPackage("com.baeldung.hibernate.pojo"); - metadataSources.addAnnotatedClass(Employee.class); - metadataSources.addAnnotatedClass(Phone.class); - metadataSources.addAnnotatedClass(EntityDescription.class); - metadataSources.addAnnotatedClass(TemporalValues.class); - metadataSources.addAnnotatedClass(DeptEmployee.class); - metadataSources.addAnnotatedClass(com.baeldung.hibernate.entities.Department.class); - metadataSources.addAnnotatedClass(Animal.class); - metadataSources.addAnnotatedClass(Bag.class); - metadataSources.addAnnotatedClass(Book.class); - metadataSources.addAnnotatedClass(Car.class); - metadataSources.addAnnotatedClass(MyEmployee.class); - metadataSources.addAnnotatedClass(MyProduct.class); - metadataSources.addAnnotatedClass(Pen.class); - metadataSources.addAnnotatedClass(Pet.class); - metadataSources.addAnnotatedClass(Vehicle.class); - - - Metadata metadata = metadataSources.getMetadataBuilder() - .build(); - - return metadata.getSessionFactoryBuilder() - .build(); - - } - - private static ServiceRegistry configureServiceRegistry() throws IOException { - return configureServiceRegistry(getProperties()); - } - - private static ServiceRegistry configureServiceRegistry(Properties properties) throws IOException { - return new StandardServiceRegistryBuilder().applySettings(properties) - .build(); - } - - public static Properties getProperties() throws IOException { - Properties properties = new Properties(); - URL propertiesURL = Thread.currentThread() - .getContextClassLoader() - .getResource(StringUtils.defaultString(PROPERTY_FILE_NAME, "hibernate.properties")); - try (FileInputStream inputStream = new FileInputStream(propertiesURL.getFile())) { - properties.load(inputStream); - } - return properties; - } -} \ No newline at end of file diff --git a/persistence-modules/hibernate5-mapping/src/main/resources/META-INF/persistence.xml b/persistence-modules/hibernate5-mapping/src/main/resources/META-INF/persistence.xml deleted file mode 100644 index 474eeb7a44..0000000000 --- a/persistence-modules/hibernate5-mapping/src/main/resources/META-INF/persistence.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - Hibernate EntityManager Demo - true - - - - - - - - - - \ No newline at end of file diff --git a/persistence-modules/hibernate5-mapping/src/main/resources/logback.xml b/persistence-modules/hibernate5-mapping/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/persistence-modules/hibernate5-mapping/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file