|
Hi all,
I've committed a big improvement to GORM which is in SVN at the moment. Essentially you no longer need to specify id,version,toString,hashCode and equals. So a Book class is as simple as: class Book { String title } The rest is injected for you at compile time. This has been extended to the creation of relationships to. So an Author class is as simple as: class Author { String name def hasMany = [books:Book] } The "books" collection is automatically created for you if you dont specifiy it yourself. So you can start doing this immediately: def a = new Author(name:"Stephen King") .addBook(new Book(title:"The Shining")) .addBook(new Book(title:"The Stand")) a.books.each { println it.title } Give it a try if you're brave, be interested to have some feedback. Couple of things to note: 1) Its backwards compatabile with the old GORM 2) It only injects properties/methods if you don't specify them yourself Next job on the list is to support Many-from-many. -- Graeme Rocher Grails Project Lead http://grails.org --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
Would it be possible to inject, an addBook method? It would follow the
boilerplate: def addBook( book ) { book.author = this if( !books ) books = new HashSet() books.add( book ) } Is this a good idea or too much? Graeme Rocher wrote: > Hi all, > > I've committed a big improvement to GORM which is in SVN at the > moment. Essentially you no longer need to specify > id,version,toString,hashCode and equals. So a Book class is as simple > as: > > class Book { > String title > } > > The rest is injected for you at compile time. This has been extended > to the creation of relationships to. So an Author class is as simple > as: > > class Author { > String name > def hasMany = [books:Book] > } > > The "books" collection is automatically created for you if you dont > specifiy it yourself. So you can start doing this immediately: > > def a = new Author(name:"Stephen King") > .addBook(new Book(title:"The Shining")) > .addBook(new Book(title:"The Stand")) > > a.books.each { println it.title } > > Give it a try if you're brave, be interested to have some feedback. > Couple of things to note: > > 1) Its backwards compatabile with the old GORM > 2) It only injects properties/methods if you don't specify them yourself > > Next job on the list is to support Many-from-many. > -- Kerry Wilson Lead Developer Williams Web [hidden email] | 423.485.4747 --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
Its a good idea and GORM already does it :-)
Graeme On 9/26/06, Kerry Wilson <[hidden email]> wrote: > Would it be possible to inject, an addBook method? It would follow the > boilerplate: > > def addBook( book ) { > book.author = this > if( !books ) > books = new HashSet() > books.add( book ) > } > > Is this a good idea or too much? > > Graeme Rocher wrote: > > Hi all, > > > > I've committed a big improvement to GORM which is in SVN at the > > moment. Essentially you no longer need to specify > > id,version,toString,hashCode and equals. So a Book class is as simple > > as: > > > > class Book { > > String title > > } > > > > The rest is injected for you at compile time. This has been extended > > to the creation of relationships to. So an Author class is as simple > > as: > > > > class Author { > > String name > > def hasMany = [books:Book] > > } > > > > The "books" collection is automatically created for you if you dont > > specifiy it yourself. So you can start doing this immediately: > > > > def a = new Author(name:"Stephen King") > > .addBook(new Book(title:"The Shining")) > > .addBook(new Book(title:"The Stand")) > > > > a.books.each { println it.title } > > > > Give it a try if you're brave, be interested to have some feedback. > > Couple of things to note: > > > > 1) Its backwards compatabile with the old GORM > > 2) It only injects properties/methods if you don't specify them yourself > > > > Next job on the list is to support Many-from-many. > > > > > -- > Kerry Wilson > Lead Developer > Williams Web > [hidden email] | 423.485.4747 > > > > --------------------------------------------------------------------- > 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 |
|
excellent!
Graeme Rocher wrote: > Its a good idea and GORM already does it :-) > > Graeme -- Kerry Wilson Lead Developer Williams Web [hidden email] | 423.485.4747 --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by graemer
Fantastic! Now my domain classes can just contain my own domain code.
Grails just keeps getting better :)) I noticed in your example below you use hasMany. Can I ask what is the difference between hasMany and relatesToMany? Also does this work with belongsTo, so Book would be: class Book { String title def belongsTo = Author // or maybe "def belongsTo = [ Author, Publisher ]" using the other wiki example } Which would mean Book now has an "author" property. Is that right? (Sorry, stupid question I'm sure) Graeme Rocher wrote: > Its a good idea and GORM already does it :-) > > Graeme > > On 9/26/06, Kerry Wilson <[hidden email]> wrote: >> Would it be possible to inject, an addBook method? It would follow the >> boilerplate: >> >> def addBook( book ) { >> book.author = this >> if( !books ) >> books = new HashSet() >> books.add( book ) >> } >> >> Is this a good idea or too much? >> >> Graeme Rocher wrote: >> > Hi all, >> > >> > I've committed a big improvement to GORM which is in SVN at the >> > moment. Essentially you no longer need to specify >> > id,version,toString,hashCode and equals. So a Book class is as simple >> > as: >> > >> > class Book { >> > String title >> > } >> > >> > The rest is injected for you at compile time. This has been extended >> > to the creation of relationships to. So an Author class is as simple >> > as: >> > >> > class Author { >> > String name >> > def hasMany = [books:Book] >> > } >> > >> > The "books" collection is automatically created for you if you dont >> > specifiy it yourself. So you can start doing this immediately: >> > >> > def a = new Author(name:"Stephen King") >> > .addBook(new Book(title:"The Shining")) >> > .addBook(new Book(title:"The Stand")) >> > >> > a.books.each { println it.title } >> > >> > Give it a try if you're brave, be interested to have some feedback. >> > Couple of things to note: >> > >> > 1) Its backwards compatabile with the old GORM >> > 2) It only injects properties/methods if you don't specify them >> yourself >> > >> > Next job on the list is to support Many-from-many. >> > >> >> >> -- >> Kerry Wilson >> Lead Developer >> Williams Web >> [hidden email] | 423.485.4747 >> >> >> >> --------------------------------------------------------------------- >> 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 |
|
On 9/26/06, Maurice Nicholson <[hidden email]> wrote:
> Fantastic! Now my domain classes can just contain my own domain code. > Grails just keeps getting better :)) > > I noticed in your example below you use hasMany. Can I ask what is the > difference between hasMany and relatesToMany? They're the same, we may eventually deprecate relatesToMany as hasMany is easier. > > Also does this work with belongsTo, so Book would be: > > class Book { > String title > def belongsTo = Author > // or maybe "def belongsTo = [ Author, Publisher ]" using the other > wiki example > } No it doesn't do it for belongsTo, but it could! In fact I'm on it now ;-) > > Which would mean Book now has an "author" property. Is that right? > (Sorry, stupid question I'm sure) Cheers Graeme > > > Graeme Rocher wrote: > > Its a good idea and GORM already does it :-) > > > > Graeme > > > > On 9/26/06, Kerry Wilson <[hidden email]> wrote: > >> Would it be possible to inject, an addBook method? It would follow the > >> boilerplate: > >> > >> def addBook( book ) { > >> book.author = this > >> if( !books ) > >> books = new HashSet() > >> books.add( book ) > >> } > >> > >> Is this a good idea or too much? > >> > >> Graeme Rocher wrote: > >> > Hi all, > >> > > >> > I've committed a big improvement to GORM which is in SVN at the > >> > moment. Essentially you no longer need to specify > >> > id,version,toString,hashCode and equals. So a Book class is as simple > >> > as: > >> > > >> > class Book { > >> > String title > >> > } > >> > > >> > The rest is injected for you at compile time. This has been extended > >> > to the creation of relationships to. So an Author class is as simple > >> > as: > >> > > >> > class Author { > >> > String name > >> > def hasMany = [books:Book] > >> > } > >> > > >> > The "books" collection is automatically created for you if you dont > >> > specifiy it yourself. So you can start doing this immediately: > >> > > >> > def a = new Author(name:"Stephen King") > >> > .addBook(new Book(title:"The Shining")) > >> > .addBook(new Book(title:"The Stand")) > >> > > >> > a.books.each { println it.title } > >> > > >> > Give it a try if you're brave, be interested to have some feedback. > >> > Couple of things to note: > >> > > >> > 1) Its backwards compatabile with the old GORM > >> > 2) It only injects properties/methods if you don't specify them > >> yourself > >> > > >> > Next job on the list is to support Many-from-many. > >> > > >> > >> > >> -- > >> Kerry Wilson > >> Lead Developer > >> Williams Web > >> [hidden email] | 423.485.4747 > >> > >> > >> > >> --------------------------------------------------------------------- > >> 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 |
|
Hmm actually that requires some thought as it could be uni-directional
in which case we would need something like: def belongsToAndHasOne = Author Which is not so neat and i'm not sure if its a better than the current solution Graeme On 9/26/06, Graeme Rocher <[hidden email]> wrote: > On 9/26/06, Maurice Nicholson <[hidden email]> wrote: > > Fantastic! Now my domain classes can just contain my own domain code. > > Grails just keeps getting better :)) > > > > I noticed in your example below you use hasMany. Can I ask what is the > > difference between hasMany and relatesToMany? > > They're the same, we may eventually deprecate relatesToMany as hasMany > is easier. > > > > > Also does this work with belongsTo, so Book would be: > > > > class Book { > > String title > > def belongsTo = Author > > // or maybe "def belongsTo = [ Author, Publisher ]" using the other > > wiki example > > } > > No it doesn't do it for belongsTo, but it could! In fact I'm on it now ;-) > > > > Which would mean Book now has an "author" property. Is that right? > > (Sorry, stupid question I'm sure) > > Cheers > Graeme > > > > > > > Graeme Rocher wrote: > > > Its a good idea and GORM already does it :-) > > > > > > Graeme > > > > > > On 9/26/06, Kerry Wilson <[hidden email]> wrote: > > >> Would it be possible to inject, an addBook method? It would follow the > > >> boilerplate: > > >> > > >> def addBook( book ) { > > >> book.author = this > > >> if( !books ) > > >> books = new HashSet() > > >> books.add( book ) > > >> } > > >> > > >> Is this a good idea or too much? > > >> > > >> Graeme Rocher wrote: > > >> > Hi all, > > >> > > > >> > I've committed a big improvement to GORM which is in SVN at the > > >> > moment. Essentially you no longer need to specify > > >> > id,version,toString,hashCode and equals. So a Book class is as simple > > >> > as: > > >> > > > >> > class Book { > > >> > String title > > >> > } > > >> > > > >> > The rest is injected for you at compile time. This has been extended > > >> > to the creation of relationships to. So an Author class is as simple > > >> > as: > > >> > > > >> > class Author { > > >> > String name > > >> > def hasMany = [books:Book] > > >> > } > > >> > > > >> > The "books" collection is automatically created for you if you dont > > >> > specifiy it yourself. So you can start doing this immediately: > > >> > > > >> > def a = new Author(name:"Stephen King") > > >> > .addBook(new Book(title:"The Shining")) > > >> > .addBook(new Book(title:"The Stand")) > > >> > > > >> > a.books.each { println it.title } > > >> > > > >> > Give it a try if you're brave, be interested to have some feedback. > > >> > Couple of things to note: > > >> > > > >> > 1) Its backwards compatabile with the old GORM > > >> > 2) It only injects properties/methods if you don't specify them > > >> yourself > > >> > > > >> > Next job on the list is to support Many-from-many. > > >> > > > >> > > >> > > >> -- > > >> Kerry Wilson > > >> Lead Developer > > >> Williams Web > > >> [hidden email] | 423.485.4747 > > >> > > >> > > >> > > >> --------------------------------------------------------------------- > > >> 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 > -- Graeme Rocher Grails Project Lead http://grails.org --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by graemer
does it do the plurals?
so to examplify it: class Author { String name def hasMany = [categories:Category] } The "categories" collection is automatically created for you if you dont specifiy it yourself. So you can start doing this immediately: def a = new Author(name:"Stephen King") .addCategory(new Category(title:"Fiction")) .addCategory(new Category(title:"Thriller")) ? On 9/26/06, Graeme Rocher <[hidden email]> wrote: > Hi all, > > I've committed a big improvement to GORM which is in SVN at the > moment. Essentially you no longer need to specify > id,version,toString,hashCode and equals. So a Book class is as simple > as: > > class Book { > String title > } > > The rest is injected for you at compile time. This has been extended > to the creation of relationships to. So an Author class is as simple > as: > > class Author { > String name > def hasMany = [books:Book] > } > > The "books" collection is automatically created for you if you dont > specifiy it yourself. So you can start doing this immediately: > > def a = new Author(name:"Stephen King") > .addBook(new Book(title:"The Shining")) > .addBook(new Book(title:"The Stand")) > > a.books.each { println it.title } > > Give it a try if you're brave, be interested to have some feedback. > Couple of things to note: > > 1) Its backwards compatabile with the old GORM > 2) It only injects properties/methods if you don't specify them yourself > > Next job on the list is to support Many-from-many. > > -- > Graeme Rocher > Grails Project Lead > http://grails.org > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > > -- Thanks, Alex. --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
It doesn't do "plurals" as they're a crap idea. Plurals assume
everyone speaks english which they clearly do not. But you example below does work, because it doesn't need it. It takes the "categories" name from the key in the hasMany map. Graeme On 9/26/06, Alex Shneyderman <[hidden email]> wrote: > does it do the plurals? > > so to examplify it: > > class Author { > String name > def hasMany = [categories:Category] > } > > The "categories" collection is automatically created for you if you dont > specifiy it yourself. So you can start doing this immediately: > > def a = new Author(name:"Stephen King") > .addCategory(new Category(title:"Fiction")) > .addCategory(new Category(title:"Thriller")) > > ? > On 9/26/06, Graeme Rocher <[hidden email]> wrote: > > Hi all, > > > > I've committed a big improvement to GORM which is in SVN at the > > moment. Essentially you no longer need to specify > > id,version,toString,hashCode and equals. So a Book class is as simple > > as: > > > > class Book { > > String title > > } > > > > The rest is injected for you at compile time. This has been extended > > to the creation of relationships to. So an Author class is as simple > > as: > > > > class Author { > > String name > > def hasMany = [books:Book] > > } > > > > The "books" collection is automatically created for you if you dont > > specifiy it yourself. So you can start doing this immediately: > > > > def a = new Author(name:"Stephen King") > > .addBook(new Book(title:"The Shining")) > > .addBook(new Book(title:"The Stand")) > > > > a.books.each { println it.title } > > > > Give it a try if you're brave, be interested to have some feedback. > > Couple of things to note: > > > > 1) Its backwards compatabile with the old GORM > > 2) It only injects properties/methods if you don't specify them yourself > > > > Next job on the list is to support Many-from-many. > > > > -- > > Graeme Rocher > > Grails Project Lead > > http://grails.org > > > > --------------------------------------------------------------------- > > To unsubscribe from this list please visit: > > > > http://xircles.codehaus.org/manage_email > > > > > > > -- > Thanks, > Alex. > > --------------------------------------------------------------------- > 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 |
|
> It doesn't do "plurals" as they're a crap idea. Plurals assume
> everyone speaks english which they clearly do not. I had no assumption of this kind. I just read a lot of code ... > But you example below does work, because it doesn't need it. It takes > the "categories" name from the key in the hasMany map. I was asking more about addCategory method that is added by GORM. I built grails a few days ago and yesterday had a need to pluralize. Unfortunately, the add method did not work as I expected, hence my question. --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by graemer
That's _awesome_. Great work.
I would guess the current GORM documentation shouldn't be replaced since this isn't in the current Grails release distribution... Maybe we should add a link from the top of the current GORM page to a GORM2 page? I'll try to do it if I get a chance. Thanks. -Tom.. On 9/26/06, Graeme Rocher <[hidden email]> wrote: > Hi all, > > I've committed a big improvement to GORM which is in SVN at the > moment. Essentially you no longer need to specify > id,version,toString,hashCode and equals. So a Book class is as simple > as: > > class Book { > String title > } > > The rest is injected for you at compile time. This has been extended > to the creation of relationships to. So an Author class is as simple > as: > > class Author { > String name > def hasMany = [books:Book] > } > > The "books" collection is automatically created for you if you dont > specifiy it yourself. So you can start doing this immediately: > > def a = new Author(name:"Stephen King") > .addBook(new Book(title:"The Shining")) > .addBook(new Book(title:"The Stand")) > > a.books.each { println it.title } > > Give it a try if you're brave, be interested to have some feedback. > Couple of things to note: > > 1) Its backwards compatabile with the old GORM > 2) It only injects properties/methods if you don't specify them yourself > > Next job on the list is to support Many-from-many. > > -- > Graeme Rocher > Grails Project Lead > http://grails.org > > --------------------------------------------------------------------- > 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 |
|
In reply to this post by graemer
On 26 Sep 2006, at 16:20, Graeme Rocher wrote: > It doesn't do "plurals" as they're a crap idea. Plurals assume > everyone speaks english which they clearly do not. > LOL indeed. When I learned about plurals in Rails it had me in stitches. A total "DailyWTF" if ever I saw one. There's the ever so thorny issue of what is the plural to use for irregular words, or words that don't even exist in the real world. People often get plurals wrong too so they would have difficulty knowing which one was correct, especially in ambiguous cases. I'd like a Pack class that contains many Wolfs please - er wait you do mean Wolves right? Oh it's OK we can handle that one with the code, but now I want a Horse class with many Hoofs (you mean Hooves don't you?). Ok we can handle that one too by looking for "oof"... so now I want a House with an option to have several Rooves (er Roofs surely?) ... I know let's just match everything on the first 3-4 letters and then ignore the rest ;-) And so continues the folly of "plain English" which is not nearly so plain. Cheers --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by Tom Nichols
On 9/26/06, Tom Nichols <[hidden email]> wrote:
> That's _awesome_. Great work. > > I would guess the current GORM documentation shouldn't be replaced > since this isn't in the current Grails release distribution... Maybe > we should add a link from the top of the current GORM page to a GORM2 > page? I'll try to do it if I get a chance. No I would prefer it if you raised an issue in JIRA to updated the docs before 0.3 release otherwise it will just confuse things and we'll end up with a Wiki like Groovy's :-( Graeme > > Thanks. > -Tom.. > > > On 9/26/06, Graeme Rocher <[hidden email]> wrote: > > Hi all, > > > > I've committed a big improvement to GORM which is in SVN at the > > moment. Essentially you no longer need to specify > > id,version,toString,hashCode and equals. So a Book class is as simple > > as: > > > > class Book { > > String title > > } > > > > The rest is injected for you at compile time. This has been extended > > to the creation of relationships to. So an Author class is as simple > > as: > > > > class Author { > > String name > > def hasMany = [books:Book] > > } > > > > The "books" collection is automatically created for you if you dont > > specifiy it yourself. So you can start doing this immediately: > > > > def a = new Author(name:"Stephen King") > > .addBook(new Book(title:"The Shining")) > > .addBook(new Book(title:"The Stand")) > > > > a.books.each { println it.title } > > > > Give it a try if you're brave, be interested to have some feedback. > > Couple of things to note: > > > > 1) Its backwards compatabile with the old GORM > > 2) It only injects properties/methods if you don't specify them yourself > > > > Next job on the list is to support Many-from-many. > > > > -- > > Graeme Rocher > > Grails Project Lead > > http://grails.org > > > > --------------------------------------------------------------------- > > 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 |
|
In reply to this post by a.shneyderman
On 9/26/06, Alex Shneyderman <[hidden email]> wrote:
> > It doesn't do "plurals" as they're a crap idea. Plurals assume > > everyone speaks english which they clearly do not. > > I had no assumption of this kind. I just read a lot of code ... Didn't mean to sound offensive, sorry :-) > > > But you example below does work, because it doesn't need it. It takes > > the "categories" name from the key in the hasMany map. > > I was asking more about addCategory method that is added by GORM. > I built grails a few days ago and yesterday had a need to pluralize. > Unfortunately, the add method did not work as I expected, hence my > question. Can you post example code so we can understand better what it is you wanted to achieve? Cheers Graeme > > --------------------------------------------------------------------- > 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 |
|
hi Grame,
Would it be possible to use GORM without Grails ? i.e. purely from a console based Groovy app? Kiran On 9/26/06, Graeme Rocher <[hidden email]> wrote: On 9/26/06, Alex Shneyderman <[hidden email]> wrote: |
|
This is possible yes, you need to do the same thing as some of the
command line utilities do. If you just need console functionality you can do: grails console Graeme On 9/26/06, Kiran K.G. <[hidden email]> wrote: > hi Grame, > > Would it be possible to use GORM without Grails ? i.e. purely from a console > based Groovy app? > Kiran > > On 9/26/06, Graeme Rocher < [hidden email]> wrote: > > On 9/26/06, Alex Shneyderman < [hidden email]> wrote: > > > > It doesn't do "plurals" as they're a crap idea. Plurals assume > > > > everyone speaks english which they clearly do not. > > > > > > I had no assumption of this kind. I just read a lot of code ... > > > > Didn't mean to sound offensive, sorry :-) > > > > > > > > > But you example below does work, because it doesn't need it. It takes > > > > the "categories" name from the key in the hasMany map. > > > > > > I was asking more about addCategory method that is added by GORM. > > > I built grails a few days ago and yesterday had a need to pluralize. > > > Unfortunately, the add method did not work as I expected, hence my > > > question. > > > > Can you post example code so we can understand better what it is you > > wanted to achieve? > > > > Cheers > > Graeme > > > > > > > --------------------------------------------------------------------- > > > 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 > > > > > > -- Graeme Rocher Grails Project Lead http://grails.org --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
hi Graeme,
Actually I want to use GORM from a java application. Just GORM without Grails. I looked at the "InteractiveShell" class with code like ApplicationContext ctx = GrailsUtil.bootstrapGrailsFromClassPath (); GrailsApplication app = (GrailsApplication)ctx.getBean(GrailsApplication.APPLICATION_ID); etc...... This approach works. However I am interested in using a more leight weight approach without SpringFramework etc.. (Quite analogous to Ruby/Rails where one can use ActiveRecord outside Rails application) Of course using GroovySQL is an option. But I like the GORM features (and the dynamic methods it adds to the domain class are cool) Regards Kiran On 9/26/06, Graeme Rocher <[hidden email]> wrote:
This is possible yes, you need to do the same thing as some of the |
|
In reply to this post by graemer
I just got chapter 16 of GINA from Manning. Is it too late (or too
early) to update the book to reflect this? I have thought all along that having id and version be declared in every domain class explicitely is very un-Groovy. It would be a shame if the improvement were made and couldn't be included in what will be a lot of people's first introduction to Grails. jb Graeme Rocher wrote: > Hi all, > > I've committed a big improvement to GORM which is in SVN at the > moment. Essentially you no longer need to specify > id,version,toString,hashCode and equals. So a Book class is as simple > as: > > class Book { > String title > } > > The rest is injected for you at compile time. This has been extended > to the creation of relationships to. So an Author class is as simple > as: > > class Author { > String name > def hasMany = [books:Book] > } > > The "books" collection is automatically created for you if you dont > specifiy it yourself. So you can start doing this immediately: > > def a = new Author(name:"Stephen King") > .addBook(new Book(title:"The Shining")) > .addBook(new Book(title:"The Stand")) > > a.books.each { println it.title } > > Give it a try if you're brave, be interested to have some feedback. > Couple of things to note: > > 1) Its backwards compatabile with the old GORM > 2) It only injects properties/methods if you don't specify them yourself > > Next job on the list is to support Many-from-many. > -- Jeff Brown [hidden email] Principal Software Engineer Object Computing Inc. http://www.ociweb.com/ Autism Strikes 1 in 250 Find The Cause ~ Find The Cure http://www.autismspeaks.org/ --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by graemer
Done: http://jira.codehaus.org/browse/GRAILS-319
On 9/26/06, Graeme Rocher <[hidden email]> wrote: > On 9/26/06, Tom Nichols <[hidden email]> wrote: > > That's _awesome_. Great work. > > > > I would guess the current GORM documentation shouldn't be replaced > > since this isn't in the current Grails release distribution... Maybe > > we should add a link from the top of the current GORM page to a GORM2 > > page? I'll try to do it if I get a chance. > > No I would prefer it if you raised an issue in JIRA to updated the > docs before 0.3 release otherwise it will just confuse things and > we'll end up with a Wiki like Groovy's :-( > > Graeme > > > > > Thanks. > > -Tom.. > > > > > > On 9/26/06, Graeme Rocher <[hidden email]> wrote: > > > Hi all, > > > > > > I've committed a big improvement to GORM which is in SVN at the > > > moment. Essentially you no longer need to specify > > > id,version,toString,hashCode and equals. So a Book class is as simple > > > as: > > > > > > class Book { > > > String title > > > } > > > > > > The rest is injected for you at compile time. This has been extended > > > to the creation of relationships to. So an Author class is as simple > > > as: > > > > > > class Author { > > > String name > > > def hasMany = [books:Book] > > > } > > > > > > The "books" collection is automatically created for you if you dont > > > specifiy it yourself. So you can start doing this immediately: > > > > > > def a = new Author(name:"Stephen King") > > > .addBook(new Book(title:"The Shining")) > > > .addBook(new Book(title:"The Stand")) > > > > > > a.books.each { println it.title } > > > > > > Give it a try if you're brave, be interested to have some feedback. > > > Couple of things to note: > > > > > > 1) Its backwards compatabile with the old GORM > > > 2) It only injects properties/methods if you don't specify them yourself > > > > > > Next job on the list is to support Many-from-many. > > > > > > -- > > > Graeme Rocher > > > Grails Project Lead > > > http://grails.org > > > > > > --------------------------------------------------------------------- > > > 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 > > --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by graemer
Actually, on a related topic, does it handle multiple collections of a
given type? That is to say, something like the following? class Person { def hasMany = [friends : Person, enemies: Person] } (what happens to the add___() methods?) Or, if you'd like a non-self-referencing example: class Book { def hasMany = [authors: Person, reviewers: Person] } (again, what happens to the add___() methods?) Would it be necessary to have different types? - Daiji Graeme Rocher wrote: > On 9/26/06, Alex Shneyderman <[hidden email]> wrote: >> > It doesn't do "plurals" as they're a crap idea. Plurals assume >> > everyone speaks english which they clearly do not. >> >> I had no assumption of this kind. I just read a lot of code ... > > Didn't mean to sound offensive, sorry :-) > >> >> > But you example below does work, because it doesn't need it. It takes >> > the "categories" name from the key in the hasMany map. >> >> I was asking more about addCategory method that is added by GORM. >> I built grails a few days ago and yesterday had a need to pluralize. >> Unfortunately, the add method did not work as I expected, hence my >> question. > > Can you post example code so we can understand better what it is you > wanted to achieve? > > Cheers > Graeme >> >> --------------------------------------------------------------------- >> To unsubscribe from this list please visit: >> >> http://xircles.codehaus.org/manage_email >> >> > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
| Powered by Nabble | Edit this page |
