|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
GORM domain class mapping-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Hi List, I`m new to grails and try to create a webapp for an existing database. The database has 2 tables, locations and devices. the relationship is a one to many, one location can have many devices and one device has one location. the field to join is different in the tables. in locations its lannr and in devices its orgid. How can I tell gorm to join the tables like I would do in sql, ie select ..... from locations join devices on locations.lannr = devices.orgid I tried to find an example, but all examples are joining via id, also tried the mappedBy statement with no luck... Is it possible and if yes how can I do that? Thank you in advance, regards, Tom -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iD8DBQFK8dkuTCCRT+dccOYRAlFcAKDo6ts604Gd8aF23YfpORm82pgZwQCffWUU gxRFTaNbuCiQnPhi0NuoU0Y= =zqmL -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: GORM domain class mappingTake a look at the Custom mapping section Regards, Kamal
|
|
|
Re: GORM domain class mappingAssuming that the column locations.lannr is the primary key and devices.orgid the foreign key this should work. In the domain object Device you have got to assign the PK column name. I marked it as <DEVICE_PK>.
class Location { static hasMany = [devices: Device] static mapping = { table 'locations' id column: 'LANNR' } } class Device { static belongsTo = [location: Location] static mapping = { table 'devices' id column: '<DEVICE_PK>' location column: 'ORGID' } } |
| Free embeddable forum powered by Nabble | Forum Help |