java - Entity class must have non argumented constructor -


i studying jpa, while studying on jpa blog vogella 1.2 entity heading, came across line says:

all entity classes must define primary key, must have non-arg constructor , or not allowed final

i not able understand line. need write non-argumented constructor, because default non argumented constructor inherited classes.

what mean not allowing final, mean can extend entity class? if why compulsion, why can not final

by default, non arg constructor when there no constructor defined in class has nothing jpa. yes if defining constructor, have define no arg constructor like:

 public class student {       public student() {}//default ctor needed jpa convert row db java object       public student(int id) {..}//ctor accepts 1 arg  } 

making class final meaning can't subclass. jpa vendor's hibernate creates proxy lazily fetch rows limit options performance tuning. hence see class may/may not final depending on use case.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -