gorm


How to save GORM class with composite id made from its own field?


This is my Domain class
class ReturnReason implements Serializable {
Long returnReasonId
Long languageId
String name
int hashCode() {
def builder = new HashCodeBuilder()
builder.append returnReasonId
builder.append languageId
builder.toHashCode()
}
boolean equals(other) {
if (other == null) return false
def builder = new EqualsBuilder()
builder.append returnReasonId, other.returnReasonId
builder.append languageId, other.languageId
builder.isEquals()
}
static mapping = {
id composite: ["returnReasonId", "languageId"]
version false
}
static constraints = {
name maxSize: 128
}
}
This is my controller code to save my domain class.
def save() {
ReturnReason returnReasonInstance = new ReturnReason(params)
returnReasonInstance.languageId = 1
if (!returnReasonInstance.save(flush: true)) {
render(view: "create", model: [returnReasonInstance: returnReasonInstance])
}
redirect(action: "list")
}
While trying to save in my controller than there is a error in returnReasonId ,i.e returnReasonId rejected value null. How to fix it.??
write validate:false in save action
def save() {
ReturnStatus returnStatusInstance = new ReturnStatus(params)
returnStatusInstance.languageId = 1
if (!returnStatusInstance.save(validate: false, flush: true)) {
render(view: "create", model: [returnStatusInstance: returnStatusInstance])
}
redirect(action: "list")
}

Related Links

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
Script for saving large no of entries in mongodb
Does the multiple datasource feature of Grails 2.0 support relations?
How to avoid ImprovedNamingStrategy in joinTable in Grails
Grails 2 Show transient property that is an alias for id column
How to save GORM class with composite id made from its own field?
Grails - 2 domains and 1 form create/update/edit issues

Categories

HOME
twitter
azure-data-factory
comparison
homebrew
hashmap
lodash
office365api
alpha
fancybox
add
midi
modelica
postgres-xl
google-cloud-spanner
moonmail
windows-phone-7
dynamics-crm-online
undefined
flux
normalizr
jqwidget
text-rendering
lldb
visjs
riot.js
tar
tibco-mdm
opennlp
tdd
sparse-matrix
fgetcsv
fifo
atlassian-crucible
skia
exuberant-ctags
noraui
android-nestedscrollview
normal-distribution
hexo
bower-install
ios5
hockeyapp
libvpx
sfdc
nomethoderror
spring-security-kerberos
btrace
smartcontracts
dandelion
typescript1.8
powercli
directory-structure
sqlclient
qtwebview
iso8601
dynamics-sl
crosswalk-runtime
quartz-composer
url-pattern
libpng
savon
google-web-starter-kit
ctest
contact-list
markojs
hover-over
pagerank
browser-link
natvis
hsv
pervasive-sql
prerequisites
map-projections
ideamart
proj4js
network-interface
nsbutton
zend-route
heisenbug
rebol3
rtmfp
cdc
gwt-rpc
back-stack
orchardcms-1.7
sharp-repository
selected
e4x
unc
postgresql-performance
spring-portlet-mvc
deobfuscation
coercion
datareader
telerik-scheduler
gallio
gamequery
perfect-hash
fixed-width
photoshop-cs4
virtual-functions
anti-piracy
dbisam
multiple-languages
commodore
ntvdm.exe

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