Hibernate needs your default constructor to be present in order to create entity, since your constructor is hidden it cannot create your HomeEntity
.
Either constructor should be public or package visibility, hibernate should be be able to use setAccessible(true) // Note I havent tried package visibility option.
Hibernate and in general framework who create entity uses Class<T>.newInstance()
via reflection.
mappedBy means that mapping is done by the Owning side, the dependent need not define the mapping.
So in your case you will place mappedBy in Book
if you are defining mapping in HomeLibrary
or vice versa.
This post on SO speaks about creating objects via Factory method, you can use that to have your singleton object.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…