The "id" field is probably fine but wouldn't exist in "Person" class. It looks as if the Vaadin code builds a map
of the properties of the class passed in via the constructor. Hence requires the mixin with SurrogateIntId
BTW the approach of using the abstract class didn't work in the end because the Vaadin code to add
the bean doesn't like it when the object being added doesn't match the class passed in the constructor.
Even though the abstract class and the bean being added are "Person with SurrogateIntId" they are
seen as different classes.
Anyway the following code works without having to solve my original issue and at the moment seems
sufficiently robust and minimal that, other than for academic interest, I won't bother pursuing how to
achieve "classOf[Person with SurrogateIntId]"
p.setContainerDataSource(new BeanContainer[Int, Person](classOf[Person]) {
import com.googlecode.mapperdao.Query.{ select => dbselect }
val p = personEntity
val query = dbselect from p orderBy p.surname
val persons = queryDao.query(query)
persons foreach { person =>
}
})
The Vaadin "addItem()" as opposed to "addBean()" allows manual specification of the "id" and avoids the
original problem.
BTW would be interested if you know a better way to solve the problem causing me to use "dbselect"
instead of "select" in the query. Had me stumped for a while as to why "select" wouldn't work. Turns out
that this code is in a subclass of Vaadin's ComboBox that has a "select" method defined. Without doing
the mapperdao import again (it was already done at the start of the file) then scala assumes this to be the
ComboBox select method. If I just reimport mapperdao without the rename then scala complains about
an ambiguous reference.
Renaming the mapperdao select as in the code above works. But in this particular code I'm not likely to use
the ComboBox "select" method and would prefer "select" to be the mapperdao one. Any idea how I would
force scala to interpret "select" as the mapperdao one rather than the method from a superclass? Just using
"import com.googlecode.mapperdao.Query.select" still complains of ambiguous reference.
REGARDS
Peter