Status of Hibernate annotations on a Groovy domain class (POGO)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

Status of Hibernate annotations on a Groovy domain class (POGO)

elvanor
Hello,

I am writing this to know the status of Hibernate annotations support
in Grails currently, for Groovy domain classes. I am using Grails
0.5.6 - maybe things have improved in 0.6 so please tell me.

Currently the only information I've found on the subject was a
previous thread in the mailing list. Hibernate annotations can somehow
be used in Groovy domain classes, but I encountered the following
problems:

* First, I had to move the file Section.groovy out of
grails-app/domain to /src/groovy, else I would have errors (duplicate
stuff: same errors as the previous person wrote on the thread I
mention). This probably means that my class is no longer considered a
domain, so I lose all the dynamics methods associated with it, right?

* Second, I could not use annotations from org.hibernate.annotations
import org.hibernate.annotations would produce errors when launching
grails run-app (class not found). Maybe this is only a classpath
problem, eg Grails does not load the correct hibernate annotations
jar?

This second problem is annoying as I cannot use the Hibernate
annotations extensions to the EJB3 annotations. The first problem
prevents a nice integration within the Grails framework.

It would really really be nice to be able to customize the Hibernate
mappings on POGOs: this would allow to do easily things that GORM does
not permit right now, while benefiting from Grails advantages.

Should I open a JIRA feature request for this? Does Grails 0.6 imporve
the situation?

Jean-Noël
Reply | Threaded
Open this post in threaded view
|

Re: Status of Hibernate annotations on a Groovy domain class (POGO)

graemer
I recommend you try 0.6, if you wait a little while I'll have an RC
for you to download

Cheers

On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:

> Hello,
>
> I am writing this to know the status of Hibernate annotations support
> in Grails currently, for Groovy domain classes. I am using Grails
> 0.5.6 - maybe things have improved in 0.6 so please tell me.
>
> Currently the only information I've found on the subject was a
> previous thread in the mailing list. Hibernate annotations can somehow
> be used in Groovy domain classes, but I encountered the following
> problems:
>
> * First, I had to move the file Section.groovy out of
> grails-app/domain to /src/groovy, else I would have errors (duplicate
> stuff: same errors as the previous person wrote on the thread I
> mention). This probably means that my class is no longer considered a
> domain, so I lose all the dynamics methods associated with it, right?
>
> * Second, I could not use annotations from org.hibernate.annotations
> import org.hibernate.annotations would produce errors when launching
> grails run-app (class not found). Maybe this is only a classpath
> problem, eg Grails does not load the correct hibernate annotations
> jar?
>
> This second problem is annoying as I cannot use the Hibernate
> annotations extensions to the EJB3 annotations. The first problem
> prevents a nice integration within the Grails framework.
>
> It would really really be nice to be able to customize the Hibernate
> mappings on POGOs: this would allow to do easily things that GORM does
> not permit right now, while benefiting from Grails advantages.
>
> Should I open a JIRA feature request for this? Does Grails 0.6 imporve
> the situation?
>
> Jean-Noël
>


--
Graeme Rocher
Grails Project Lead
http://grails.org

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Status of Hibernate annotations on a Groovy domain class (POGO)

elvanor
In reply to this post by elvanor
Forget about question 2): it was just a stupid mistake on my part.
I've now managed to import that package correctly.

On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:

> Hello,
>
> I am writing this to know the status of Hibernate annotations support
> in Grails currently, for Groovy domain classes. I am using Grails
> 0.5.6 - maybe things have improved in 0.6 so please tell me.
>
> Currently the only information I've found on the subject was a
> previous thread in the mailing list. Hibernate annotations can somehow
> be used in Groovy domain classes, but I encountered the following
> problems:
>
> * First, I had to move the file Section.groovy out of
> grails-app/domain to /src/groovy, else I would have errors (duplicate
> stuff: same errors as the previous person wrote on the thread I
> mention). This probably means that my class is no longer considered a
> domain, so I lose all the dynamics methods associated with it, right?
>
> * Second, I could not use annotations from org.hibernate.annotations
> import org.hibernate.annotations would produce errors when launching
> grails run-app (class not found). Maybe this is only a classpath
> problem, eg Grails does not load the correct hibernate annotations
> jar?
>
> This second problem is annoying as I cannot use the Hibernate
> annotations extensions to the EJB3 annotations. The first problem
> prevents a nice integration within the Grails framework.
>
> It would really really be nice to be able to customize the Hibernate
> mappings on POGOs: this would allow to do easily things that GORM does
> not permit right now, while benefiting from Grails advantages.
>
> Should I open a JIRA feature request for this? Does Grails 0.6 imporve
> the situation?
>
> Jean-Noël
>
Reply | Threaded
Open this post in threaded view
|

Re: Status of Hibernate annotations on a Groovy domain class (POGO)

elvanor
OK. So after playing a bit with 0.6-RC1 here is the situation for me,
and a comparison with 0.5.6:

0.5.6:

* Unable to have an annotated groovy class in grails-app/domain (would
lead to an Hibernate duplicate error)
* In src/groovy, an annotated class would work but not completely correct.

0.6:

* This time I can have an annotated groovy class in grails-app/domain,
however it seems to me all annotations just get ignored. Here is my
source file:

import javax.persistence.*
import org.hibernate.annotations.*

@Entity
@Table(name="bert")
class Section
{
        @Id
        Long id
       
        Long getId()
        {
                return id
        }

    @Column(name="real_try")
    String realName

    @CollectionOfElements
    @Column(name="favormig", nullable=false)
        Set <String> questions = new HashSet <String> ()

    public Set <String> getQuestions()
    {
        return questions;
    }
}

@Table gets ignored (in db the name by convention is used), as well as
 @Column(name="real_try") (the column name is real_name as per
convention). Finally @CollectionOfElements don't work at all (no other
tables is created).

In /src/groovy, things work almost perfectly. The following source
file gets properly mapped:

import javax.persistence.*
import org.hibernate.annotations.*

@Entity
@Table(name="bubu")
class OtherSection
{
        @Id
        Long id
       
        Long getId()
        {
                return id
        }

    @Column(name="real_blabla")
    String realName

 @CollectionOfElements
// @JoinTable
// (
// table=@Table(name="gaga"),
// joinColumns = @JoinColumn(name="BoyId")
// )
   @Column(name="favoritepoupon", nullable=false)
        Set <String> questions = new HashSet <String> ()

    public Set <String> getQuestions()
    {
        return questions;
    }
}

The correct table 'bubu" gets created, and another table
bubu_questions get created too, so the @CollectionOfElements is
working. However, if I remove the comments around @JoinTable I get a
Groovy error and the server won't start:

Compilation error:
org.codehaus.groovy.control.MultipleCompilationErrorsException:
startup failed,
/home/elvanor/development/shoopz/shop-engine/src/groovy/OtherSection.groovy:
19: unexpected token: @ @ line 19, column 2.

The last thing may be a Groovy thing. However, the fact that
annotations don't work at all in the domain classes in a Grails thing
and is problematic. Can you confirm this is "normal", Graeme? Could
that feature be implemented? Shall I raise a JIRA?

Currently my only viable option to use annotations would be to move
files to src/groovy. How can I then use dynamics methods on these
classes?

Jean-Noël



On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:

> Forget about question 2): it was just a stupid mistake on my part.
> I've now managed to import that package correctly.
>
> On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
> > Hello,
> >
> > I am writing this to know the status of Hibernate annotations support
> > in Grails currently, for Groovy domain classes. I am using Grails
> > 0.5.6 - maybe things have improved in 0.6 so please tell me.
> >
> > Currently the only information I've found on the subject was a
> > previous thread in the mailing list. Hibernate annotations can somehow
> > be used in Groovy domain classes, but I encountered the following
> > problems:
> >
> > * First, I had to move the file Section.groovy out of
> > grails-app/domain to /src/groovy, else I would have errors (duplicate
> > stuff: same errors as the previous person wrote on the thread I
> > mention). This probably means that my class is no longer considered a
> > domain, so I lose all the dynamics methods associated with it, right?
> >
> > * Second, I could not use annotations from org.hibernate.annotations
> > import org.hibernate.annotations would produce errors when launching
> > grails run-app (class not found). Maybe this is only a classpath
> > problem, eg Grails does not load the correct hibernate annotations
> > jar?
> >
> > This second problem is annoying as I cannot use the Hibernate
> > annotations extensions to the EJB3 annotations. The first problem
> > prevents a nice integration within the Grails framework.
> >
> > It would really really be nice to be able to customize the Hibernate
> > mappings on POGOs: this would allow to do easily things that GORM does
> > not permit right now, while benefiting from Grails advantages.
> >
> > Should I open a JIRA feature request for this? Does Grails 0.6 imporve
> > the situation?
> >
> > Jean-Noël
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Re: Status of Hibernate annotations on a Groovy domain class (POGO)

graemer
You will still be able to use dynamic methods on domain classes in
src/groovy as to why some of the annotations aren't working i would
raise the question in the Groovy list as I have not played with
Groovy's annotation support yet

Cheers

On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:

> OK. So after playing a bit with 0.6-RC1 here is the situation for me,
> and a comparison with 0.5.6:
>
> 0.5.6:
>
> * Unable to have an annotated groovy class in grails-app/domain (would
> lead to an Hibernate duplicate error)
> * In src/groovy, an annotated class would work but not completely correct.
>
> 0.6:
>
> * This time I can have an annotated groovy class in grails-app/domain,
> however it seems to me all annotations just get ignored. Here is my
> source file:
>
> import javax.persistence.*
> import org.hibernate.annotations.*
>
> @Entity
> @Table(name="bert")
> class Section
> {
>         @Id
>         Long id
>
>         Long getId()
>         {
>                 return id
>         }
>
>     @Column(name="real_try")
>     String realName
>
>     @CollectionOfElements
>     @Column(name="favormig", nullable=false)
>         Set <String> questions = new HashSet <String> ()
>
>     public Set <String> getQuestions()
>     {
>         return questions;
>     }
> }
>
> @Table gets ignored (in db the name by convention is used), as well as
>  @Column(name="real_try") (the column name is real_name as per
> convention). Finally @CollectionOfElements don't work at all (no other
> tables is created).
>
> In /src/groovy, things work almost perfectly. The following source
> file gets properly mapped:
>
> import javax.persistence.*
> import org.hibernate.annotations.*
>
> @Entity
> @Table(name="bubu")
> class OtherSection
> {
>         @Id
>         Long id
>
>         Long getId()
>         {
>                 return id
>         }
>
>     @Column(name="real_blabla")
>     String realName
>
>  @CollectionOfElements
> //      @JoinTable
> //      (
> //              table=@Table(name="gaga"),
> //              joinColumns = @JoinColumn(name="BoyId")
> //      )
>    @Column(name="favoritepoupon", nullable=false)
>         Set <String> questions = new HashSet <String> ()
>
>     public Set <String> getQuestions()
>     {
>         return questions;
>     }
> }
>
> The correct table 'bubu" gets created, and another table
> bubu_questions get created too, so the @CollectionOfElements is
> working. However, if I remove the comments around @JoinTable I get a
> Groovy error and the server won't start:
>
> Compilation error:
> org.codehaus.groovy.control.MultipleCompilationErrorsException:
> startup failed,
> /home/elvanor/development/shoopz/shop-engine/src/groovy/OtherSection.groovy:
> 19: unexpected token: @ @ line 19, column 2.
>
> The last thing may be a Groovy thing. However, the fact that
> annotations don't work at all in the domain classes in a Grails thing
> and is problematic. Can you confirm this is "normal", Graeme? Could
> that feature be implemented? Shall I raise a JIRA?
>
> Currently my only viable option to use annotations would be to move
> files to src/groovy. How can I then use dynamics methods on these
> classes?
>
> Jean-Noël
>
>
>
> On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
> > Forget about question 2): it was just a stupid mistake on my part.
> > I've now managed to import that package correctly.
> >
> > On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
> > > Hello,
> > >
> > > I am writing this to know the status of Hibernate annotations support
> > > in Grails currently, for Groovy domain classes. I am using Grails
> > > 0.5.6 - maybe things have improved in 0.6 so please tell me.
> > >
> > > Currently the only information I've found on the subject was a
> > > previous thread in the mailing list. Hibernate annotations can somehow
> > > be used in Groovy domain classes, but I encountered the following
> > > problems:
> > >
> > > * First, I had to move the file Section.groovy out of
> > > grails-app/domain to /src/groovy, else I would have errors (duplicate
> > > stuff: same errors as the previous person wrote on the thread I
> > > mention). This probably means that my class is no longer considered a
> > > domain, so I lose all the dynamics methods associated with it, right?
> > >
> > > * Second, I could not use annotations from org.hibernate.annotations
> > > import org.hibernate.annotations would produce errors when launching
> > > grails run-app (class not found). Maybe this is only a classpath
> > > problem, eg Grails does not load the correct hibernate annotations
> > > jar?
> > >
> > > This second problem is annoying as I cannot use the Hibernate
> > > annotations extensions to the EJB3 annotations. The first problem
> > > prevents a nice integration within the Grails framework.
> > >
> > > It would really really be nice to be able to customize the Hibernate
> > > mappings on POGOs: this would allow to do easily things that GORM does
> > > not permit right now, while benefiting from Grails advantages.
> > >
> > > Should I open a JIRA feature request for this? Does Grails 0.6 imporve
> > > the situation?
> > >
> > > Jean-Noël
> > >
> >
>


--
Graeme Rocher
Grails Project Lead
http://grails.org

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Re: Status of Hibernate annotations on a Groovy domain class (POGO)

elvanor
So, what are the limitations of putting my domain class in src/groovy
rather than grails-app/domain ? What do I lose?

Do you have an idea as to why no annotation is working at all when the
class is in grails-app/domain?

Jean-Noël

PS: I will post the question to the groovy list regarding missing
annotation support.

On 8/22/07, Graeme Rocher <[hidden email]> wrote:

> You will still be able to use dynamic methods on domain classes in
> src/groovy as to why some of the annotations aren't working i would
> raise the question in the Groovy list as I have not played with
> Groovy's annotation support yet
>
> Cheers
>
> On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
> > OK. So after playing a bit with 0.6-RC1 here is the situation for me,
> > and a comparison with 0.5.6:
> >
> > 0.5.6:
> >
> > * Unable to have an annotated groovy class in grails-app/domain (would
> > lead to an Hibernate duplicate error)
> > * In src/groovy, an annotated class would work but not completely correct.
> >
> > 0.6:
> >
> > * This time I can have an annotated groovy class in grails-app/domain,
> > however it seems to me all annotations just get ignored. Here is my
> > source file:
> >
> > import javax.persistence.*
> > import org.hibernate.annotations.*
> >
> > @Entity
> > @Table(name="bert")
> > class Section
> > {
> >         @Id
> >         Long id
> >
> >         Long getId()
> >         {
> >                 return id
> >         }
> >
> >     @Column(name="real_try")
> >     String realName
> >
> >     @CollectionOfElements
> >     @Column(name="favormig", nullable=false)
> >         Set <String> questions = new HashSet <String> ()
> >
> >     public Set <String> getQuestions()
> >     {
> >         return questions;
> >     }
> > }
> >
> > @Table gets ignored (in db the name by convention is used), as well as
> >  @Column(name="real_try") (the column name is real_name as per
> > convention). Finally @CollectionOfElements don't work at all (no other
> > tables is created).
> >
> > In /src/groovy, things work almost perfectly. The following source
> > file gets properly mapped:
> >
> > import javax.persistence.*
> > import org.hibernate.annotations.*
> >
> > @Entity
> > @Table(name="bubu")
> > class OtherSection
> > {
> >         @Id
> >         Long id
> >
> >         Long getId()
> >         {
> >                 return id
> >         }
> >
> >     @Column(name="real_blabla")
> >     String realName
> >
> >  @CollectionOfElements
> > //      @JoinTable
> > //      (
> > //              table=@Table(name="gaga"),
> > //              joinColumns = @JoinColumn(name="BoyId")
> > //      )
> >    @Column(name="favoritepoupon", nullable=false)
> >         Set <String> questions = new HashSet <String> ()
> >
> >     public Set <String> getQuestions()
> >     {
> >         return questions;
> >     }
> > }
> >
> > The correct table 'bubu" gets created, and another table
> > bubu_questions get created too, so the @CollectionOfElements is
> > working. However, if I remove the comments around @JoinTable I get a
> > Groovy error and the server won't start:
> >
> > Compilation error:
> > org.codehaus.groovy.control.MultipleCompilationErrorsException:
> > startup failed,
> > /home/elvanor/development/shoopz/shop-engine/src/groovy/OtherSection.groovy:
> > 19: unexpected token: @ @ line 19, column 2.
> >
> > The last thing may be a Groovy thing. However, the fact that
> > annotations don't work at all in the domain classes in a Grails thing
> > and is problematic. Can you confirm this is "normal", Graeme? Could
> > that feature be implemented? Shall I raise a JIRA?
> >
> > Currently my only viable option to use annotations would be to move
> > files to src/groovy. How can I then use dynamics methods on these
> > classes?
> >
> > Jean-Noël
> >
> >
> >
> > On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
> > > Forget about question 2): it was just a stupid mistake on my part.
> > > I've now managed to import that package correctly.
> > >
> > > On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
> > > > Hello,
> > > >
> > > > I am writing this to know the status of Hibernate annotations support
> > > > in Grails currently, for Groovy domain classes. I am using Grails
> > > > 0.5.6 - maybe things have improved in 0.6 so please tell me.
> > > >
> > > > Currently the only information I've found on the subject was a
> > > > previous thread in the mailing list. Hibernate annotations can somehow
> > > > be used in Groovy domain classes, but I encountered the following
> > > > problems:
> > > >
> > > > * First, I had to move the file Section.groovy out of
> > > > grails-app/domain to /src/groovy, else I would have errors (duplicate
> > > > stuff: same errors as the previous person wrote on the thread I
> > > > mention). This probably means that my class is no longer considered a
> > > > domain, so I lose all the dynamics methods associated with it, right?
> > > >
> > > > * Second, I could not use annotations from org.hibernate.annotations
> > > > import org.hibernate.annotations would produce errors when launching
> > > > grails run-app (class not found). Maybe this is only a classpath
> > > > problem, eg Grails does not load the correct hibernate annotations
> > > > jar?
> > > >
> > > > This second problem is annoying as I cannot use the Hibernate
> > > > annotations extensions to the EJB3 annotations. The first problem
> > > > prevents a nice integration within the Grails framework.
> > > >
> > > > It would really really be nice to be able to customize the Hibernate
> > > > mappings on POGOs: this would allow to do easily things that GORM does
> > > > not permit right now, while benefiting from Grails advantages.
> > > >
> > > > Should I open a JIRA feature request for this? Does Grails 0.6 imporve
> > > > the situation?
> > > >
> > > > Jean-Noël
> > > >
> > >
> >
>
>
> --
> Graeme Rocher
> Grails Project Lead
> http://grails.org
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Re: Status of Hibernate annotations on a Groovy domain class (POGO)

graemer
On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
> So, what are the limitations of putting my domain class in src/groovy
> rather than grails-app/domain ? What do I lose?

I have no idea, they are all compiled with the same compiler

Cheers

>
> Do you have an idea as to why no annotation is working at all when the
> class is in grails-app/domain?
>
> Jean-Noël
>
> PS: I will post the question to the groovy list regarding missing
> annotation support.
>
> On 8/22/07, Graeme Rocher <[hidden email]> wrote:
> > You will still be able to use dynamic methods on domain classes in
> > src/groovy as to why some of the annotations aren't working i would
> > raise the question in the Groovy list as I have not played with
> > Groovy's annotation support yet
> >
> > Cheers
> >
> > On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
> > > OK. So after playing a bit with 0.6-RC1 here is the situation for me,
> > > and a comparison with 0.5.6:
> > >
> > > 0.5.6:
> > >
> > > * Unable to have an annotated groovy class in grails-app/domain (would
> > > lead to an Hibernate duplicate error)
> > > * In src/groovy, an annotated class would work but not completely correct.
> > >
> > > 0.6:
> > >
> > > * This time I can have an annotated groovy class in grails-app/domain,
> > > however it seems to me all annotations just get ignored. Here is my
> > > source file:
> > >
> > > import javax.persistence.*
> > > import org.hibernate.annotations.*
> > >
> > > @Entity
> > > @Table(name="bert")
> > > class Section
> > > {
> > >         @Id
> > >         Long id
> > >
> > >         Long getId()
> > >         {
> > >                 return id
> > >         }
> > >
> > >     @Column(name="real_try")
> > >     String realName
> > >
> > >     @CollectionOfElements
> > >     @Column(name="favormig", nullable=false)
> > >         Set <String> questions = new HashSet <String> ()
> > >
> > >     public Set <String> getQuestions()
> > >     {
> > >         return questions;
> > >     }
> > > }
> > >
> > > @Table gets ignored (in db the name by convention is used), as well as
> > >  @Column(name="real_try") (the column name is real_name as per
> > > convention). Finally @CollectionOfElements don't work at all (no other
> > > tables is created).
> > >
> > > In /src/groovy, things work almost perfectly. The following source
> > > file gets properly mapped:
> > >
> > > import javax.persistence.*
> > > import org.hibernate.annotations.*
> > >
> > > @Entity
> > > @Table(name="bubu")
> > > class OtherSection
> > > {
> > >         @Id
> > >         Long id
> > >
> > >         Long getId()
> > >         {
> > >                 return id
> > >         }
> > >
> > >     @Column(name="real_blabla")
> > >     String realName
> > >
> > >  @CollectionOfElements
> > > //      @JoinTable
> > > //      (
> > > //              table=@Table(name="gaga"),
> > > //              joinColumns = @JoinColumn(name="BoyId")
> > > //      )
> > >    @Column(name="favoritepoupon", nullable=false)
> > >         Set <String> questions = new HashSet <String> ()
> > >
> > >     public Set <String> getQuestions()
> > >     {
> > >         return questions;
> > >     }
> > > }
> > >
> > > The correct table 'bubu" gets created, and another table
> > > bubu_questions get created too, so the @CollectionOfElements is
> > > working. However, if I remove the comments around @JoinTable I get a
> > > Groovy error and the server won't start:
> > >
> > > Compilation error:
> > > org.codehaus.groovy.control.MultipleCompilationErrorsException:
> > > startup failed,
> > > /home/elvanor/development/shoopz/shop-engine/src/groovy/OtherSection.groovy:
> > > 19: unexpected token: @ @ line 19, column 2.
> > >
> > > The last thing may be a Groovy thing. However, the fact that
> > > annotations don't work at all in the domain classes in a Grails thing
> > > and is problematic. Can you confirm this is "normal", Graeme? Could
> > > that feature be implemented? Shall I raise a JIRA?
> > >
> > > Currently my only viable option to use annotations would be to move
> > > files to src/groovy. How can I then use dynamics methods on these
> > > classes?
> > >
> > > Jean-Noël
> > >
> > >
> > >
> > > On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
> > > > Forget about question 2): it was just a stupid mistake on my part.
> > > > I've now managed to import that package correctly.
> > > >
> > > > On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
> > > > > Hello,
> > > > >
> > > > > I am writing this to know the status of Hibernate annotations support
> > > > > in Grails currently, for Groovy domain classes. I am using Grails
> > > > > 0.5.6 - maybe things have improved in 0.6 so please tell me.
> > > > >
> > > > > Currently the only information I've found on the subject was a
> > > > > previous thread in the mailing list. Hibernate annotations can somehow
> > > > > be used in Groovy domain classes, but I encountered the following
> > > > > problems:
> > > > >
> > > > > * First, I had to move the file Section.groovy out of
> > > > > grails-app/domain to /src/groovy, else I would have errors (duplicate
> > > > > stuff: same errors as the previous person wrote on the thread I
> > > > > mention). This probably means that my class is no longer considered a
> > > > > domain, so I lose all the dynamics methods associated with it, right?
> > > > >
> > > > > * Second, I could not use annotations from org.hibernate.annotations
> > > > > import org.hibernate.annotations would produce errors when launching
> > > > > grails run-app (class not found). Maybe this is only a classpath
> > > > > problem, eg Grails does not load the correct hibernate annotations
> > > > > jar?
> > > > >
> > > > > This second problem is annoying as I cannot use the Hibernate
> > > > > annotations extensions to the EJB3 annotations. The first problem
> > > > > prevents a nice integration within the Grails framework.
> > > > >
> > > > > It would really really be nice to be able to customize the Hibernate
> > > > > mappings on POGOs: this would allow to do easily things that GORM does
> > > > > not permit right now, while benefiting from Grails advantages.
> > > > >
> > > > > Should I open a JIRA feature request for this? Does Grails 0.6 imporve
> > > > > the situation?
> > > > >
> > > > > Jean-Noël
> > > > >
> > > >
> > >
> >
> >
> > --
> > Graeme Rocher
> > Grails Project Lead
> > http://grails.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
>


--
Graeme Rocher
Grails Project Lead
http://grails.org

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Re: Status of Hibernate annotations on a Groovy domain class (POGO)

Marc Palmer Local


> On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
>> So, what are the limitations of putting my domain class in src/groovy
>> rather than grails-app/domain ? What do I lose?
>

I would say don't do it. I am thinking that in future we should  
change the classloading mechanism to treat only those classes in  
grails-app/domain/ as domain classes etc. This makes a fair bit of  
sense to me and may provide us with some performance gains in future  
- for example startup and reload times might be cut by knowing that a  
certain resource path has only a certain kind (or set of kinds) of  
artefact below it.

Currently we have conflicting mechanisms. At startup grails will scan  
all the resources to analyse their artefact conventions, but plugins  
can only watch for changes (for reloading) based on the path of a  
resource, i.e:

def watchedResources = ["file:./grails-app/controllers/**/
*Controller.groovy",
        "file:./plugins/*/grails-app/controllers/**/*Controller.groovy",
        "file:./plugins/*/grails-app/taglib/**/*TagLib.groovy",
         "file:./grails-app/taglib/**/*TagLib.groovy"]

The above is from the controllers plugin. So you see it will only  
find changes based on location, and yet at startup a controller can  
be "anywhere". This'll be a post 1.0 refinement I think, one way or  
the other.

The shorter answer is, it may work now, but don't bank on it in the  
future :)

Marc


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Re: Status of Hibernate annotations on a Groovy domain class (POGO)

elvanor
I totally agree with you - if it's meant to be a Grails artefact, here
a domain class, it should be in grails-app/domain, not src/groovy. But
the problem here is that I am kind of stuck until I can understand why
Hibernate annotations *don't* work in grails-app and work in src...

If anybody can finds the reason, I'd appreciate the help. Meanwhile I
am still looking

On 8/22/07, Marc Palmer <[hidden email]> wrote:

>
>
> > On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
> >> So, what are the limitations of putting my domain class in src/groovy
> >> rather than grails-app/domain ? What do I lose?
> >
>
> I would say don't do it. I am thinking that in future we should
> change the classloading mechanism to treat only those classes in
> grails-app/domain/ as domain classes etc. This makes a fair bit of
> sense to me and may provide us with some performance gains in future
> - for example startup and reload times might be cut by knowing that a
> certain resource path has only a certain kind (or set of kinds) of
> artefact below it.
>
> Currently we have conflicting mechanisms. At startup grails will scan
> all the resources to analyse their artefact conventions, but plugins
> can only watch for changes (for reloading) based on the path of a
> resource, i.e:
>
> def watchedResources = ["file:./grails-app/controllers/**/
> *Controller.groovy",
>         "file:./plugins/*/grails-app/controllers/**/*Controller.groovy",
>         "file:./plugins/*/grails-app/taglib/**/*TagLib.groovy",
>          "file:./grails-app/taglib/**/*TagLib.groovy"]
>
> The above is from the controllers plugin. So you see it will only
> find changes based on location, and yet at startup a controller can
> be "anywhere". This'll be a post 1.0 refinement I think, one way or
> the other.
>
> The shorter answer is, it may work now, but don't bank on it in the
> future :)
>
> Marc
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Status of Hibernate annotations on a Groovy domain class (POGO)

mano-2
In reply to this post by graemer
The other solution is that you could write the domain classes in java. You can add hibernate annotations and also have all the dynamic methods available.

- Manohar

graemer wrote
I recommend you try 0.6, if you wait a little while I'll have an RC
for you to download

Cheers

On 8/22/07, Jean-Noël Rivasseau <elvanor@gmail.com> wrote:
> Hello,
>
> I am writing this to know the status of Hibernate annotations support
> in Grails currently, for Groovy domain classes. I am using Grails
> 0.5.6 - maybe things have improved in 0.6 so please tell me.
>
> Currently the only information I've found on the subject was a
> previous thread in the mailing list. Hibernate annotations can somehow
> be used in Groovy domain classes, but I encountered the following
> problems:
>
> * First, I had to move the file Section.groovy out of
> grails-app/domain to /src/groovy, else I would have errors (duplicate
> stuff: same errors as the previous person wrote on the thread I
> mention). This probably means that my class is no longer considered a
> domain, so I lose all the dynamics methods associated with it, right?
>
> * Second, I could not use annotations from org.hibernate.annotations
> import org.hibernate.annotations would produce errors when launching
> grails run-app (class not found). Maybe this is only a classpath
> problem, eg Grails does not load the correct hibernate annotations
> jar?
>
> This second problem is annoying as I cannot use the Hibernate
> annotations extensions to the EJB3 annotations. The first problem
> prevents a nice integration within the Grails framework.
>
> It would really really be nice to be able to customize the Hibernate
> mappings on POGOs: this would allow to do easily things that GORM does
> not permit right now, while benefiting from Grails advantages.
>
> Should I open a JIRA feature request for this? Does Grails 0.6 imporve
> the situation?
>
> Jean-Noël
>


--
Graeme Rocher
Grails Project Lead
http://grails.org

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email
Reply | Threaded
Open this post in threaded view
|

Re: Status of Hibernate annotations on a Groovy domain class (POGO)

elvanor
Hello.

I don't plan currently to write the domain classes in Java - I make
use of lots of Groovy features.

After further investigation, it appears that the situation has not
changed a lot from 0.5.6. I realised that the Hibernate configuration
file web-app/WEB-INF/classes/hibernate.cfg.xml was not the one I
expected (it was not copied over from
grails-app/conf/hibernate/hibernate.cfg.xml !! Is that a bug ??). Thus
it did not contain the mapping for the domain class in grails-app.
Thus it was of course logical that these annotations did not have any
effect.

So after manually copying it and verifying that it had the mapping for
the domain class in grails-app/domain, it started outputting the same
error than under 0.5.6:

2007-08-22 17:24:34.074::WARN:  Nested in
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'transactionManager': Cannot resolve reference
to bean 'sessionFactory' while setting bean property 'sessionFactory';
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'sessionFactory': Invocation of init method
failed; nested exception is org.hibernate.DuplicateMappingException:
Duplicate class/entity mapping AnnotationElement:
org.hibernate.DuplicateMappingException: Duplicate class/entity
mapping AnnotationElement

AnnotationElement.groovy is my test class in grails-app/domain.

So, no changes from 0.5.6? Can someone look at this?

Jean-Noël


On 8/22/07, Mano <[hidden email]> wrote:

>
> The other solution is that you could write the domain classes in java. You
> can add hibernate annotations and also have all the dynamic methods
> available.
>
> - Manohar
>
>
> graemer wrote:
> >
> > I recommend you try 0.6, if you wait a little while I'll have an RC
> > for you to download
> >
> > Cheers
> >
> > On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
> >> Hello,
> >>
> >> I am writing this to know the status of Hibernate annotations support
> >> in Grails currently, for Groovy domain classes. I am using Grails
> >> 0.5.6 - maybe things have improved in 0.6 so please tell me.
> >>
> >> Currently the only information I've found on the subject was a
> >> previous thread in the mailing list. Hibernate annotations can somehow
> >> be used in Groovy domain classes, but I encountered the following
> >> problems:
> >>
> >> * First, I had to move the file Section.groovy out of
> >> grails-app/domain to /src/groovy, else I would have errors (duplicate
> >> stuff: same errors as the previous person wrote on the thread I
> >> mention). This probably means that my class is no longer considered a
> >> domain, so I lose all the dynamics methods associated with it, right?
> >>
> >> * Second, I could not use annotations from org.hibernate.annotations
> >> import org.hibernate.annotations would produce errors when launching
> >> grails run-app (class not found). Maybe this is only a classpath
> >> problem, eg Grails does not load the correct hibernate annotations
> >> jar?
> >>
> >> This second problem is annoying as I cannot use the Hibernate
> >> annotations extensions to the EJB3 annotations. The first problem
> >> prevents a nice integration within the Grails framework.
> >>
> >> It would really really be nice to be able to customize the Hibernate
> >> mappings on POGOs: this would allow to do easily things that GORM does
> >> not permit right now, while benefiting from Grails advantages.
> >>
> >> Should I open a JIRA feature request for this? Does Grails 0.6 imporve
> >> the situation?
> >>
> >> Jean-Noël
> >>
> >
> >
> > --
> > Graeme Rocher
> > Grails Project Lead
> > http://grails.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Status-of-Hibernate-annotations-on-a-Groovy-domain-class-%28POGO%29-tf4310486.html#a12277002
> Sent from the grails - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Status of Hibernate annotations on a Groovy domain class (POGO)

Todd Johnson-5
I've been in the same situation as you Jean-Noël.  I want to do
something gorm doesn't do correctly (many-to-many recursive
relationships).  I wanted to just annotate my domain class, but that
didn't work.  Correct me if I'm wrong, but the annotations are actually
part of the jpa spec. Earlier Graeme wrote:

>I've updated the Roadmap, we are scaling back our goals for 1.0 to
>make sure we deliver a stable release. The focust will be on
>stability, project infastructure and plug-in system refinements until
>1.0

>After 1.0 we'll deal with things like JPA, probably as a plugin

>Cheers

So I'm guessing jpa annotations fall into that category?



Jean-Noël Rivasseau wrote:

> Hello.
>
> I don't plan currently to write the domain classes in Java - I make
> use of lots of Groovy features.
>
> After further investigation, it appears that the situation has not
> changed a lot from 0.5.6. I realised that the Hibernate configuration
> file web-app/WEB-INF/classes/hibernate.cfg.xml was not the one I
> expected (it was not copied over from
> grails-app/conf/hibernate/hibernate.cfg.xml !! Is that a bug ??). Thus
> it did not contain the mapping for the domain class in grails-app.
> Thus it was of course logical that these annotations did not have any
> effect.
>
> So after manually copying it and verifying that it had the mapping for
> the domain class in grails-app/domain, it started outputting the same
> error than under 0.5.6:
>
> 2007-08-22 17:24:34.074::WARN:  Nested in
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'transactionManager': Cannot resolve reference
> to bean 'sessionFactory' while setting bean property 'sessionFactory';
> nested exception is
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'sessionFactory': Invocation of init method
> failed; nested exception is org.hibernate.DuplicateMappingException:
> Duplicate class/entity mapping AnnotationElement:
> org.hibernate.DuplicateMappingException: Duplicate class/entity
> mapping AnnotationElement
>
> AnnotationElement.groovy is my test class in grails-app/domain.
>
> So, no changes from 0.5.6? Can someone look at this?
>
> Jean-Noël
>
>
> On 8/22/07, Mano <[hidden email]> wrote:
>  
>> The other solution is that you could write the domain classes in java. You
>> can add hibernate annotations and also have all the dynamic methods
>> available.
>>
>> - Manohar
>>
>>
>> graemer wrote:
>>    
>>> I recommend you try 0.6, if you wait a little while I'll have an RC
>>> for you to download
>>>
>>> Cheers
>>>
>>> On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
>>>      
>>>> Hello,
>>>>
>>>> I am writing this to know the status of Hibernate annotations support
>>>> in Grails currently, for Groovy domain classes. I am using Grails
>>>> 0.5.6 - maybe things have improved in 0.6 so please tell me.
>>>>
>>>> Currently the only information I've found on the subject was a
>>>> previous thread in the mailing list. Hibernate annotations can somehow
>>>> be used in Groovy domain classes, but I encountered the following
>>>> problems:
>>>>
>>>> * First, I had to move the file Section.groovy out of
>>>> grails-app/domain to /src/groovy, else I would have errors (duplicate
>>>> stuff: same errors as the previous person wrote on the thread I
>>>> mention). This probably means that my class is no longer considered a
>>>> domain, so I lose all the dynamics methods associated with it, right?
>>>>
>>>> * Second, I could not use annotations from org.hibernate.annotations
>>>> import org.hibernate.annotations would produce errors when launching
>>>> grails run-app (class not found). Maybe this is only a classpath
>>>> problem, eg Grails does not load the correct hibernate annotations
>>>> jar?
>>>>
>>>> This second problem is annoying as I cannot use the Hibernate
>>>> annotations extensions to the EJB3 annotations. The first problem
>>>> prevents a nice integration within the Grails framework.
>>>>
>>>> It would really really be nice to be able to customize the Hibernate
>>>> mappings on POGOs: this would allow to do easily things that GORM does
>>>> not permit right now, while benefiting from Grails advantages.
>>>>
>>>> Should I open a JIRA feature request for this? Does Grails 0.6 imporve
>>>> the situation?
>>>>
>>>> Jean-Noël
>>>>
>>>>        
>>> --
>>> Graeme Rocher
>>> Grails Project Lead
>>> http://grails.org
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list please visit:
>>>
>>>     http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>>      
>> --
>> View this message in context: http://www.nabble.com/Status-of-Hibernate-annotations-on-a-Groovy-domain-class-%28POGO%29-tf4310486.html#a12277002
>> Sent from the grails - user mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>    


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Status of Hibernate annotations on a Groovy domain class (POGO)

graemer
On 8/22/07, Todd Johnson <[hidden email]> wrote:

> I've been in the same situation as you Jean-Noël.  I want to do
> something gorm doesn't do correctly (many-to-many recursive
> relationships).  I wanted to just annotate my domain class, but that
> didn't work.  Correct me if I'm wrong, but the annotations are actually
> part of the jpa spec. Earlier Graeme wrote:
>
> >I've updated the Roadmap, we are scaling back our goals for 1.0 to
> >make sure we deliver a stable release. The focust will be on
> >stability, project infastructure and plug-in system refinements until
> >1.0
>
> >After 1.0 we'll deal with things like JPA, probably as a plugin
>
> >Cheers
>
> So I'm guessing jpa annotations fall into that category?

No we can certainly support Hibernate annotations for 1.0. When I
refer to JPA support I am talking about adding dynamic methods that
use the EntityManager and allowing Grails to work with TopLink, Kodo
etc.

As for the currently problem, I don't see what the issue is with
putting the classses in src/groovy for them moment. All the dynamic
finders and methods will still work. In the meantime raise an issue
for the problem with classes in grails-app/domain and we can look at
it

Cheers

>
>
>
> Jean-Noël Rivasseau wrote:
> > Hello.
> >
> > I don't plan currently to write the domain classes in Java - I make
> > use of lots of Groovy features.
> >
> > After further investigation, it appears that the situation has not
> > changed a lot from 0.5.6. I realised that the Hibernate configuration
> > file web-app/WEB-INF/classes/hibernate.cfg.xml was not the one I
> > expected (it was not copied over from
> > grails-app/conf/hibernate/hibernate.cfg.xml !! Is that a bug ??). Thus
> > it did not contain the mapping for the domain class in grails-app.
> > Thus it was of course logical that these annotations did not have any
> > effect.
> >
> > So after manually copying it and verifying that it had the mapping for
> > the domain class in grails-app/domain, it started outputting the same
> > error than under 0.5.6:
> >
> > 2007-08-22 17:24:34.074::WARN:  Nested in
> > org.springframework.beans.factory.BeanCreationException: Error
> > creating bean with name 'transactionManager': Cannot resolve reference
> > to bean 'sessionFactory' while setting bean property 'sessionFactory';
> > nested exception is
> > org.springframework.beans.factory.BeanCreationException: Error
> > creating bean with name 'sessionFactory': Invocation of init method
> > failed; nested exception is org.hibernate.DuplicateMappingException:
> > Duplicate class/entity mapping AnnotationElement:
> > org.hibernate.DuplicateMappingException: Duplicate class/entity
> > mapping AnnotationElement
> >
> > AnnotationElement.groovy is my test class in grails-app/domain.
> >
> > So, no changes from 0.5.6? Can someone look at this?
> >
> > Jean-Noël
> >
> >
> > On 8/22/07, Mano <[hidden email]> wrote:
> >
> >> The other solution is that you could write the domain classes in java. You
> >> can add hibernate annotations and also have all the dynamic methods
> >> available.
> >>
> >> - Manohar
> >>
> >>
> >> graemer wrote:
> >>
> >>> I recommend you try 0.6, if you wait a little while I'll have an RC
> >>> for you to download
> >>>
> >>> Cheers
> >>>
> >>> On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
> >>>
> >>>> Hello,
> >>>>
> >>>> I am writing this to know the status of Hibernate annotations support
> >>>> in Grails currently, for Groovy domain classes. I am using Grails
> >>>> 0.5.6 - maybe things have improved in 0.6 so please tell me.
> >>>>
> >>>> Currently the only information I've found on the subject was a
> >>>> previous thread in the mailing list. Hibernate annotations can somehow
> >>>> be used in Groovy domain classes, but I encountered the following
> >>>> problems:
> >>>>
> >>>> * First, I had to move the file Section.groovy out of
> >>>> grails-app/domain to /src/groovy, else I would have errors (duplicate
> >>>> stuff: same errors as the previous person wrote on the thread I
> >>>> mention). This probably means that my class is no longer considered a
> >>>> domain, so I lose all the dynamics methods associated with it, right?
> >>>>
> >>>> * Second, I could not use annotations from org.hibernate.annotations
> >>>> import org.hibernate.annotations would produce errors when launching
> >>>> grails run-app (class not found). Maybe this is only a classpath
> >>>> problem, eg Grails does not load the correct hibernate annotations
> >>>> jar?
> >>>>
> >>>> This second problem is annoying as I cannot use the Hibernate
> >>>> annotations extensions to the EJB3 annotations. The first problem
> >>>> prevents a nice integration within the Grails framework.
> >>>>
> >>>> It would really really be nice to be able to customize the Hibernate
> >>>> mappings on POGOs: this would allow to do easily things that GORM does
> >>>> not permit right now, while benefiting from Grails advantages.
> >>>>
> >>>> Should I open a JIRA feature request for this? Does Grails 0.6 imporve
> >>>> the situation?
> >>>>
> >>>> Jean-Noël
> >>>>
> >>>>
> >>> --
> >>> Graeme Rocher
> >>> Grails Project Lead
> >>> http://grails.org
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe from this list please visit:
> >>>
> >>>     http://xircles.codehaus.org/manage_email
> >>>
> >>>
> >>>
> >>>
> >> --
> >> View this message in context: http://www.nabble.com/Status-of-Hibernate-annotations-on-a-Groovy-domain-class-%28POGO%29-tf4310486.html#a12277002
> >> Sent from the grails - user mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe from this list please visit:
> >>
> >>     http://xircles.codehaus.org/manage_email
> >>
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Graeme Rocher
Grails Project Lead
http://grails.org

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Status of Hibernate annotations on a Groovy domain class (POGO)

Todd Johnson-5
Before I open an issue, let me verify I took the correct steps.

Annotated my domain class:
import javax.persistence.*
@Entity
class User {
        @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
        Long id
        @Column(name="uname")
        String username
}

added to the dataSource section in grails-app/conf/DataSource.groovy:
configClass =
org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration.class

created grails-app/conf/hibernate/hibernate.cfg.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
  PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory><mapping class="User" /></session-factory>
</hibernate-configuration>

when i startup I get an org.hibernate.DuplicateMappingException:
Duplicate class/entity mapping User

If those steps should have worked, let me know and I'll raise an issue,
else, let me know where my blunder was.

Thanks for all your input on this,
Todd

P.S. Are you going to release a second edition of your book when 1.0
comes out?

Graeme Rocher wrote:

> On 8/22/07, Todd Johnson <[hidden email]> wrote:
>  
>> I've been in the same situation as you Jean-Noël.  I want to do
>> something gorm doesn't do correctly (many-to-many recursive
>> relationships).  I wanted to just annotate my domain class, but that
>> didn't work.  Correct me if I'm wrong, but the annotations are actually
>> part of the jpa spec. Earlier Graeme wrote:
>>
>>    
>>> I've updated the Roadmap, we are scaling back our goals for 1.0 to
>>> make sure we deliver a stable release. The focust will be on
>>> stability, project infastructure and plug-in system refinements until
>>> 1.0
>>>      
>>> After 1.0 we'll deal with things like JPA, probably as a plugin
>>>      
>>> Cheers
>>>      
>> So I'm guessing jpa annotations fall into that category?
>>    
>
> No we can certainly support Hibernate annotations for 1.0. When I
> refer to JPA support I am talking about adding dynamic methods that
> use the EntityManager and allowing Grails to work with TopLink, Kodo
> etc.
>
> As for the currently problem, I don't see what the issue is with
> putting the classses in src/groovy for them moment. All the dynamic
> finders and methods will still work. In the meantime raise an issue
> for the problem with classes in grails-app/domain and we can look at
> it
>
> Cheers
>
>  
>>
>> Jean-Noël Rivasseau wrote:
>>    
>>> Hello.
>>>
>>> I don't plan currently to write the domain classes in Java - I make
>>> use of lots of Groovy features.
>>>
>>> After further investigation, it appears that the situation has not
>>> changed a lot from 0.5.6. I realised that the Hibernate configuration
>>> file web-app/WEB-INF/classes/hibernate.cfg.xml was not the one I
>>> expected (it was not copied over from
>>> grails-app/conf/hibernate/hibernate.cfg.xml !! Is that a bug ??). Thus
>>> it did not contain the mapping for the domain class in grails-app.
>>> Thus it was of course logical that these annotations did not have any
>>> effect.
>>>
>>> So after manually copying it and verifying that it had the mapping for
>>> the domain class in grails-app/domain, it started outputting the same
>>> error than under 0.5.6:
>>>
>>> 2007-08-22 17:24:34.074::WARN:  Nested in
>>> org.springframework.beans.factory.BeanCreationException: Error
>>> creating bean with name 'transactionManager': Cannot resolve reference
>>> to bean 'sessionFactory' while setting bean property 'sessionFactory';
>>> nested exception is
>>> org.springframework.beans.factory.BeanCreationException: Error
>>> creating bean with name 'sessionFactory': Invocation of init method
>>> failed; nested exception is org.hibernate.DuplicateMappingException:
>>> Duplicate class/entity mapping AnnotationElement:
>>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>>> mapping AnnotationElement
>>>
>>> AnnotationElement.groovy is my test class in grails-app/domain.
>>>
>>> So, no changes from 0.5.6? Can someone look at this?
>>>
>>> Jean-Noël
>>>
>>>
>>> On 8/22/07, Mano <[hidden email]> wrote:
>>>
>>>      
>>>> The other solution is that you could write the domain classes in java. You
>>>> can add hibernate annotations and also have all the dynamic methods
>>>> available.
>>>>
>>>> - Manohar
>>>>
>>>>
>>>> graemer wrote:
>>>>
>>>>        
>>>>> I recommend you try 0.6, if you wait a little while I'll have an RC
>>>>> for you to download
>>>>>
>>>>> Cheers
>>>>>
>>>>> On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
>>>>>
>>>>>          
>>>>>> Hello,
>>>>>>
>>>>>> I am writing this to know the status of Hibernate annotations support
>>>>>> in Grails currently, for Groovy domain classes. I am using Grails
>>>>>> 0.5.6 - maybe things have improved in 0.6 so please tell me.
>>>>>>
>>>>>> Currently the only information I've found on the subject was a
>>>>>> previous thread in the mailing list. Hibernate annotations can somehow
>>>>>> be used in Groovy domain classes, but I encountered the following
>>>>>> problems:
>>>>>>
>>>>>> * First, I had to move the file Section.groovy out of
>>>>>> grails-app/domain to /src/groovy, else I would have errors (duplicate
>>>>>> stuff: same errors as the previous person wrote on the thread I
>>>>>> mention). This probably means that my class is no longer considered a
>>>>>> domain, so I lose all the dynamics methods associated with it, right?
>>>>>>
>>>>>> * Second, I could not use annotations from org.hibernate.annotations
>>>>>> import org.hibernate.annotations would produce errors when launching
>>>>>> grails run-app (class not found). Maybe this is only a classpath
>>>>>> problem, eg Grails does not load the correct hibernate annotations
>>>>>> jar?
>>>>>>
>>>>>> This second problem is annoying as I cannot use the Hibernate
>>>>>> annotations extensions to the EJB3 annotations. The first problem
>>>>>> prevents a nice integration within the Grails framework.
>>>>>>
>>>>>> It would really really be nice to be able to customize the Hibernate
>>>>>> mappings on POGOs: this would allow to do easily things that GORM does
>>>>>> not permit right now, while benefiting from Grails advantages.
>>>>>>
>>>>>> Should I open a JIRA feature request for this? Does Grails 0.6 imporve
>>>>>> the situation?
>>>>>>
>>>>>> Jean-Noël
>>>>>>
>>>>>>
>>>>>>            
>>>>> --
>>>>> Graeme Rocher
>>>>> Grails Project Lead
>>>>> http://grails.org
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe from this list please visit:
>>>>>
>>>>>     http://xircles.codehaus.org/manage_email
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>          
>>>> --
>>>> View this message in context: http://www.nabble.com/Status-of-Hibernate-annotations-on-a-Groovy-domain-class-%28POGO%29-tf4310486.html#a12277002
>>>> Sent from the grails - user mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list please visit:
>>>>
>>>>     http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>>        
>> ---------------------------------------------------------------------
>> To unsubscribe from this list please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>    
>
>
>  


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Status of Hibernate annotations on a Groovy domain class (POGO)

elvanor
I would say those steps are correct - I have almost exactly the same
setups and get this error. I'll let you enter the JIRA issue then ;)

This is probably not a big deal to fix, clearly Grails tries to use
two Hibernate mappings for the class (one generated by Grails, the
other by the associations), thus the problem.

Would be nice if it could be included in 0.6-final.

Jean-Noel

ps: with some help from Guillaume I was also able to fix my Groovy
annotation problem.

On 8/22/07, Todd Johnson <[hidden email]> wrote:

> Before I open an issue, let me verify I took the correct steps.
>
> Annotated my domain class:
> import javax.persistence.*
> @Entity
> class User {
>         @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
>         Long id
>         @Column(name="uname")
>         String username
> }
>
> added to the dataSource section in grails-app/conf/DataSource.groovy:
> configClass =
> org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration.class
>
> created grails-app/conf/hibernate/hibernate.cfg.xml:
> <?xml version='1.0' encoding='utf-8'?>
> <!DOCTYPE hibernate-configuration
>   PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
>   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
> <hibernate-configuration>
>     <session-factory><mapping class="User" /></session-factory>
> </hibernate-configuration>
>
> when i startup I get an org.hibernate.DuplicateMappingException:
> Duplicate class/entity mapping User
>
> If those steps should have worked, let me know and I'll raise an issue,
> else, let me know where my blunder was.
>
> Thanks for all your input on this,
> Todd
>
> P.S. Are you going to release a second edition of your book when 1.0
> comes out?
>
> Graeme Rocher wrote:
> > On 8/22/07, Todd Johnson <[hidden email]> wrote:
> >
> >> I've been in the same situation as you Jean-Noël.  I want to do
> >> something gorm doesn't do correctly (many-to-many recursive
> >> relationships).  I wanted to just annotate my domain class, but that
> >> didn't work.  Correct me if I'm wrong, but the annotations are actually
> >> part of the jpa spec. Earlier Graeme wrote:
> >>
> >>
> >>> I've updated the Roadmap, we are scaling back our goals for 1.0 to
> >>> make sure we deliver a stable release. The focust will be on
> >>> stability, project infastructure and plug-in system refinements until
> >>> 1.0
> >>>
> >>> After 1.0 we'll deal with things like JPA, probably as a plugin
> >>>
> >>> Cheers
> >>>
> >> So I'm guessing jpa annotations fall into that category?
> >>
> >
> > No we can certainly support Hibernate annotations for 1.0. When I
> > refer to JPA support I am talking about adding dynamic methods that
> > use the EntityManager and allowing Grails to work with TopLink, Kodo
> > etc.
> >
> > As for the currently problem, I don't see what the issue is with
> > putting the classses in src/groovy for them moment. All the dynamic
> > finders and methods will still work. In the meantime raise an issue
> > for the problem with classes in grails-app/domain and we can look at
> > it
> >
> > Cheers
> >
> >
> >>
> >> Jean-Noël Rivasseau wrote:
> >>
> >>> Hello.
> >>>
> >>> I don't plan currently to write the domain classes in Java - I make
> >>> use of lots of Groovy features.
> >>>
> >>> After further investigation, it appears that the situation has not
> >>> changed a lot from 0.5.6. I realised that the Hibernate configuration
> >>> file web-app/WEB-INF/classes/hibernate.cfg.xml was not the one I
> >>> expected (it was not copied over from
> >>> grails-app/conf/hibernate/hibernate.cfg.xml !! Is that a bug ??). Thus
> >>> it did not contain the mapping for the domain class in grails-app.
> >>> Thus it was of course logical that these annotations did not have any
> >>> effect.
> >>>
> >>> So after manually copying it and verifying that it had the mapping for
> >>> the domain class in grails-app/domain, it started outputting the same
> >>> error than under 0.5.6:
> >>>
> >>> 2007-08-22 17:24:34.074::WARN:  Nested in
> >>> org.springframework.beans.factory.BeanCreationException: Error
> >>> creating bean with name 'transactionManager': Cannot resolve reference
> >>> to bean 'sessionFactory' while setting bean property 'sessionFactory';
> >>> nested exception is
> >>> org.springframework.beans.factory.BeanCreationException: Error
> >>> creating bean with name 'sessionFactory': Invocation of init method
> >>> failed; nested exception is org.hibernate.DuplicateMappingException:
> >>> Duplicate class/entity mapping AnnotationElement:
> >>> org.hibernate.DuplicateMappingException: Duplicate class/entity
> >>> mapping AnnotationElement
> >>>
> >>> AnnotationElement.groovy is my test class in grails-app/domain.
> >>>
> >>> So, no changes from 0.5.6? Can someone look at this?
> >>>
> >>> Jean-Noël
> >>>
> >>>
> >>> On 8/22/07, Mano <[hidden email]> wrote:
> >>>
> >>>
> >>>> The other solution is that you could write the domain classes in java. You
> >>>> can add hibernate annotations and also have all the dynamic methods
> >>>> available.
> >>>>
> >>>> - Manohar
> >>>>
> >>>>
> >>>> graemer wrote:
> >>>>
> >>>>
> >>>>> I recommend you try 0.6, if you wait a little while I'll have an RC
> >>>>> for you to download
> >>>>>
> >>>>> Cheers
> >>>>>
> >>>>> On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
> >>>>>
> >>>>>
> >>>>>> Hello,
> >>>>>>
> >>>>>> I am writing this to know the status of Hibernate annotations support
> >>>>>> in Grails currently, for Groovy domain classes. I am using Grails
> >>>>>> 0.5.6 - maybe things have improved in 0.6 so please tell me.
> >>>>>>
> >>>>>> Currently the only information I've found on the subject was a
> >>>>>> previous thread in the mailing list. Hibernate annotations can somehow
> >>>>>> be used in Groovy domain classes, but I encountered the following
> >>>>>> problems:
> >>>>>>
> >>>>>> * First, I had to move the file Section.groovy out of
> >>>>>> grails-app/domain to /src/groovy, else I would have errors (duplicate
> >>>>>> stuff: same errors as the previous person wrote on the thread I
> >>>>>> mention). This probably means that my class is no longer considered a
> >>>>>> domain, so I lose all the dynamics methods associated with it, right?
> >>>>>>
> >>>>>> * Second, I could not use annotations from org.hibernate.annotations
> >>>>>> import org.hibernate.annotations would produce errors when launching
> >>>>>> grails run-app (class not found). Maybe this is only a classpath
> >>>>>> problem, eg Grails does not load the correct hibernate annotations
> >>>>>> jar?
> >>>>>>
> >>>>>> This second problem is annoying as I cannot use the Hibernate
> >>>>>> annotations extensions to the EJB3 annotations. The first problem
> >>>>>> prevents a nice integration within the Grails framework.
> >>>>>>
> >>>>>> It would really really be nice to be able to customize the Hibernate
> >>>>>> mappings on POGOs: this would allow to do easily things that GORM does
> >>>>>> not permit right now, while benefiting from Grails advantages.
> >>>>>>
> >>>>>> Should I open a JIRA feature request for this? Does Grails 0.6 imporve
> >>>>>> the situation?
> >>>>>>
> >>>>>> Jean-Noël
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>> --
> >>>>> Graeme Rocher
> >>>>> Grails Project Lead
> >>>>> http://grails.org
> >>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>> To unsubscribe from this list please visit:
> >>>>>
> >>>>>     http://xircles.codehaus.org/manage_email
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>> --
> >>>> View this message in context: http://www.nabble.com/Status-of-Hibernate-annotations-on-a-Groovy-domain-class-%28POGO%29-tf4310486.html#a12277002
> >>>> Sent from the grails - user mailing list archive at Nabble.com.
> >>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe from this list please visit:
> >>>>
> >>>>     http://xircles.codehaus.org/manage_email
> >>>>
> >>>>
> >>>>
> >>>>
> >> ---------------------------------------------------------------------
> >> To unsubscribe from this list please visit:
> >>
> >>     http://xircles.codehaus.org/manage_email
> >>
> >>
> >>
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Status of Hibernate annotations on a Groovy domain class (POGO)

Barry Lagerweij
In reply to this post by Todd Johnson-5
What happens when you do not create the hibernate.cfg.xml file ? Since it's a normal Grails domain class, living in grails-app/domain, you don't need to register the class manually by using the hibernate.cfg.xml

It would explain the duplicate mapping, since the GORM plugin tries to register the domain class, but your hibernate.cfg.xml has also done this previously.

Barry

On 8/22/07, Todd Johnson <[hidden email]> wrote:
Before I open an issue, let me verify I took the correct steps.

Annotated my domain class:
import javax.persistence.*
@Entity
class User {
        @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
        Long id
        @Column(name="uname")
        String username
}

added to the dataSource section in grails-app/conf/DataSource.groovy:
configClass =
org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration.class

created grails-app/conf/hibernate/hibernate.cfg.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
  PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory><mapping class="User" /></session-factory>
</hibernate-configuration>

when i startup I get an org.hibernate.DuplicateMappingException:
Duplicate class/entity mapping User

If those steps should have worked, let me know and I'll raise an issue,
else, let me know where my blunder was.

Thanks for all your input on this,
Todd

P.S. Are you going to release a second edition of your book when 1.0
comes out?

Graeme Rocher wrote:

> On 8/22/07, Todd Johnson < [hidden email]> wrote:
>
>> I've been in the same situation as you Jean-Noël.  I want to do
>> something gorm doesn't do correctly (many-to-many recursive
>> relationships).  I wanted to just annotate my domain class, but that
>> didn't work.  Correct me if I'm wrong, but the annotations are actually
>> part of the jpa spec. Earlier Graeme wrote:
>>
>>
>>> I've updated the Roadmap, we are scaling back our goals for 1.0 to
>>> make sure we deliver a stable release. The focust will be on
>>> stability, project infastructure and plug-in system refinements until
>>> 1.0
>>>
>>> After 1.0 we'll deal with things like JPA, probably as a plugin
>>>
>>> Cheers
>>>
>> So I'm guessing jpa annotations fall into that category?
>>
>
> No we can certainly support Hibernate annotations for 1.0. When I
> refer to JPA support I am talking about adding dynamic methods that
> use the EntityManager and allowing Grails to work with TopLink, Kodo
> etc.
>
> As for the currently problem, I don't see what the issue is with
> putting the classses in src/groovy for them moment. All the dynamic
> finders and methods will still work. In the meantime raise an issue
> for the problem with classes in grails-app/domain and we can look at
> it
>
> Cheers
>
>
>>
>> Jean-Noël Rivasseau wrote:
>>
>>> Hello.
>>>
>>> I don't plan currently to write the domain classes in Java - I make
>>> use of lots of Groovy features.
>>>
>>> After further investigation, it appears that the situation has not
>>> changed a lot from 0.5.6. I realised that the Hibernate configuration
>>> file web-app/WEB-INF/classes/hibernate.cfg.xml was not the one I
>>> expected (it was not copied over from
>>> grails-app/conf/hibernate/hibernate.cfg.xml !! Is that a bug ??). Thus
>>> it did not contain the mapping for the domain class in grails-app.
>>> Thus it was of course logical that these annotations did not have any
>>> effect.
>>>
>>> So after manually copying it and verifying that it had the mapping for
>>> the domain class in grails-app/domain, it started outputting the same
>>> error than under 0.5.6:
>>>
>>> 2007-08-22 17:24:34.074::WARN:  Nested in
>>> org.springframework.beans.factory.BeanCreationException: Error
>>> creating bean with name 'transactionManager': Cannot resolve reference
>>> to bean 'sessionFactory' while setting bean property 'sessionFactory';
>>> nested exception is
>>> org.springframework.beans.factory.BeanCreationException: Error
>>> creating bean with name 'sessionFactory': Invocation of init method
>>> failed; nested exception is org.hibernate.DuplicateMappingException:
>>> Duplicate class/entity mapping AnnotationElement:
>>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>>> mapping AnnotationElement
>>>
>>> AnnotationElement.groovy is my test class in grails-app/domain.
>>>

>>> So, no changes from 0.5.6? Can someone look at this?
>>>
>>> Jean-Noël
>>>
>>>
>>> On 8/22/07, Mano <[hidden email]> wrote:
>>>
>>>
>>>> The other solution is that you could write the domain classes in java. You
>>>> can add hibernate annotations and also have all the dynamic methods
>>>> available.
>>>>
>>>> - Manohar
>>>>
>>>>
>>>> graemer wrote:
>>>>
>>>>
>>>>> I recommend you try 0.6, if you wait a little while I'll have an RC
>>>>> for you to download
>>>>>
>>>>> Cheers
>>>>>
>>>>> On 8/22/07, Jean-Noël Rivasseau < [hidden email]> wrote:
>>>>>
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I am writing this to know the status of Hibernate annotations support
>>>>>> in Grails currently, for Groovy domain classes. I am using Grails
>>>>>> 0.5.6 - maybe things have improved in 0.6 so please tell me.
>>>>>>
>>>>>> Currently the only information I've found on the subject was a
>>>>>> previous thread in the mailing list. Hibernate annotations can somehow
>>>>>> be used in Groovy domain classes, but I encountered the following
>>>>>> problems:
>>>>>>
>>>>>> * First, I had to move the file Section.groovy out of
>>>>>> grails-app/domain to /src/groovy, else I would have errors (duplicate
>>>>>> stuff: same errors as the previous person wrote on the thread I
>>>>>> mention). This probably means that my class is no longer considered a
>>>>>> domain, so I lose all the dynamics methods associated with it, right?
>>>>>>
>>>>>> * Second, I could not use annotations from org.hibernate.annotations
>>>>>> import org.hibernate.annotations would produce errors when launching
>>>>>> grails run-app (class not found). Maybe this is only a classpath
>>>>>> problem, eg Grails does not load the correct hibernate annotations
>>>>>> jar?
>>>>>>
>>>>>> This second problem is annoying as I cannot use the Hibernate
>>>>>> annotations extensions to the EJB3 annotations. The first problem
>>>>>> prevents a nice integration within the Grails framework.
>>>>>>
>>>>>> It would really really be nice to be able to customize the Hibernate
>>>>>> mappings on POGOs: this would allow to do easily things that GORM does
>>>>>> not permit right now, while benefiting from Grails advantages.
>>>>>>
>>>>>> Should I open a JIRA feature request for this? Does Grails 0.6 imporve

>>>>>> the situation?
>>>>>>
>>>>>> Jean-Noël
>>>>>>
>>>>>>
>>>>>>
>>>>> --
>>>>> Graeme Rocher
>>>>> Grails Project Lead
>>>>> http://grails.org
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe from this list please visit:
>>>>>
>>>>>     http://xircles.codehaus.org/manage_email
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>> --
>>>> View this message in context: http://www.nabble.com/Status-of-Hibernate-annotations-on-a-Groovy-domain-class-%28POGO%29-tf4310486.html#a12277002
>>>> Sent from the grails - user mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list please visit:
>>>>
>>>>     http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Status of Hibernate annotations on a Groovy domain class (POGO)

elvanor
If I don't create the hibernate.cfg.xml file everything works, but
annotations don't have any effects since the class is then mapped by
GORM. Which is obviously not what I want.

On 8/22/07, Barry Lagerweij <[hidden email]> wrote:

> What happens when you do not create the hibernate.cfg.xml file ? Since it's
> a normal Grails domain class, living in grails-app/domain, you don't need to
> register the class manually by using the hibernate.cfg.xml
>
> It would explain the duplicate mapping, since the GORM plugin tries to
> register the domain class, but your hibernate.cfg.xml has also done this
> previously.
>
> Barry
>
>
> On 8/22/07, Todd Johnson <[hidden email]> wrote:
> > Before I open an issue, let me verify I took the correct steps.
> >
> > Annotated my domain class:
> > import javax.persistence.*
> > @Entity
> > class User {
> >         @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
> >         Long id
> >         @Column(name="uname")
> >         String username
> > }
> >
> > added to the dataSource section in
> grails-app/conf/DataSource.groovy:
> > configClass =
> >
> org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration.class
> >
> > created grails-app/conf/hibernate/hibernate.cfg.xml:
> > <?xml version='1.0' encoding='utf-8'?>
> > <!DOCTYPE hibernate-configuration
> >   PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
> >
> "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
> > <hibernate-configuration>
> >     <session-factory><mapping class="User" /></session-factory>
> > </hibernate-configuration>
> >
> > when i startup I get an
> org.hibernate.DuplicateMappingException:
> > Duplicate class/entity mapping User
> >
> > If those steps should have worked, let me know and I'll raise an issue,
> > else, let me know where my blunder was.
> >
> > Thanks for all your input on this,
> > Todd
> >
> > P.S. Are you going to release a second edition of your book when 1.0
> > comes out?
> >
> > Graeme Rocher wrote:
> > > On 8/22/07, Todd Johnson < [hidden email]> wrote:
> > >
> > >> I've been in the same situation as you Jean-Noël.  I want to do
> > >> something gorm doesn't do correctly (many-to-many recursive
> > >> relationships).  I wanted to just annotate my domain class, but that
> > >> didn't work.  Correct me if I'm wrong, but the annotations are actually
> > >> part of the jpa spec. Earlier Graeme wrote:
> > >>
> > >>
> > >>> I've updated the Roadmap, we are scaling back our goals for 1.0 to
> > >>> make sure we deliver a stable release. The focust will be on
> > >>> stability, project infastructure and plug-in system refinements until
> > >>> 1.0
> > >>>
> > >>> After 1.0 we'll deal with things like JPA, probably as a plugin
> > >>>
> > >>> Cheers
> > >>>
> > >> So I'm guessing jpa annotations fall into that category?
> > >>
> > >
> > > No we can certainly support Hibernate annotations for 1.0. When I
> > > refer to JPA support I am talking about adding dynamic methods that
> > > use the EntityManager and allowing Grails to work with TopLink, Kodo
> > > etc.
> > >
> > > As for the currently problem, I don't see what the issue is with
> > > putting the classses in src/groovy for them moment. All the dynamic
> > > finders and methods will still work. In the meantime raise an issue
> > > for the problem with classes in grails-app/domain and we can look at
> > > it
> > >
> > > Cheers
> > >
> > >
> > >>
> > >> Jean-Noël Rivasseau wrote:
> > >>
> > >>> Hello.
> > >>>
> > >>> I don't plan currently to write the domain classes in Java - I make
> > >>> use of lots of Groovy features.
> > >>>
> > >>> After further investigation, it appears that the situation has not
> > >>> changed a lot from 0.5.6. I realised that the Hibernate configuration
> > >>> file web-app/WEB-INF/classes/hibernate.cfg.xml was
> not the one I
> > >>> expected (it was not copied over from
> > >>> grails-app/conf/hibernate/hibernate.cfg.xml !! Is
> that a bug ??). Thus
> > >>> it did not contain the mapping for the domain class in grails-app.
> > >>> Thus it was of course logical that these annotations did not have any
> > >>> effect.
> > >>>
> > >>> So after manually copying it and verifying that it had the mapping for
> > >>> the domain class in grails-app/domain, it started outputting the same
> > >>> error than under 0.5.6:
> > >>>
> > >>> 2007-08-22 17:24:34.074::WARN:  Nested in
> > >>>
> org.springframework.beans.factory.BeanCreationException:
> Error
> > >>> creating bean with name 'transactionManager': Cannot resolve reference
> > >>> to bean 'sessionFactory' while setting bean property 'sessionFactory';
> > >>> nested exception is
> > >>>
> org.springframework.beans.factory.BeanCreationException:
> Error
> > >>> creating bean with name 'sessionFactory': Invocation of init method
> > >>> failed; nested exception is
> org.hibernate.DuplicateMappingException:
> > >>> Duplicate class/entity mapping AnnotationElement:
> > >>> org.hibernate.DuplicateMappingException: Duplicate
> class/entity
> > >>> mapping AnnotationElement
> > >>>
> > >>> AnnotationElement.groovy is my test class in grails-app/domain.
> > >>>
> > >>> So, no changes from 0.5.6? Can someone look at this?
> > >>>
> > >>> Jean-Noël
> > >>>
> > >>>
> > >>> On 8/22/07, Mano < [hidden email]> wrote:
> > >>>
> > >>>
> > >>>> The other solution is that you could write the domain classes in
> java. You
> > >>>> can add hibernate annotations and also have all the dynamic methods
> > >>>> available.
> > >>>>
> > >>>> - Manohar
> > >>>>
> > >>>>
> > >>>> graemer wrote:
> > >>>>
> > >>>>
> > >>>>> I recommend you try 0.6, if you wait a little while I'll have an RC
> > >>>>> for you to download
> > >>>>>
> > >>>>> Cheers
> > >>>>>
> > >>>>> On 8/22/07, Jean-Noël Rivasseau < [hidden email]> wrote:
> > >>>>>
> > >>>>>
> > >>>>>> Hello,
> > >>>>>>
> > >>>>>> I am writing this to know the status of Hibernate annotations
> support
> > >>>>>> in Grails currently, for Groovy domain classes. I am using Grails
> > >>>>>> 0.5.6 - maybe things have improved in 0.6 so please tell me.
> > >>>>>>
> > >>>>>> Currently the only information I've found on the subject was a
> > >>>>>> previous thread in the mailing list. Hibernate annotations can
> somehow
> > >>>>>> be used in Groovy domain classes, but I encountered the following
> > >>>>>> problems:
> > >>>>>>
> > >>>>>> * First, I had to move the file Section.groovy out of
> > >>>>>> grails-app/domain to /src/groovy, else I would have errors
> (duplicate
> > >>>>>> stuff: same errors as the previous person wrote on the thread I
> > >>>>>> mention). This probably means that my class is no longer considered
> a
> > >>>>>> domain, so I lose all the dynamics methods associated with it,
> right?
> > >>>>>>
> > >>>>>> * Second, I could not use annotations from
> org.hibernate.annotations
> > >>>>>> import org.hibernate.annotations would produce errors when
> launching
> > >>>>>> grails run-app (class not found). Maybe this is only a classpath
> > >>>>>> problem, eg Grails does not load the correct hibernate annotations
> > >>>>>> jar?
> > >>>>>>
> > >>>>>> This second problem is annoying as I cannot use the Hibernate
> > >>>>>> annotations extensions to the EJB3 annotations. The first problem
> > >>>>>> prevents a nice integration within the Grails framework.
> > >>>>>>
> > >>>>>> It would really really be nice to be able to customize the
> Hibernate
> > >>>>>> mappings on POGOs: this would allow to do easily things that GORM
> does
> > >>>>>> not permit right now, while benefiting from Grails advantages.
> > >>>>>>
> > >>>>>> Should I open a JIRA feature request for this? Does Grails 0.6
> imporve
> > >>>>>> the situation?
> > >>>>>>
> > >>>>>> Jean-Noël
> > >>>>>>
> > >>>>>>
> > >>>>>>
> > >>>>> --
> > >>>>> Graeme Rocher
> > >>>>> Grails Project Lead
> > >>>>> http://grails.org
> > >>>>>
> > >>>>>
> ---------------------------------------------------------------------
> > >>>>> To unsubscribe from this list please visit:
> > >>>>>
> > >>>>>     http://xircles.codehaus.org/manage_email
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>> --
> > >>>> View this message in context:
> http://www.nabble.com/Status-of-Hibernate-annotations-on-a-Groovy-domain-class-%28POGO%29-tf4310486.html#a12277002
> > >>>> Sent from the grails - user mailing list archive at Nabble.com.
> > >>>>
> > >>>>
> > >>>>
> ---------------------------------------------------------------------
> > >>>> To unsubscribe from this list please visit:
> > >>>>
> > >>>>     http://xircles.codehaus.org/manage_email
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>
> ---------------------------------------------------------------------
> > >> To unsubscribe from this list please visit:
> > >>
> > >>     http://xircles.codehaus.org/manage_email
> > >>
> > >>
> > >>
> > >
> > >
> > >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Status of Hibernate annotations on a Groovy domain class (POGO)

Barry Lagerweij
Ah, yes, forgot about that.

I guess for now (at least until GORM detects @Entity domain classes) you have to revert to the old situation: put these annotated domain-classes in src/groovy, and register them manually via hibernate.cfg.xml :-(

Barry

On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
If I don't create the hibernate.cfg.xml file everything works, but
annotations don't have any effects since the class is then mapped by
GORM. Which is obviously not what I want.

On 8/22/07, Barry Lagerweij < [hidden email]> wrote:

> What happens when you do not create the hibernate.cfg.xml file ? Since it's
> a normal Grails domain class, living in grails-app/domain, you don't need to
> register the class manually by using the hibernate.cfg.xml
>
> It would explain the duplicate mapping, since the GORM plugin tries to
> register the domain class, but your hibernate.cfg.xml has also done this
> previously.
>
> Barry
>
>
> On 8/22/07, Todd Johnson <[hidden email]> wrote:
> > Before I open an issue, let me verify I took the correct steps.
> >
> > Annotated my domain class:
> > import javax.persistence.*
> > @Entity
> > class User {
> >         @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
> >         Long id
> >         @Column(name="uname")
> >         String username
> > }
> >
> > added to the dataSource section in
> grails-app/conf/DataSource.groovy:
> > configClass =
> >
> org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration.class
> >
> > created grails-app/conf/hibernate/hibernate.cfg.xml:
> > <?xml version='1.0' encoding='utf-8'?>
> > <!DOCTYPE hibernate-configuration
> >   PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
> >
> " http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
> > <hibernate-configuration>
> >     <session-factory><mapping class="User" /></session-factory>
> > </hibernate-configuration>
> >
> > when i startup I get an
> org.hibernate.DuplicateMappingException:
> > Duplicate class/entity mapping User
> >
> > If those steps should have worked, let me know and I'll raise an issue,
> > else, let me know where my blunder was.
> >
> > Thanks for all your input on this,
> > Todd
> >
> > P.S. Are you going to release a second edition of your book when 1.0
> > comes out?
> >
> > Graeme Rocher wrote:
> > > On 8/22/07, Todd Johnson < [hidden email]> wrote:
> > >
> > >> I've been in the same situation as you Jean-Noël.  I want to do
> > >> something gorm doesn't do correctly (many-to-many recursive
> > >> relationships).  I wanted to just annotate my domain class, but that
> > >> didn't work.  Correct me if I'm wrong, but the annotations are actually
> > >> part of the jpa spec. Earlier Graeme wrote:
> > >>
> > >>
> > >>> I've updated the Roadmap, we are scaling back our goals for 1.0 to
> > >>> make sure we deliver a stable release. The focust will be on
> > >>> stability, project infastructure and plug-in system refinements until
> > >>> 1.0
> > >>>
> > >>> After 1.0 we'll deal with things like JPA, probably as a plugin
> > >>>
> > >>> Cheers
> > >>>
> > >> So I'm guessing jpa annotations fall into that category?
> > >>
> > >
> > > No we can certainly support Hibernate annotations for 1.0. When I
> > > refer to JPA support I am talking about adding dynamic methods that
> > > use the EntityManager and allowing Grails to work with TopLink, Kodo
> > > etc.
> > >
> > > As for the currently problem, I don't see what the issue is with
> > > putting the classses in src/groovy for them moment. All the dynamic
> > > finders and methods will still work. In the meantime raise an issue
> > > for the problem with classes in grails-app/domain and we can look at
> > > it
> > >
> > > Cheers
> > >
> > >
> > >>
> > >> Jean-Noël Rivasseau wrote:
> > >>
> > >>> Hello.
> > >>>
> > >>> I don't plan currently to write the domain classes in Java - I make
> > >>> use of lots of Groovy features.
> > >>>
> > >>> After further investigation, it appears that the situation has not
> > >>> changed a lot from 0.5.6. I realised that the Hibernate configuration
> > >>> file web-app/WEB-INF/classes/hibernate.cfg.xml was
> not the one I
> > >>> expected (it was not copied over from
> > >>> grails-app/conf/hibernate/hibernate.cfg.xml !! Is
> that a bug ??). Thus
> > >>> it did not contain the mapping for the domain class in grails-app.
> > >>> Thus it was of course logical that these annotations did not have any
> > >>> effect.
> > >>>
> > >>> So after manually copying it and verifying that it had the mapping for
> > >>> the domain class in grails-app/domain, it started outputting the same
> > >>> error than under 0.5.6:
> > >>>
> > >>> 2007-08-22 17:24:34.074::WARN:   Nested in
> > >>>
> org.springframework.beans.factory.BeanCreationException:
> Error
> > >>> creating bean with name 'transactionManager': Cannot resolve reference
> > >>> to bean 'sessionFactory' while setting bean property 'sessionFactory';
> > >>> nested exception is
> > >>>
> org.springframework.beans.factory.BeanCreationException :
> Error
> > >>> creating bean with name 'sessionFactory': Invocation of init method
> > >>> failed; nested exception is
> org.hibernate.DuplicateMappingException:
> > >>> Duplicate class/entity mapping AnnotationElement:

> > >>> org.hibernate.DuplicateMappingException: Duplicate
> class/entity
> > >>> mapping AnnotationElement
> > >>>
> > >>> AnnotationElement.groovy is my test class in grails-app/domain.
> > >>>
> > >>> So, no changes from 0.5.6? Can someone look at this?
> > >>>
> > >>> Jean-Noël
> > >>>
> > >>>
> > >>> On 8/22/07, Mano < [hidden email]> wrote:
> > >>>
> > >>>
> > >>>> The other solution is that you could write the domain classes in
> java. You
> > >>>> can add hibernate annotations and also have all the dynamic methods
> > >>>> available.
> > >>>>
> > >>>> - Manohar
> > >>>>
> > >>>>
> > >>>> graemer wrote:
> > >>>>
> > >>>>
> > >>>>> I recommend you try 0.6, if you wait a little while I'll have an RC
> > >>>>> for you to download
> > >>>>>
> > >>>>> Cheers
> > >>>>>
> > >>>>> On 8/22/07, Jean-Noël Rivasseau < [hidden email]> wrote:
> > >>>>>
> > >>>>>
> > >>>>>> Hello,
> > >>>>>>
> > >>>>>> I am writing this to know the status of Hibernate annotations
> support

> > >>>>>> in Grails currently, for Groovy domain classes. I am using Grails
> > >>>>>> 0.5.6 - maybe things have improved in 0.6 so please tell me.
> > >>>>>>
> > >>>>>> Currently the only information I've found on the subject was a
> > >>>>>> previous thread in the mailing list. Hibernate annotations can
> somehow
> > >>>>>> be used in Groovy domain classes, but I encountered the following
> > >>>>>> problems:
> > >>>>>>
> > >>>>>> * First, I had to move the file Section.groovy out of
> > >>>>>> grails-app/domain to /src/groovy, else I would have errors
> (duplicate
> > >>>>>> stuff: same errors as the previous person wrote on the thread I
> > >>>>>> mention). This probably means that my class is no longer considered
> a
> > >>>>>> domain, so I lose all the dynamics methods associated with it,
> right?

> > >>>>>>
> > >>>>>> * Second, I could not use annotations from
> org.hibernate.annotations
> > >>>>>> import org.hibernate.annotations would produce errors when
> launching
> > >>>>>> grails run-app (class not found). Maybe this is only a classpath
> > >>>>>> problem, eg Grails does not load the correct hibernate annotations
> > >>>>>> jar?
> > >>>>>>
> > >>>>>> This second problem is annoying as I cannot use the Hibernate
> > >>>>>> annotations extensions to the EJB3 annotations. The first problem
> > >>>>>> prevents a nice integration within the Grails framework.
> > >>>>>>
> > >>>>>> It would really really be nice to be able to customize the
> Hibernate
> > >>>>>> mappings on POGOs: this would allow to do easily things that GORM
> does
> > >>>>>> not permit right now, while benefiting from Grails advantages.
> > >>>>>>
> > >>>>>> Should I open a JIRA feature request for this? Does Grails 0.6
> imporve
> > >>>>>> the situation?
> > >>>>>>
> > >>>>>> Jean-Noël
> > >>>>>>
> > >>>>>>
> > >>>>>>
> > >>>>> --
> > >>>>> Graeme Rocher
> > >>>>> Grails Project Lead
> > >>>>> http://grails.org
> > >>>>>
> > >>>>>
> ---------------------------------------------------------------------
> > >>>>> To unsubscribe from this list please visit:
> > >>>>>
> > >>>>>     http://xircles.codehaus.org/manage_email
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>> --
> > >>>> View this message in context:
> http://www.nabble.com/Status-of-Hibernate-annotations-on-a-Groovy-domain-class-%28POGO%29-tf4310486.html#a12277002
> > >>>> Sent from the grails - user mailing list archive at Nabble.com.
> > >>>>
> > >>>>
> > >>>>
> ---------------------------------------------------------------------

> > >>>> To unsubscribe from this list please visit:
> > >>>>
> > >>>>     http://xircles.codehaus.org/manage_email
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>
> ---------------------------------------------------------------------
> > >> To unsubscribe from this list please visit:
> > >>
> > >>     http://xircles.codehaus.org/manage_email
> > >>
> > >>
> > >>
> > >
> > >
> > >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Status of Hibernate annotations on a Groovy domain class (POGO)

elvanor
In reply to this post by Todd Johnson-5
Did you open the issue?

On 8/22/07, Todd Johnson <[hidden email]> wrote:

> Before I open an issue, let me verify I took the correct steps.
>
> Annotated my domain class:
> import javax.persistence.*
> @Entity
> class User {
>         @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
>         Long id
>         @Column(name="uname")
>         String username
> }
>
> added to the dataSource section in grails-app/conf/DataSource.groovy:
> configClass =
> org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration.class
>
> created grails-app/conf/hibernate/hibernate.cfg.xml:
> <?xml version='1.0' encoding='utf-8'?>
> <!DOCTYPE hibernate-configuration
>   PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
>   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
> <hibernate-configuration>
>     <session-factory><mapping class="User" /></session-factory>
> </hibernate-configuration>
>
> when i startup I get an org.hibernate.DuplicateMappingException:
> Duplicate class/entity mapping User
>
> If those steps should have worked, let me know and I'll raise an issue,
> else, let me know where my blunder was.
>
> Thanks for all your input on this,
> Todd
>
> P.S. Are you going to release a second edition of your book when 1.0
> comes out?
>
> Graeme Rocher wrote:
> > On 8/22/07, Todd Johnson <[hidden email]> wrote:
> >
> >> I've been in the same situation as you Jean-Noël.  I want to do
> >> something gorm doesn't do correctly (many-to-many recursive
> >> relationships).  I wanted to just annotate my domain class, but that
> >> didn't work.  Correct me if I'm wrong, but the annotations are actually
> >> part of the jpa spec. Earlier Graeme wrote:
> >>
> >>
> >>> I've updated the Roadmap, we are scaling back our goals for 1.0 to
> >>> make sure we deliver a stable release. The focust will be on
> >>> stability, project infastructure and plug-in system refinements until
> >>> 1.0
> >>>
> >>> After 1.0 we'll deal with things like JPA, probably as a plugin
> >>>
> >>> Cheers
> >>>
> >> So I'm guessing jpa annotations fall into that category?
> >>
> >
> > No we can certainly support Hibernate annotations for 1.0. When I
> > refer to JPA support I am talking about adding dynamic methods that
> > use the EntityManager and allowing Grails to work with TopLink, Kodo
> > etc.
> >
> > As for the currently problem, I don't see what the issue is with
> > putting the classses in src/groovy for them moment. All the dynamic
> > finders and methods will still work. In the meantime raise an issue
> > for the problem with classes in grails-app/domain and we can look at
> > it
> >
> > Cheers
> >
> >
> >>
> >> Jean-Noël Rivasseau wrote:
> >>
> >>> Hello.
> >>>
> >>> I don't plan currently to write the domain classes in Java - I make
> >>> use of lots of Groovy features.
> >>>
> >>> After further investigation, it appears that the situation has not
> >>> changed a lot from 0.5.6. I realised that the Hibernate configuration
> >>> file web-app/WEB-INF/classes/hibernate.cfg.xml was not the one I
> >>> expected (it was not copied over from
> >>> grails-app/conf/hibernate/hibernate.cfg.xml !! Is that a bug ??). Thus
> >>> it did not contain the mapping for the domain class in grails-app.
> >>> Thus it was of course logical that these annotations did not have any
> >>> effect.
> >>>
> >>> So after manually copying it and verifying that it had the mapping for
> >>> the domain class in grails-app/domain, it started outputting the same
> >>> error than under 0.5.6:
> >>>
> >>> 2007-08-22 17:24:34.074::WARN:  Nested in
> >>> org.springframework.beans.factory.BeanCreationException: Error
> >>> creating bean with name 'transactionManager': Cannot resolve reference
> >>> to bean 'sessionFactory' while setting bean property 'sessionFactory';
> >>> nested exception is
> >>> org.springframework.beans.factory.BeanCreationException: Error
> >>> creating bean with name 'sessionFactory': Invocation of init method
> >>> failed; nested exception is org.hibernate.DuplicateMappingException:
> >>> Duplicate class/entity mapping AnnotationElement:
> >>> org.hibernate.DuplicateMappingException: Duplicate class/entity
> >>> mapping AnnotationElement
> >>>
> >>> AnnotationElement.groovy is my test class in grails-app/domain.
> >>>
> >>> So, no changes from 0.5.6? Can someone look at this?
> >>>
> >>> Jean-Noël
> >>>
> >>>
> >>> On 8/22/07, Mano <[hidden email]> wrote:
> >>>
> >>>
> >>>> The other solution is that you could write the domain classes in java. You
> >>>> can add hibernate annotations and also have all the dynamic methods
> >>>> available.
> >>>>
> >>>> - Manohar
> >>>>
> >>>>
> >>>> graemer wrote:
> >>>>
> >>>>
> >>>>> I recommend you try 0.6, if you wait a little while I'll have an RC
> >>>>> for you to download
> >>>>>
> >>>>> Cheers
> >>>>>
> >>>>> On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
> >>>>>
> >>>>>
> >>>>>> Hello,
> >>>>>>
> >>>>>> I am writing this to know the status of Hibernate annotations support
> >>>>>> in Grails currently, for Groovy domain classes. I am using Grails
> >>>>>> 0.5.6 - maybe things have improved in 0.6 so please tell me.
> >>>>>>
> >>>>>> Currently the only information I've found on the subject was a
> >>>>>> previous thread in the mailing list. Hibernate annotations can somehow
> >>>>>> be used in Groovy domain classes, but I encountered the following
> >>>>>> problems:
> >>>>>>
> >>>>>> * First, I had to move the file Section.groovy out of
> >>>>>> grails-app/domain to /src/groovy, else I would have errors (duplicate
> >>>>>> stuff: same errors as the previous person wrote on the thread I
> >>>>>> mention). This probably means that my class is no longer considered a
> >>>>>> domain, so I lose all the dynamics methods associated with it, right?
> >>>>>>
> >>>>>> * Second, I could not use annotations from org.hibernate.annotations
> >>>>>> import org.hibernate.annotations would produce errors when launching
> >>>>>> grails run-app (class not found). Maybe this is only a classpath
> >>>>>> problem, eg Grails does not load the correct hibernate annotations
> >>>>>> jar?
> >>>>>>
> >>>>>> This second problem is annoying as I cannot use the Hibernate
> >>>>>> annotations extensions to the EJB3 annotations. The first problem
> >>>>>> prevents a nice integration within the Grails framework.
> >>>>>>
> >>>>>> It would really really be nice to be able to customize the Hibernate
> >>>>>> mappings on POGOs: this would allow to do easily things that GORM does
> >>>>>> not permit right now, while benefiting from Grails advantages.
> >>>>>>
> >>>>>> Should I open a JIRA feature request for this? Does Grails 0.6 imporve
> >>>>>> the situation?
> >>>>>>
> >>>>>> Jean-Noël
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>> --
> >>>>> Graeme Rocher
> >>>>> Grails Project Lead
> >>>>> http://grails.org
> >>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>> To unsubscribe from this list please visit:
> >>>>>
> >>>>>     http://xircles.codehaus.org/manage_email
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>> --
> >>>> View this message in context: http://www.nabble.com/Status-of-Hibernate-annotations-on-a-Groovy-domain-class-%28POGO%29-tf4310486.html#a12277002
> >>>> Sent from the grails - user mailing list archive at Nabble.com.
> >>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe from this list please visit:
> >>>>
> >>>>     http://xircles.codehaus.org/manage_email
> >>>>
> >>>>
> >>>>
> >>>>
> >> ---------------------------------------------------------------------
> >> To unsubscribe from this list please visit:
> >>
> >>     http://xircles.codehaus.org/manage_email
> >>
> >>
> >>
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Status of Hibernate annotations on a Groovy domain class (POGO)

Todd Johnson-5
yea, thanks for the reminder
http://jira.codehaus.org/browse/GRAILS-1551

Jean-Noël Rivasseau wrote:

> Did you open the issue?
>
> On 8/22/07, Todd Johnson <[hidden email]> wrote:
>  
>> Before I open an issue, let me verify I took the correct steps.
>>
>> Annotated my domain class:
>> import javax.persistence.*
>> @Entity
>> class User {
>>         @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
>>         Long id
>>         @Column(name="uname")
>>         String username
>> }
>>
>> added to the dataSource section in grails-app/conf/DataSource.groovy:
>> configClass =
>> org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration.class
>>
>> created grails-app/conf/hibernate/hibernate.cfg.xml:
>> <?xml version='1.0' encoding='utf-8'?>
>> <!DOCTYPE hibernate-configuration
>>   PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
>>   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
>> <hibernate-configuration>
>>     <session-factory><mapping class="User" /></session-factory>
>> </hibernate-configuration>
>>
>> when i startup I get an org.hibernate.DuplicateMappingException:
>> Duplicate class/entity mapping User
>>
>> If those steps should have worked, let me know and I'll raise an issue,
>> else, let me know where my blunder was.
>>
>> Thanks for all your input on this,
>> Todd
>>
>> P.S. Are you going to release a second edition of your book when 1.0
>> comes out?
>>
>> Graeme Rocher wrote:
>>    
>>> On 8/22/07, Todd Johnson <[hidden email]> wrote:
>>>
>>>      
>>>> I've been in the same situation as you Jean-Noël.  I want to do
>>>> something gorm doesn't do correctly (many-to-many recursive
>>>> relationships).  I wanted to just annotate my domain class, but that
>>>> didn't work.  Correct me if I'm wrong, but the annotations are actually
>>>> part of the jpa spec. Earlier Graeme wrote:
>>>>
>>>>
>>>>        
>>>>> I've updated the Roadmap, we are scaling back our goals for 1.0 to
>>>>> make sure we deliver a stable release. The focust will be on
>>>>> stability, project infastructure and plug-in system refinements until
>>>>> 1.0
>>>>>
>>>>> After 1.0 we'll deal with things like JPA, probably as a plugin
>>>>>
>>>>> Cheers
>>>>>
>>>>>          
>>>> So I'm guessing jpa annotations fall into that category?
>>>>
>>>>        
>>> No we can certainly support Hibernate annotations for 1.0. When I
>>> refer to JPA support I am talking about adding dynamic methods that
>>> use the EntityManager and allowing Grails to work with TopLink, Kodo
>>> etc.
>>>
>>> As for the currently problem, I don't see what the issue is with
>>> putting the classses in src/groovy for them moment. All the dynamic
>>> finders and methods will still work. In the meantime raise an issue
>>> for the problem with classes in grails-app/domain and we can look at
>>> it
>>>
>>> Cheers
>>>
>>>
>>>      
>>>> Jean-Noël Rivasseau wrote:
>>>>
>>>>        
>>>>> Hello.
>>>>>
>>>>> I don't plan currently to write the domain classes in Java - I make
>>>>> use of lots of Groovy features.
>>>>>
>>>>> After further investigation, it appears that the situation has not
>>>>> changed a lot from 0.5.6. I realised that the Hibernate configuration
>>>>> file web-app/WEB-INF/classes/hibernate.cfg.xml was not the one I
>>>>> expected (it was not copied over from
>>>>> grails-app/conf/hibernate/hibernate.cfg.xml !! Is that a bug ??). Thus
>>>>> it did not contain the mapping for the domain class in grails-app.
>>>>> Thus it was of course logical that these annotations did not have any
>>>>> effect.
>>>>>
>>>>> So after manually copying it and verifying that it had the mapping for
>>>>> the domain class in grails-app/domain, it started outputting the same
>>>>> error than under 0.5.6:
>>>>>
>>>>> 2007-08-22 17:24:34.074::WARN:  Nested in
>>>>> org.springframework.beans.factory.BeanCreationException: Error
>>>>> creating bean with name 'transactionManager': Cannot resolve reference
>>>>> to bean 'sessionFactory' while setting bean property 'sessionFactory';
>>>>> nested exception is
>>>>> org.springframework.beans.factory.BeanCreationException: Error
>>>>> creating bean with name 'sessionFactory': Invocation of init method
>>>>> failed; nested exception is org.hibernate.DuplicateMappingException:
>>>>> Duplicate class/entity mapping AnnotationElement:
>>>>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>>>>> mapping AnnotationElement
>>>>>
>>>>> AnnotationElement.groovy is my test class in grails-app/domain.
>>>>>
>>>>> So, no changes from 0.5.6? Can someone look at this?
>>>>>
>>>>> Jean-Noël
>>>>>
>>>>>
>>>>> On 8/22/07, Mano <[hidden email]> wrote:
>>>>>
>>>>>
>>>>>          
>>>>>> The other solution is that you could write the domain classes in java. You
>>>>>> can add hibernate annotations and also have all the dynamic methods
>>>>>> available.
>>>>>>
>>>>>> - Manohar
>>>>>>
>>>>>>
>>>>>> graemer wrote:
>>>>>>
>>>>>>
>>>>>>            
>>>>>>> I recommend you try 0.6, if you wait a little while I'll have an RC
>>>>>>> for you to download
>>>>>>>
>>>>>>> Cheers
>>>>>>>
>>>>>>> On 8/22/07, Jean-Noël Rivasseau <[hidden email]> wrote:
>>>>>>>
>>>>>>>
>>>>>>>              
>>>>>>>> Hello,
>>>>>>>>
>>>>>>>> I am writing this to know the status of Hibernate annotations support
>>>>>>>> in Grails currently, for Groovy domain classes. I am using Grails
>>>>>>>> 0.5.6 - maybe things have improved in 0.6 so please tell me.
>>>>>>>>
>>>>>>>> Currently the only information I've found on the subject was a
>>>>>>>> previous thread in the mailing list. Hibernate annotations can somehow
>>>>>>>> be used in Groovy domain classes, but I encountered the following
>>>>>>>> problems:
>>>>>>>>
>>>>>>>> * First, I had to move the file Section.groovy out of
>>>>>>>> grails-app/domain to /src/groovy, else I would have errors (duplicate
>>>>>>>> stuff: same errors as the previous person wrote on the thread I
>>>>>>>> mention). This probably means that my class is no longer considered a
>>>>>>>> domain, so I lose all the dynamics methods associated with it, right?
>>>>>>>>
>>>>>>>> * Second, I could not use annotations from org.hibernate.annotations
>>>>>>>> import org.hibernate.annotations would produce errors when launching
>>>>>>>> grails run-app (class not found). Maybe this is only a classpath
>>>>>>>> problem, eg Grails does not load the correct hibernate annotations
>>>>>>>> jar?
>>>>>>>>
>>>>>>>> This second problem is annoying as I cannot use the Hibernate
>>>>>>>> annotations extensions to the EJB3 annotations. The first problem
>>>>>>>> prevents a nice integration within the Grails framework.
>>>>>>>>
>>>>>>>> It would really really be nice to be able to customize the Hibernate
>>>>>>>> mappings on POGOs: this would allow to do easily things that GORM does
>>>>>>>> not permit right now, while benefiting from Grails advantages.
>>>>>>>>
>>>>>>>> Should I open a JIRA feature request for this? Does Grails 0.6 imporve
>>>>>>>> the situation?
>>>>>>>>
>>>>>>>> Jean-Noël
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                
>>>>>>> --
>>>>>>> Graeme Rocher
>>>>>>> Grails Project Lead
>>>>>>> http://grails.org
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe from this list please visit:
>>>>>>>
>>>>>>>     http://xircles.codehaus.org/manage_email
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>              
>>>>>> --
>>>>>> View this message in context: http://www.nabble.com/Status-of-Hibernate-annotations-on-a-Groovy-domain-class-%28POGO%29-tf4310486.html#a12277002
>>>>>> Sent from the grails - user mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe from this list please visit:
>>>>>>
>>>>>>     http://xircles.codehaus.org/manage_email
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>            
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list please visit:
>>>>
>>>>     http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>>        
>>>
>>>      
>> ---------------------------------------------------------------------
>> To unsubscribe from this list please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>    


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email