im newbie in grails. I use three Domain Class Books, Customers and Rents.
My Question:
It is possible if i create a new rent (the rent create use private key from Domain Class Customers and Books) and before i save the new rent that i change a field value in Domain Class Books?
Example: I create a new rent. A rent use the Data from the Customer and the Book that customer want rent. If the rent is create the value for book count should reduce for this rent book (Example from 15 to 14 books).
If this possible how should i do this. I test with this in Controller Rent
def changeBooks(Long id) {
def p=Books.get(id)
p.properties
Books.executeUpdate("update Books p set p.anzahl=anzahl -1")
redirect view:'edit'
but i get the message
URI
/rents/changeBooks
Class
java.lang.NullPointerException
Message
null
Caused by
Cannot get property 'properties' on null object
Wow! This can be one particular of the most useful blogs We’ love ever arrive across on this subject. Actually Excellent. I am also a specialist in this topic, therefore, I can understand your effort.
t rex game