java - Hibernate seems to see private fields of entity -


we know that, private members not inherited in java, or more specifically, private member variables not visible in child class. so, if have super class follows :

 public class {        private int a;       public int b;   } 

and there other class b, extends follows:

 public class b extends a{} 

now have following code snippet:

 class b = new b();  system.out.println(b.a);    //  not possible since 'a' declared privtate  system.out.println(b.a);    // possible 

now, have following code using in hibernate tutorial. (example involves table_per_class strategy.) here code,

  public class vehicle {   @id   private int vehicleid;   private string vehiclename;    public string getvehiclename() {     return vehiclename;   }    public void setvehiclename(string vehiclename) {     this.vehiclename = vehiclename;   }    public vehicle() {     // todo auto-generated constructor stub   }    public int getvehicleid() {     return vehicleid;   }    public void setvehicleid(int vehicleid) {     this.vehicleid = vehicleid;   }  } 

and have twowheeler class follows:

 @entity  public class twowheeler extends vehicle {   private string steeringhandle;    public string getsteeringhandle() {     return steeringhandle;    }     public void setsteeringhandle(string steeringhandle) {     steeringhandle = steeringhandle;    }  } 

when run code, twowheeler table created following columns:

 +-----------+-------------+----------------------+  | vehicleid | vehiclename | steeringhandle       |  +-----------+-------------+----------------------+  |         2 | bike        | bike steering handle |  +-----------+-------------+----------------------+ 

but vehicleid , vehiclename private members of vehicle class. how inherited in hibernate when tables created in database?

hibernate accesses fields using getters , setters methods... public


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -