Quantcast

Domain classes problem

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Domain classes problem

Guillaume Laforge-2
Good evening,

I wanted to prototype a little application I was needing for work, and
I must have done something wrong in the definition of my domain
classes, because I got this error:

   [groovy] org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFac
tory' defined in resource loaded through InputStream: Initialization
of bean failed; nested exception is org.h
ibernate.MappingException: property mapping has wrong number of
columns: Document.relationships type: object
   [groovy] org.hibernate.MappingException: property mapping has wrong
number of columns: Document.relationshi
ps type: object


But I don't know what's the problem.

For the record, here are my domain classes:

class Document {
    @Property Long id
    @Property Long version

    @Property relationships = [
        "keywords": Keyword.class
    ]

    @Property String title
    @Property String summary

    @Property StandardLevel level
    @Property DocumentType type
    @Property Perimeter perimeter

    @Property Set keywords = new HashSet()

    String toString() { "${this.class.name} :  $id" }
}

class Document {
    @Property Long id
    @Property Long version

    @Property relationships = [
        "keywords": Keyword.class
    ]

    @Property String title
    @Property String summary

    @Property StandardLevel level
    @Property DocumentType type
    @Property Perimeter perimeter

    @Property Set keywords = new HashSet()

    String toString() { "${this.class.name} :  $id" }
}

class Keyword {
    @Property Long id
    @Property Long version

    @Property String value

    String toString() { "${this.class.name} :  $id" }
}

class Perimeter {
    @Property Long id
    @Property Long version

    @Property String typology

    @Property ProjectStage stage

    String toString() { "${this.class.name} :  $id" }
}

class ProjectStage {
    @Property Long id
    @Property Long version

    @Property String value

    String toString() { "${this.class.name} :  $id" }
}

class Solution {
    @Property Long id
    @Property Long version

    @Property relationships = [
        "associatedSolutions": Solution.class,
        "associatedDocuments": Document.class,
        "keywords": Keyword.class
    ]

    @Property String title
    @Property String description

    @Property SolutionType type

    @Property Set associatedSolutions = new HashSet()
    @Property Set associatedDocuments = new HashSet()
    @Property Set keywords = new HashSet()

    String toString() { "${this.class.name} :  $id" }
}

class SolutionType {
    @Property Long id
    @Property Long version

    @Property String value

    String toString() { "${this.class.name} :  $id" }
}

class StandardLevel {
    @Property Long id
    @Property Long version

    @Property String value

    String toString() { "${this.class.name} :  $id" }
}

Any idea?
(sorry for the long post)
--
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Domain classes problem

Dierk König
Graeme can certainly give better advice, but here is mine:

- you are going for bi-directional references with
  'relationships' but the other side doesn't have an
  according property that will hold the 'other' side
  of the relation.
- I guess for your domain model, you will probably not need
  bi-directional references at all
  (unless you want to try it explicitly)
- If bi-directional, think about where to place the
  'belongsTo'.
- (you don't need the '.class' suffixes, since
  e.g. 'Document' already reference the class :-))

hope that helps
Mittie

> -----Original Message-----
> From: Guillaume Laforge [mailto:[hidden email]]
> Sent: Sonntag, 12. März 2006 23:05
> To: Grails Dev
> Subject: [grails-dev] Domain classes problem
>
>
> Good evening,
>
> I wanted to prototype a little application I was needing for work, and
> I must have done something wrong in the definition of my domain
> classes, because I got this error:
>
>    [groovy] org.springframework.beans.factory.BeanCreationException:
> Error creating bean with name 'sessionFac
> tory' defined in resource loaded through InputStream: Initialization
> of bean failed; nested exception is org.h
> ibernate.MappingException: property mapping has wrong number of
> columns: Document.relationships type: object
>    [groovy] org.hibernate.MappingException: property mapping has wrong
> number of columns: Document.relationshi
> ps type: object
>
>
> But I don't know what's the problem.
>
> For the record, here are my domain classes:
>
> class Document {
>     @Property Long id
>     @Property Long version
>
>     @Property relationships = [
>         "keywords": Keyword.class
>     ]
>
>     @Property String title
>     @Property String summary
>
>     @Property StandardLevel level
>     @Property DocumentType type
>     @Property Perimeter perimeter
>
>     @Property Set keywords = new HashSet()
>
>     String toString() { "${this.class.name} :  $id" }
> }
>
> class Document {
>     @Property Long id
>     @Property Long version
>
>     @Property relationships = [
>         "keywords": Keyword.class
>     ]
>
>     @Property String title
>     @Property String summary
>
>     @Property StandardLevel level
>     @Property DocumentType type
>     @Property Perimeter perimeter
>
>     @Property Set keywords = new HashSet()
>
>     String toString() { "${this.class.name} :  $id" }
> }
>
> class Keyword {
>     @Property Long id
>     @Property Long version
>
>     @Property String value
>
>     String toString() { "${this.class.name} :  $id" }
> }
>
> class Perimeter {
>     @Property Long id
>     @Property Long version
>
>     @Property String typology
>
>     @Property ProjectStage stage
>
>     String toString() { "${this.class.name} :  $id" }
> }
>
> class ProjectStage {
>     @Property Long id
>     @Property Long version
>
>     @Property String value
>
>     String toString() { "${this.class.name} :  $id" }
> }
>
> class Solution {
>     @Property Long id
>     @Property Long version
>
>     @Property relationships = [
>         "associatedSolutions": Solution.class,
>         "associatedDocuments": Document.class,
>         "keywords": Keyword.class
>     ]
>
>     @Property String title
>     @Property String description
>
>     @Property SolutionType type
>
>     @Property Set associatedSolutions = new HashSet()
>     @Property Set associatedDocuments = new HashSet()
>     @Property Set keywords = new HashSet()
>
>     String toString() { "${this.class.name} :  $id" }
> }
>
> class SolutionType {
>     @Property Long id
>     @Property Long version
>
>     @Property String value
>
>     String toString() { "${this.class.name} :  $id" }
> }
>
> class StandardLevel {
>     @Property Long id
>     @Property Long version
>
>     @Property String value
>
>     String toString() { "${this.class.name} :  $id" }
> }
>
> Any idea?
> (sorry for the long post)
> --
> Guillaume Laforge
> Groovy Project Manager
> http://glaforge.free.fr/blog/groovy

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Domain classes problem

graemer
I don't have much time to look at it now as I'm about to leave for
london to see a client, but I would say the most likely reason is that
you are still using the old 'relationships' property which has now
been renamed to 'relatesToMany'

Cheers
Graeme

On 13/03/06, Dierk Koenig <[hidden email]> wrote:

> Graeme can certainly give better advice, but here is mine:
>
> - you are going for bi-directional references with
>   'relationships' but the other side doesn't have an
>   according property that will hold the 'other' side
>   of the relation.
> - I guess for your domain model, you will probably not need
>   bi-directional references at all
>   (unless you want to try it explicitly)
> - If bi-directional, think about where to place the
>   'belongsTo'.
> - (you don't need the '.class' suffixes, since
>   e.g. 'Document' already reference the class :-))
>
> hope that helps
> Mittie
>
> > -----Original Message-----
> > From: Guillaume Laforge [mailto:[hidden email]]
> > Sent: Sonntag, 12. März 2006 23:05
> > To: Grails Dev
> > Subject: [grails-dev] Domain classes problem
> >
> >
> > Good evening,
> >
> > I wanted to prototype a little application I was needing for work, and
> > I must have done something wrong in the definition of my domain
> > classes, because I got this error:
> >
> >    [groovy] org.springframework.beans.factory.BeanCreationException:
> > Error creating bean with name 'sessionFac
> > tory' defined in resource loaded through InputStream: Initialization
> > of bean failed; nested exception is org.h
> > ibernate.MappingException: property mapping has wrong number of
> > columns: Document.relationships type: object
> >    [groovy] org.hibernate.MappingException: property mapping has wrong
> > number of columns: Document.relationshi
> > ps type: object
> >
> >
> > But I don't know what's the problem.
> >
> > For the record, here are my domain classes:
> >
> > class Document {
> >     @Property Long id
> >     @Property Long version
> >
> >     @Property relationships = [
> >         "keywords": Keyword.class
> >     ]
> >
> >     @Property String title
> >     @Property String summary
> >
> >     @Property StandardLevel level
> >     @Property DocumentType type
> >     @Property Perimeter perimeter
> >
> >     @Property Set keywords = new HashSet()
> >
> >     String toString() { "${this.class.name} :  $id" }
> > }
> >
> > class Document {
> >     @Property Long id
> >     @Property Long version
> >
> >     @Property relationships = [
> >         "keywords": Keyword.class
> >     ]
> >
> >     @Property String title
> >     @Property String summary
> >
> >     @Property StandardLevel level
> >     @Property DocumentType type
> >     @Property Perimeter perimeter
> >
> >     @Property Set keywords = new HashSet()
> >
> >     String toString() { "${this.class.name} :  $id" }
> > }
> >
> > class Keyword {
> >     @Property Long id
> >     @Property Long version
> >
> >     @Property String value
> >
> >     String toString() { "${this.class.name} :  $id" }
> > }
> >
> > class Perimeter {
> >     @Property Long id
> >     @Property Long version
> >
> >     @Property String typology
> >
> >     @Property ProjectStage stage
> >
> >     String toString() { "${this.class.name} :  $id" }
> > }
> >
> > class ProjectStage {
> >     @Property Long id
> >     @Property Long version
> >
> >     @Property String value
> >
> >     String toString() { "${this.class.name} :  $id" }
> > }
> >
> > class Solution {
> >     @Property Long id
> >     @Property Long version
> >
> >     @Property relationships = [
> >         "associatedSolutions": Solution.class,
> >         "associatedDocuments": Document.class,
> >         "keywords": Keyword.class
> >     ]
> >
> >     @Property String title
> >     @Property String description
> >
> >     @Property SolutionType type
> >
> >     @Property Set associatedSolutions = new HashSet()
> >     @Property Set associatedDocuments = new HashSet()
> >     @Property Set keywords = new HashSet()
> >
> >     String toString() { "${this.class.name} :  $id" }
> > }
> >
> > class SolutionType {
> >     @Property Long id
> >     @Property Long version
> >
> >     @Property String value
> >
> >     String toString() { "${this.class.name} :  $id" }
> > }
> >
> > class StandardLevel {
> >     @Property Long id
> >     @Property Long version
> >
> >     @Property String value
> >
> >     String toString() { "${this.class.name} :  $id" }
> > }
> >
> > Any idea?
> > (sorry for the long post)
> > --
> > Guillaume Laforge
> > Groovy Project Manager
> > http://glaforge.free.fr/blog/groovy
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Domain classes problem

Guillaume Laforge-2
On 3/13/06, Graeme Rocher <[hidden email]> wrote:
> I don't have much time to look at it now as I'm about to leave for
> london to see a client, but I would say the most likely reason is that
> you are still using the old 'relationships' property which has now
> been renamed to 'relatesToMany'

Hmmm okay :-)
I had an old version of the documentation with me while I was offline.
I'll double check it works with relatesToMany!


--
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy
Loading...