Maven Conflict of Dom4j/Hibernate and Selenium

pom.xml

<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>

<groupId>com.ittechoffice</groupId>

<artifactId>HelloWorld-Selenium</artifactId>

<version>0.0.1-SNAPSHOT</version>

<repositories>

     <repository>

        <id>JBoss repository</id>

        <url>http://repository.jboss.com/maven2/</url>

     </repository>

      <repository>

     <id>Java.Net</id>

     <url>http://download.java.net/maven/2/</url>

    </repository>

   </repositories>

<dependencies>

<dependency>

<groupId>org.seleniumhq.selenium</groupId>

<artifactId>selenium-java</artifactId>

<version>2.53.0</version>

</dependency>

<dependency>

<groupId>org.seleniumhq.selenium</groupId>

<artifactId>htmlunit-driver</artifactId>

<version>2.20</version>

</dependency>

<dependency>

<groupId>org.apache.commons</groupId>

<artifactId>commons-math3</artifactId>

<version>3.2</version>

</dependency>

<!-- H2 database -->

<dependency>

    <groupId>com.h2database</groupId>

      <artifactId>h2</artifactId>

      <version>1.4.191</version>

</dependency>

<!-- MySQL database driver -->

<dependency>

<groupId>mysql</groupId>

<artifactId>mysql-connector-java</artifactId>

<version>5.1.9</version>

</dependency>

<!-- Hibernate core -->

<dependency>

<groupId>hibernate</groupId>

<artifactId>hibernate3</artifactId>

<version>3.2.3.GA</version>

</dependency>

<!-- Hibernate annotation -->

<dependency>

<groupId>hibernate-annotations</groupId>

<artifactId>hibernate-annotations</artifactId>

<version>3.3.0.GA</version>

</dependency>

<dependency>

<groupId>hibernate-commons-annotations</groupId>

<artifactId>hibernate-commons-annotations</artifactId>

<version>3.0.0.GA</version>

</dependency>

<!-- Hibernate library dependecy start -->

<dependency>

<groupId>dom4j</groupId>

<artifactId>dom4j</artifactId>

<version>1.6.1</version>

</dependency>

<dependency>

<groupId>commons-logging</groupId>

<artifactId>commons-logging</artifactId>

<version>1.1.1</version>

</dependency>

<dependency>

<groupId>commons-collections</groupId>

<artifactId>commons-collections</artifactId>

<version>3.2.1</version>

</dependency>

<dependency>

<groupId>cglib</groupId>

<artifactId>cglib</artifactId>

<version>2.2</version>

</dependency>

<!-- Hibernate library dependecy end -->

<dependency>

<groupId>javax.transaction</groupId>

<artifactId>jta</artifactId>

<version>1.1</version>

</dependency>

      <!-- Javaee API -->

<dependency>

      <groupId>javax</groupId>

      <artifactId>javaee-api</artifactId>

      <version>6.0</version>

</dependency>

</dependencies>

</project>

 

Solution

<dependency>

<groupId>dom4j</groupId>

<artifactId>dom4j</artifactId>

<version>1.6.1</version>

<exclusions>

        <exclusion>

            <artifactId>xml-apis</artifactId>

            <groupId>xml-apis</groupId>

        </exclusion>        

      </exclusions>

</dependency>

 

What difference between Hibernate and MyBatis

MyBatis 

  • Best used when you need complete control of the SQL.
  • Useful when the SQL queries need to be fine-tuned.
  • Should NOT be used when full control of both application and database design. Because in this case application could be modified to suit the database or vice versa.
  • Reverted ORM
  • Not support non-relational database

Hibernate 

  • Best when you have full control of both application and database. You can tune application to suit database or vice versa.
  • Best option of programmer who are less familiar to SQL
  • [Could use createNativeQuery() in EntityManager to control Query]

 

Q&A

What difference between JPA and Hibernate? 

Hibernate is an implementation while JPA is a specification.

Is MyBatis an ORM mapper?

Unlike ORM framework, MyBatis map Java Object to SQL.

 

Disadvantage of Different JPA

Hibernate

Too much magic

MyBastis

More time in development and maintenance (Have to rewrite all query if object mode change)