Hi NG!
I've just browsed the Hibernate-FAQ on
www.hibernate.org a bit:
In the section "Common Problems" there are two questions:
*************************************************
Q1:
I get org.hibernate.HibernateException: CGLIB Enhancement failed: <classname>?
A1:
If you use lazy loading with proxies (default for all classes in Hibernate 3), Hibernate needs to subclass your class at runtime. It can't do this if you have a private no-argument constructor. As per documentation, at least package visibility is required.
A bit further is another question:
Q2:
Hibernate is nontransparent because it requires me to have a default constructor which breaks the API of my class!
A2:
You may declare the constructor private. (Same goes for any property accessors.)
*************************************************
So, what is the truth? May I or may I not declare my default constructor private?
Berti