The issue I'm facing is that when creating a query with SELECT, Hibernate expects the existence of a specific constructor that corresponds to the parameters given in SELECT. For example, if I specify that I'm only interested in id (long) and model (String) columns in my BasicInfo class, then Hibernate attempts to find and call BasicInfo(int, String) constructor. This is indicated by the error message shown below:
I'm looking for a way to force Hibernate to use a default class constructor and then using the setters of requested fields. If not that, maybe there is another way that would allow to not retrieve full row data from the database when each request is made (and then limiting it in the application code before sending back to the client).
Yes, it is worthwhile, because I want to create a generic solution, not only for a specific use.
So is there any way to achieve that goal?
TBH, I don’t think the request makes sense. It even has bad side effect. Creating a corresponding constructor makes more sense and is not a big deal, IMHO.
Yes, it does make sense when we want to create a generic API implementation. My goal is to pass the list of selectors linked to a particular data class, not having prepared previously this class for this very list of selectors.
Again, this is a feature request, not a bug. IMHO, it is not a generic feature (arguably it doesn’t make sense for constructor with parameter != default constructor + setter). You can achieve the goal without modifying Hibernate, I think.