Default constructor in domain model subclass not called?

View: New views
1 Messages — Rating Filter:   Alert me  

Default constructor in domain model subclass not called?

by Philip Luppens :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello everyone,

I'm sure this is a very well known issue, but for the heck I cannot find me any more information about it, so I'm posting it here. I have a simple domain class called Foo, with some fields (say, name and description). I created a subclass called Bar which has a default constructor that amongst other things, sets these name and description fields. Strangely enough, I cannot get this constructor to be invoked (and thereby the fields set). def bar = new Bar() invokes the superclass Foo's constructor, but never Bar's constructor. Even stranger, the class of bar is Foo, and not Bar. I'm puzzled, because it works fine when I have a non-default constructor (meaning at least one argument).

What am I missing here? How can I use a default constructor from a subclass ?

Kind regards,

Philip