gorm


use of mappedBy in Many to Many relationship in Grails


I am a newbie to Grails and am having a lots of problems in a many to many relationship especially when the mappedBy comes into picture. Here is the exact problem that I am facing.
I have two domain classes which have a many to many relationship.
class Address {
Long id
String addName
static hasMany = [policy: Policy]
static belongsTo=[Policy]
Date lastUpdated
Date dateCreated
}
and
class Policy {
int id
int policyId
Date lastUpdated
Date dateCreated
static hasMany = [addressSource:Address,addressDestination: AddressSet]
}
Now this creates 4 tables, namely : address, policy, policy_src_add and policy_dest_add
The problem that I am facing is with the 'show' view (The views are the standard ones generated by Grails by the generate-views command).
In the show view of Address I can see the Policies that are referenced by policy_dest_add but not the ones that are referenced by policy_src_add.
For ex : Let us assume there is a policy:"PK" which has addressSource:"AS"(lets say id=1) and a addressDestination :"AD"(lets say : id=2)
When i go to the show view of "AD" (which is /address/show/2 ) I can see the Policy "PK" but when i go to the show view of "AS" (which is /address/show/1 ) I can NOT see the Policy "PK" in it.
Can someone please help me.Is this a view generation problem in case of many to many relationships in grails? Or is it just something I am missing ?I have tried using mappedBy in the Address as follows but to no avail :
static mappedBy = [policy:"addressSource", policy:"addressDestination"]
Thanks a ton,
Manas Shukla

Related Links

Grails 3 (unsaved) instance issue while fetching from database (GORM)
Can't use get() in domain using Grails3
GORM findAll + cannot pass dynamic List as named parameter
How to display database records in grails
Configure Grails 3.0.9 for Oracle 12c with identity PK?
Adding condition to findAll and findAllBy methods
Neo4j and Mongodb as datasource in Grails
GORM (varchar .save(), non DATE): ORA-01861: literal does not match format string
GORM addTo methods not found in Spock test
spring-boot property exception while externalizing datasource properties and using actuator
Mapping hasMany relation and saving the related data
Method on class [] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails Correctly
What happens when two app servers in cluster start LiquiBase update (via Grails)?
use of mappedBy in Many to Many relationship in Grails
Domain class auto validation in grails
Grails Detached Criteria Query and “group by” and “having” clause

Categories

HOME
ibm-bluemix
ionic-framework
pypi
reflection
azure-data-factory
google-api-php-client
hp-exstream
fft
baqend
synchronization
gorm
izpack
spring-tool-suite
flask-wtforms
zebra-printers
finite-automata
shared-hosting
custom-wordpress-pages
bootstrap-material-design
applozic
assistant
pdb
lxd
jmonkeyengine
jquery-bootgrid
unobtrusive-validation
broadcastreceiver
eclipse-scout
galleria
qwt
worksheet
dropbox-php
slickedit
magma
smart-table
instant
adxstudio-portals
gridview-sorting
lua-5.1
prettytensor
essence
sdf
hexdump
pagerank
php-internals
wapiti
pyke
lib.web.mvc
cartesian-product
cannon.js
python-3.2
processmodel
angular-local-storage
nsmutabledictionary
jsonpickle
fpml
rdtsc
preferences
typeof
system.net.webexception
message-driven-bean
gridfs
excel-2003
android-hardware
distutils
referrer
typoscript2
simba
online-compilation
enter
gnu-prolog
cinema-4d
sql-server-profiler
mysql-error-1005
fixed-width
firefox4
xetex
temporal-database

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App