My domain layer looks like that:
@Resource(uri='/product')
class BasicProduct {
String title
String description
Double price
Date creationDate
Date changedDate
static constraints = {
//everything is by default NotNull
title(blank: false, unique: true)
description(blank: false)
price(blank: false, inList: [5,15,25,50,100])
creationDate(min: new Date())
}
}
My Bootstrap.groovy
contains that code:
class BootStrap {
def init = { servletContext ->
new BasicProduct(title: "Product1", description:"blblblblbalablablalbalbablablablablblabalalbllba", price:5).save()
new BasicProduct(title: "Product2", description:"blblblblbalablablalbalbablablablablblabalalbllba", price:75).save()
new BasicProduct(title: "Product3", description:"blblblblbalablablalbalbablablablablblabalalbllba", price:50).save()
new BasicProduct(title: "Product4", description:"blblblblbalablablalbalbablablablablblabalalbllba", price:25).save()
new BasicProduct(title: "Product5", description:"blblblblbalablablalbalbablablablablblabalalbllba", price:15).save()
println "initializing data..."
}
However when I open the \product
url I do not see any data.
Any ideas why?
I appreciate your answer!
For your dates you can do:
Date dateCreated
Date lastUpdated
static mapping = {
autoTimestamp true
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With