hibernate3-maven-plugin dependencies for newer version of hibernate

Deadly 提交于 2019-12-05 10:15:53

I was able to get this working with the following set of dependencies (i.e. 3.5.1-Final for all hibernate jars)

                <dependencies>
                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-core</artifactId>
                        <version>${hibernate-core.version}</version>
                    </dependency>

                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-entitymanager</artifactId>
                        <version>${hibernate-entitymanager.version}</version>
                    </dependency>

                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-annotations</artifactId>
                        <version>${hibernate-annotations.version}</version>
                    </dependency>

                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>ejb3-persistence</artifactId>
                        <version>3.3.2.Beta1</version>
                    </dependency>

                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-tools</artifactId>
                        <version>${hibernate-tools.version}</version>
                    </dependency>
                </dependencies>

It's hard to say what is happening exactly but the fact is that the version 2.2. of hibernate3-maven-plugin declares hibernate-core 3.3.1.GA and hibernate-tools 3.2.3.GA as dependencies and is compiled against those versions. Did you try to replace them? If yes, I don't think you can (especially since they seem to introduce non compatible changes).

Having that said, this shouldn't prevent you from declaring hibernate-entitymanager-3.5.1-Final as dependency in your project and let the plugin use other versions (which should be the default behavior).

I had a similar issue.

After running "mvn dependency:tree", I saw that unitils-dbunit:3.1 depended on an older hibernate.jar...

[INFO] +- org.unitils:unitils-dbunit:jar:3.1:test
[INFO] |  +- org.unitils:unitils-core:jar:3.1:test
[INFO] |  |  +- commons-logging:commons-logging:jar:1.1:test
[INFO] |  |  +- commons-lang:commons-lang:jar:2.5:test (version managed from 2.3)
[INFO] |  |  \- ognl:ognl:jar:2.6.9:test
[INFO] |  +- org.unitils:unitils-database:jar:3.1:test
[INFO] |  |  +- org.unitils:unitils-dbmaintainer:jar:3.1:test
[INFO] |  |  |  \- org.hibernate:hibernate:jar:3.2.5.ga:test

Moving the Hibernate libs before the unitils dependency solved the problem. Order matters.

Good luck, J.

For Hibernate 3.6.0.Final I setup the plugin as follows:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>hibernate3-maven-plugin</artifactId>
    <version>2.2</version>
    <dependencies>
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.9.1</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.6.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>3.6.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft</groupId>
            <artifactId>sqljdbc4</artifactId>
            <version>3.0.1301</version>
        </dependency>
    </dependencies>
</plugin>

This solution is the best for me. Just add one dependency, and it will add the rest of necesary dependencies:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>4.2.1.Final</version>
</dependency>

Latest version here: http://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!