gorm


Mapping hasMany relation and saving the related data


I have two domain classes Question and Tag.
Question has 'hasMany relation' with Tag.
I am trying to save a question with some tags, but the error message is
"Failed to convert property value of type java.lang.String to required type com.org.Tag for property tag; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.org.Tag] for property tag: no matching editors or conversion strategy found "
from my UI how can i send the list of Tags into QuestionController and how can i save Question with relationship with Tag
Your currently having
static hasMany = [tags:Tag]
But i believe you might be storing it directly as a string
questionInstance.tags = ['tag1', 'tag2',...]
as opposed to
questionInstance.tags = [new Tag(name: tag1), new Tag(name: tag2),...]
I skipped the looping through tag values to show you whats implied. Hope this helps.

Related Links

“grails.mongodb.default.mapping” equivalent in application.yml in Grails 3.2
TenantId is null when saving an entity in a Discriminator based multi tenant application in Grails 3.2 with GORM 6
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

Categories

HOME
server
include
tesseract
getelementsbytagname
programming-languages
filtering
spring-jdbc
baqend
wamp
networkx
amazon-cloudformation
slurm
gnupg
volttron
u-sql
postgres-xl
caml
pc
ef-migrations
google-static-maps
visual-composer
emulator
one-hot-encoding
mps
php-openssl
smb
url-scheme
traffic
greendao
c++-amp
lightswitch-2013
nameservers
exuberant-ctags
ioio
catel
fog
gesture
vapor
hilbert-curve
lumberjack
ibpy
estimote
midl
scorm
logparser
winscp-net
nstextview
r-forge
windows-iot-core-10
spring-cache
bind9
background-service
watchconnectivity
xcb
log4c
bonobo
dstu2-fhir
sigabrt
skype4py
bgp
pickadate
bluemix-app-scan
php-internals
oauth2client
goose
photobucket
javax.sound.midi
prerequisites
intellij-14
0xdbe
deis
service-accounts
event-bubbling
web-controls
python-green
dia
device-manager
internet-connection
eol
android-2.2-froyo
transcoding
cloud-connect
page-layout
oam
xsockets.net
web2py-modules
quickdialog
qtkit
hgsubversion
eclipse-templates
invite
gdlib
iphone-web-app
digest-authentication
virtual-functions
w3wp
post-build

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