Reputation: 3581
I have this domain model, grails-app/domain
, named com.portal.Schedule.groovy
having this properties:
Subject subject
Room room
Day day
Time timeStart
Time timeEnd
static embedded = ['timeStart', 'timeEnd']
Where in the object com.portal.Time
is located in the src/groovy
having this properties:
Integer hour
Integer minute
public Time(Integer hour, Integer minute) {
super();
this.hour = hour;
this.minute = minute;
}
The problem is when I want to add a record using the BootStrap.groovy
having this syntax:
new Schedule(subject: Subject.get(1), room: Room.get(1), day: Day.MON,
timeStart: new Time(9, 0), timeEnd: new Time(11, 00)).save(failOnError: true)
I get this error message prior to finish to start-up:
Message: No default constructor for entity: com.portal.Time; nested exception is org.hibernate.InstantiationException: No default constructor for entity: com.portal.Time
How can I resolve this to have my Bootstrap.groovy
running with the instance of Schedule
with those attributes?
Upvotes: 1
Views: 695
Reputation: 3581
I've searched it thoroughly on Google how to solve this problem.
It's seems groovy
has almost the same feature with python
regarding constructor or in other terms tuples
in Python located here
After inserting the annotation to the class Time
I can now code the constructor in multiple ways.
Upvotes: 0
Reputation: 528
Your Time constructor is set to private. That's why you're getting that error.
Upvotes: 1