1 2 Previous Next 17 Replies Latest reply on Feb 28, 2014 10:31 AM by maxandersen

    Hibernate tools for Hibernate 4.x

    marcelstoer

      What's the status of Hibernate tools for Hibernate 4.x?

       

      Problem

      After upgrading to Hibernate 4.x the hibernate3-maven-plugin 3.0 failed. It uses hibernate-tools 3.2.4.GA internally. I could work around the issues by adding an explicit dependency to Hibernate 3.6 like so

      {code:xml}

      <dependencies>

        <dependency>

          <groupId>org.hibernate</groupId>

          <artifactId>hibernate-core</artifactId>

          <version>3.6.10.Final</version>

        </dependency>

      </dependencies>

      {code}

       

      This, however, has negative side-effects because new Hibernate 4 features are not present while running hbm2ddl.

      Thanks to the new data type auto-registration in Hibernate 4 (put to work by Usertype for Joda Time data types) we were able to remove all @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime") annotations from our entities. Now while running hbm2ddl in Maven "works" the generated schema doesn't contain proper data type declarations because Hibernate 3.6 doesn't know about Joda Time.

       

      Hibernate tools on Github

      I saw that there's some action on https://github.com/hibernate/hibernate-tools/. How likely is it that building the latest 4.0.0 SNAPSHOT from there myself will fix the above mentioned issues?

       

      Cheers,

        • 1. Re: Hibernate tools for Hibernate 4.x
          marcelstoer

          Never mind...

           

          My findings:

          • Building 4.0.0 SNAPSHOT myself sort-of work (odd dependencies to Eclipse stuff not in Maven Central).
          • Using the manually built 4.0.0 SNAPSHOT in my own Maven build to run hbm2ddl failed with some Ant errors. I suspected Ant version conflicts (two different Ant versions in classpath). Specifically excluding Ant from the 4.0.0 SNAPSHOT dependency yielded no sensible result. The build didn't fail but no DDL was produced.
          • I had to revert all my changes and re-add the @Type annotations :-( I realized that hbm2ddl run from Hibernate tools during a Maven build can never do without because there's nothing there that would populate the type registry (equivalent to what Usertype does when the app runs).

           

          All in all several wasted hours just to realize that Hibernate 4 auto-registration is cool but useless if you still depend on hbm2ddl during Maven build.

          1 of 1 people found this helpful
          • 2. Re: Hibernate tools for Hibernate 4.x
            maxandersen

            heya, sorry for not responding sooner (vacation time).

             

            yes, you should be able to use trunk on github - fixing the lack of proper tags in the master repo this week so stay tuned.

             

            About autoregistered usertypes, can you show me the code you actually want to have executed ?

             

            There might be a hook - and if not we actually should get such hook created.

            1 of 1 people found this helpful
            • 3. Re: Hibernate tools for Hibernate 4.x
              jackalista

              Hi Max,

               

              I have a more general question about using hibernate tools to reverse engineer domain objects from an exisitng database.  Is there some content on here somewhere to show how to do that?  I've not found any discussions that relate to the current tools set for eclipse indigo and the plugins for hibernate tools.  I did get the tools installed successfully but I'm not seeing how to reverse engineer hibernate domain objects from our DB.  All the discussions I did see about reverse engineering this stuff appear to be in seam discussions, so I tried to create a seam project and see if that made things clearer but I'm still not seeing a way to get this working.  Any pointers to how this is supposed to be done?  Thanks.

              • 4. Re: Hibernate tools for Hibernate 4.x
                marcelstoer

                Better late than never they say...

                yes, you should be able to use trunk on github - fixing the lack of proper tags in the master repo this week so stay tuned.

                 

                I added my hand-woven 4.0.0 tools SNAPSHOT to the hibernate3-maven-plugin and experienced the described the Ant issues. I don't think this is a use case you actually test. Why should you..once tools 4.0.0 is out the Maven plugin maintainer(s) have to take care of that. IMO there's little hope, though. Never got any feedback to the post I sent to their mailing list.

                About autoregistered usertypes, can you show me the code you actually want to have executed ?

                 

                We use the Usertype library to map Joda Time data types via Hibernate (it's also JSR-310 compliant). It provides several implementations of org.hibernate.integrator.spi.Integrator. The relevant abstract class is AbstractUserTypeHibernateIntegrator (autoRegisterUsertypes()). The relevant sub class that provides implementations of getUserTypes() and getCompositeUserTypes() is UserTypeJodaTimeHibernateIntegrator.

                • 5. Re: Hibernate tools for Hibernate 4.x
                  maxandersen

                  Answered in your own thread at https://community.jboss.org/message/753399#753399

                   

                  Please don't cross-post

                  • 6. Re: Hibernate tools for Hibernate 4.x
                    maxandersen
                    yes, you should be able to use trunk on github - fixing the lack of proper tags in the master repo this week so stay tuned.

                     

                    I added my hand-woven 4.0.0 tools SNAPSHOT to the hibernate3-maven-plugin and experienced the described the Ant issues. I don't think this is a use case you actually test. Why should you..once tools 4.0.0 is out the Maven plugin maintainer(s) have to take care of that. IMO there's little hope, though. Never got any feedback to the post I sent to their mailing list.

                     

                    yeah, I wasn't involved in hibernate3-maven-plugin; that was all externally done and I've rarely heard from them either. I wanted them to contribute it so the maven plugin could work more or less the same as the ant tasks and eclipse integration. Just never materialized ;(

                     

                    But its sure that they can't run with hibernate4 jars in a hibernate3 plugin - that will never work without changes.

                     

                    About autoregistered usertypes, can you show me the code you actually want to have executed ?

                     

                    We use the Usertype library to map Joda Time data types via Hibernate (it's also JSR-310 compliant). It provides several implementations of org.hibernate.integrator.spi.Integrator. The relevant abstract class is AbstractUserTypeHibernateIntegrator (autoRegisterUsertypes()). The relevant sub class that provides implementations of getUserTypes() and getCompositeUserTypes() is UserTypeJodaTimeHibernateIntegrator.

                     

                    I haven't done much work with auto registered types but my understanding was that these jars just needed to be on the classpath when "starting" hibernate. Do you have these usertypes on the classpath ?

                     

                    if yes, then yes we definitely need to add in a hook for this to happen and I would appreciate if you could open a issue on https://jira.jboss.org/jira/browse/JBIDE with a small example that fails for you.

                     

                    Thanks!

                    • 7. Re: Hibernate tools for Hibernate 4.x
                      maxandersen

                      just learned that the auto type registration happens at SessionFactory creation time - that explains why you don't see those types.

                       

                      we should try fix this in tools - please open a https://jira.jboss.org/jira/browse/JBIDE issue with an example so we can be sure to cover your usecase - thanks!

                      • 8. Re: Hibernate tools for Hibernate 4.x
                        thomas.letsch

                        I got the latest hibernate-tools running under maven with the help of the ant-run plugin. The solution is described in more details in my blog: http://www.thomas-letsch.de/2013/generate-ddl-with-hibernate-tools-jpa-and-maven/. If this works for others as well, there is no urgent need for a newer hibernate3-maven-plugin anymore.

                        • 9. Re: Hibernate tools for Hibernate 4.x
                          schvanhugten

                          I checked the projects (hibernate-tools and hibernate3-maven-plugin) out from SVN and GIT and recompiled them against 4.2.7.SP1 jars. I think every goal now works, but I have only really tested hbm2ddl. You can check out the jar (and source code) at http://sourceforge.net/projects/hibernate4mavenplugin/files/?source=navbar.

                          • 10. Re: Hibernate tools for Hibernate 4.x
                            jzwolak

                            Any update on this?  It seems that Hibernate Tools is not under active development.  On GitHub I see the last commit was 1-2 years ago, depending.  The JBoss tools seem to have engulfed hibernate tools, but the version for hibernate tools remains at 3.3.0 M5 and seems old and out of date (last copyright from 2011).

                             

                            I have a successful build system using Hibernate tools from Maven Central: org.hibernate:hibernate-tools:4.0.0-CR1

                             

                            But I worry about the future and even if what I'm using is stable or the latest of what's available.

                            • 11. Re: Hibernate tools for Hibernate 4.x
                              maxandersen

                              Where are you seeing the version remains at 3.3.0.M5 ?

                               

                              MAster is at 4.0 at https://github.com/hibernate/hibernate-tools

                               

                              But yes, hibernate tools have only received maintanence patches in a long time - I/we haven't had anything to do with the maven integration though.

                               

                              If anyone is up for maintaining and moving hibernate tools forward in and outside of eclipse ping me.

                              • 12. Re: Hibernate tools for Hibernate 4.x
                                jzwolak

                                Hibernate Tools Reference Guide

                                Which is linked to (indirectly) from here: Reference - JBoss Community

                                • 13. Re: Hibernate tools for Hibernate 4.x
                                  karlvr

                                  I've had similar issues and went down a rabbit hole updating Hibernate Tools to Hibernate 4.3.1.Final. It works now for my use. I've submitted a pull request to start the conversation hopefully to update Hibernate Tools. Here's my Github repo karlvr/hibernate-tools · GitHub

                                  • 14. Re: Hibernate tools for Hibernate 4.x
                                    jzwolak

                                    Hi Karl, it seems that your pull request was accepted.  I wonder if I get the source from hibernate/hibernate-tools · GitHub , will it work?  Are all your changes in the hibernate tools master branch now?

                                    1 2 Previous Next