Because that is your back reference to Header that is stored in Line table. Your tables are like this:
Lines_2_V : invoice_id, line_number, header_id, one_id, second_id ,thid_id
Header_2_V: invoice_id
Since Gorm already has Header's id
stored in Line table, its using that to join them.
When you have belongTo
as a map:
static belongsTo = [header : Header]
Grails/Gorm will create a back reference in your table. You can also use
static belongsTo = Header
Which gorm creates intermediate table to join them for more information refer to GORM Gotchas article by Peter Ledbrook
btw, Lines
should be lines
:
createAlias('Lines', 'l', CriteriaSpecification.INNER_JOIN)
should be
createAlias('lines', 'l', CriteriaSpecification.INNER_JOIN)