4 Replies Latest reply on Dec 15, 2007 6:52 AM by trouby

    Hibernate + Groovy

    trouby

      Hey,
      My question is more related to Hibernate&Groovy but since I mix it all with seam / seam provides examples with groovy I felt like it's ok to ask my question here :)


      I have looked at the hotel booking example with groovy and it seems to work fine, but at the moment I'm trying to write an entity with groovy which EXTENDS another entity written in java(that annotated with @Inheritance) then I get an exception that Hibernate tries to persist column an unknow column type named groovy.lang.MetaClass,

      indeed there is such a property, but I can't see any way to automatically ignore it,

      I tried to add to the groovy entity the following:
      {code}
      @Transient
      MetaClass metaClass
      {code}

      but no luck,


      What I'm curious about, if this property available for any groovy object, then why hibernate does try to persist it without inheritance as well ?




      Many thanks,

      Asaf.

        • 1. Re: Hibernate + Groovy
          epbernard

          oups, interesting. I don't really understand why we don't run into the problem when there is no inheritance.
          I will try and catch guillaume to talk about how to solve that.

          • 2. Re: Hibernate + Groovy
            trouby

            Sure,

            Thank you for your answer Emmanuel,


            Asaf.

            • 3. Re: Hibernate + Groovy
              epbernard

              OK we found the issue.
              In the first case (pure Groovy), the annotations are placed on the fields (always the case for Groovy) and metaClass is indeed a transient field thus ignored.

              In the second case I suspect your java class has it's annotations on getters. So JPA expect to find annotations on getters and process getters of the Groovy class. Hence it picks getMetaClass, and incidentally does not read your annotations in Groovy (field instead of property).

              The solution is to use field annotations for your superclass in Java.

              • 4. Re: Hibernate + Groovy
                trouby

                Yeah, that is for sure the case, sounds good!


                thanks.