porno porno rokettube
Results 1 to 3 of 3

Thread: grails one to many relationship: no entries created on database

  1. #1

    grails one to many relationship: no entries created on database

    I have two domain classes in which one has a one to many relationship with the other

    Class A
           static hasMany = [bElements:B]
        Class B
    When I run the application, the relation table A_B is created and entries in A_B table are automatically added when user creates A objects. Then I've decided to change this relation, because I've noticed that it is better to have a relation between class A and class C, so class A now has

    static hasMany = [cElements:C]

    but when I create a new object of type A (after creation of some C objects), adding one or more objects of type C, in my database I don't see the entry into the A_C table, but only in A table.

    Why do this beahavior happens? What must I control to resolve problem?

  2. #2
    Anybody has an answer to this??

  3. #3
    think this is basic gorm working - you need to read the docs again. essentially unless the many side has a 'belongsTo' then gorm wont auto manage the inserts for you - you have to do that yourself. so if you want the auto handling you need the belongsTo declared in the many side table (class C). else you have to create the C instance, then set this into the B attribute by hand and ensure you have saved the C instance then the B instance. Try reading the gorm sections again


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Forum Design by Tucanoo Solutions Ltd Grails Development Specialists.