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

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
Domain class auto validation in grails

Categories

HOME
testng
pypi
azure-data-factory
fft
google-docs
yahoo-oauth
baqend
windows-server
ios-charts
nano-server
php-7.1
timeout
gz
event-handling
workload-scheduler
beyondcompare
zapier
csrf-protection
tapestry
react-css-modules
nameservers
iframe-resizer
semantic-versioning
fog
usbserial
stringtemplate
bower-install
automake
swift3.0.2
objectlistview
hp-ux
sencha-touch-2.3
segment
galleria
azure-application-gateway
hls.js
kbuild
nodebb
windows-mobile-6.5
arrow-keys
spring-android
libpng
httplistener
intrusion-detection
bgp
itextpdf
two-factor-authentication
ios8-today-widget
maven-tomcat-plugin
eclipse-clp
qdialog
mutation-observers
spidermonkey
deis
event-bubbling
dundas
apache-commons-net
geonetwork
formatjs
gwidgets
socketexception
titanium-modules
websocket4net
inbox
coverflow
jplaton
pushbackinputstream
sqlperformance
lcs
path-separator
jspinclude
libc++
coercion
ecl
xfbml
coda-slider
nsviewanimation
nintendo-ds
memory-size
ugc

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App