I think this explains my question well enough:
public class Model {
public static Model [] findAllBySQL(String SQL){
//this is simplified. It should really query the DB and then fill model(s) with the DB values, and return the model(s). sql query can return more than one row
return new this(); //sytax error here
}
}
public class UserModel extends Model {
}
UserModel.findAllBySQL("firstname=john") //How do I design the above so this returns a UserModel object?
I'm relatively new to Java. My background is mostly PHP. I am trying to create a simple home-made active record system.. I know this is recreating the wheel, but that's how I learn :)
EDIT: Most of you guys misunderstood me. I know how to simple to new UserModel()
. I changed the code to make it more clear.