hibernate - Saving hasMany relationship without addTo -


we have 2 domain classes

class feegroup {  string name;  static hasmany = [priceranges:pricerange] 

and

class pricerange {  integer from; integer to; boolean include;  static belongsto = [feegroup:feegroup] 

from frontend application receive form json

{     "name":"fee group 1",     "priceranges":[                     {"from":10, "to":20, "include":true},                     {"from":20, "to":40, "include":true},                     {"from":30, "to":60, "include":true}                   ] } 

right want save data simple

def model = new feegroup(data) model.save() 

with code shoud saved priceranges. wrong this? because save feegroup! wierd when you

println model.priceranges 

after model.save() print new ids of priceranges - nothing in database , not in hibernate (flush not helped here).

everywhere in documentations should use model.addtopriceranges why? why one-to-one working , one-tp-many not?

i tried changed feegroup domain class to

class feegroup {  string name; set priceranges static hasmany = [priceranges:pricerange] 

and right simple saving working gorm created 1 connection table fee_group_price_range... dont want have 3 tables hasmany connection. not solution.

thanks advice

edit

3 tables not because of changes in feegroup class because change pricerange class to

class pricerange {  integer from; integer to; boolean include;  static belongsto = feegroup 


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -