I have a normal Java class BaseModel
as below
@AllArgsConstructor
class BaseModel {
private String id;
}
Now I want to extend this in scala case class. Below is giving error:
case class Employee(id: String, dept: String) extends BaseModel(id)
Error: too many arguments for constructor BaseModel: ()
EDIT1: I have also tried with explicit constructor as below:
class BaseModel {
private String id;
public BaseModel(String id) {
this.id = id;
}
}
Now with this, it throws an error at compile time value id needs override modifier
. When I try to add override modifier, it is throwing a compile-time error in the Scala class.
case class Employee(override val id: String, dept: String) extends BaseModel(id)
The error is for id
.
Pls help me how can I fix this?