Erm, sorry everyone, but Hibernate does not require your classes to have a constructor without parameters. The JPA 2.0 specification requires this, and it is very weak on behalf of the JPA. Other frameworks like JAXB also require this, which is also very weak on behalf of these frameworks.
(In fact, JAXB supposedly allows founding companies, but he insists on creating these factories on their own, demanding that they have some kind of pointless designer, which in my book is just as good as not allowing the factories, like a llama!)
But Hibernate does not require such a thing.
Hibernate supports an interception mechanism (see "Interceptor" in the documentation ,) which allows you to create objects with any constructor parameters that they need.
Basically, what you do is that when you configure hibernate, you pass it an object that implements the org.hibernate.Interceptor interface, and hibernate will call the instantiate() method of that interface whenever it needs a new instance of the t object. e. Your implementation of this method can new your objects the way you like.
I did this in a project and it works like a charm. In this project, I do everything through JPA whenever possible, and I use only Hibernate features such as interceptor when I have no other choice.
Hibernate seems to be somewhat unsure of this, since at startup it gives an informational message for each of my entity classes, telling me INFO: HHH000182: No default (no-argument) constructor for class and class must be instantiated by Interceptor , but then I make an instance of them with an interceptor, and I am pleased with that.
To answer the question “why” in the question about tools other than Hibernate, the answer is “absolutely without good reason”, and this is confirmed by the presence of a sleep mode interceptor. There are many tools that could support some kind of similar mechanism for creating client objects, but they do not, therefore they create objects themselves, so they need to require constructors without parameters. I am tempted to believe that this is because the creators of these tools consider themselves programmers of ninja systems that create frameworks full of magic that will be used by uninformed application programmers who (as they think) would never have in their wildest dreams needed for such advanced designs as ... Factory Template . (Well, I have the temptation to think so. Actually, I don’t think so. I’m joking.)