Please inject id and version

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Please inject id and version

Gregory Pierce-2
Since the backend of this system is Spring and injection is fairly straightforward, is there no way we can inject the properties for id and version? These are system properties and they really shouldn't be omitted or anything like that or else you'll have nasty results. 

Accordingly, shouldn't these just be injected into the class so that users don't stumble over them and delete them or do some other craziness like changing the type? The book class, for example, should really look like

class Book {
    @Property belongsTo = [ author : Author ] (or similar)

    @Property Author author
    @Property String title
}


or ideally given the suggestions made in the previous mail

class Book 
{
    @Property String title

    @Property belongsTo = [ author : Author ] (or similar)
}

That is to the point and nothing is 'overstated'.
Reply | Threaded
Open this post in threaded view
|

Re: Please inject id and version

graemer
On 4/20/06, Gregory Pierce <[hidden email]> wrote:

> Since the backend of this system is Spring and injection is fairly
> straightforward, is there no way we can inject the properties for id and
> version? These are system properties and they really shouldn't be omitted or
> anything like that or else you'll have nasty results.
>
> Accordingly, shouldn't these just be injected into the class so that users
> don't stumble over them and delete them or do some other craziness like
> changing the type? The book class, for example, should really look like
>
> class Book {
>     @Property belongsTo = [ author : Author ] (or similar)
>
>     @Property Author author
>     @Property String title
> }
>
>
> or ideally given the suggestions made in the previous mail
>
> class Book
> {
>     @Property String title
>
>     @Property belongsTo = [ author : Author ] (or similar)
> }
>
> That is to the point and nothing is 'overstated'.

It would be nice, but this convention is used to identify a domain
class as we don't use inheritance and also as mentioned previously
Hibernate needs real properties to map correctly as its not groovy
aware

Graeme
Reply | Threaded
Open this post in threaded view
|

RE: Please inject id and version

Dierk König
I think there is room for a description of Grails usage patterns.

The whole issue below only applies to bi-directional relationsships.
For uni-directional ones, you do not have to provide any meta information.

In my experience, most 'usage patterns' do not need bi-directional
relationsships
since using a finder method when needed is good enough.

cheers
Mittie


> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]On Behalf
> Of Graeme Rocher
> Sent: Freitag, 21. April 2006 11:21
> To: [hidden email]
> Subject: Re: [grails-user] Please inject id and version
>
>
> On 4/20/06, Gregory Pierce <[hidden email]> wrote:
> > Since the backend of this system is Spring and injection is fairly
> > straightforward, is there no way we can inject the properties for id and
> > version? These are system properties and they really shouldn't
> be omitted or
> > anything like that or else you'll have nasty results.
> >
> > Accordingly, shouldn't these just be injected into the class so
> that users
> > don't stumble over them and delete them or do some other craziness like
> > changing the type? The book class, for example, should really look like
> >
> > class Book {
> >     @Property belongsTo = [ author : Author ] (or similar)
> >
> >     @Property Author author
> >     @Property String title
> > }
> >
> >
> > or ideally given the suggestions made in the previous mail
> >
> > class Book
> > {
> >     @Property String title
> >
> >     @Property belongsTo = [ author : Author ] (or similar)
> > }
> >
> > That is to the point and nothing is 'overstated'.
>
> It would be nice, but this convention is used to identify a domain
> class as we don't use inheritance and also as mentioned previously
> Hibernate needs real properties to map correctly as its not groovy
> aware
>
> Graeme