Hi all folks ,
I want to ask about my design decision ,
There are people and roles at my project. People are like a inspectors , doing inspect and writing reports.
I have a table for inspections reports , for instance Inspections and there are details for these inspections.But all details are different.
One inspect is type1 , other type2 , other type3 , and etc.
When they save a inspection also they must save deatils.
Inspection bean is easy , time , people , inspector , place , city , etc.etc properties..
But how can I implement detail(s) bean ? I think that I write a bean for details and all details with all kinds (type1 , type2 , there will be many , etc..) can be subclasses of these bean.And at Inspection bean I do like this :
class Inspection {
private String inspector; private String city; private Date date; ...... ....etc.etc.. private Detail _detail;
}
class Detail { }
class DetailType1 extends Detail{ private String type1_special_field; ...etc.etc.... }
class DetailType2 extends Detail{ private int type2_special_field; ...etc.etc. }
class DetailType3 extends Detail{ private long type3_special_field; ... etc.etc. }
When I want to save Inspection and it's details , for instance type3 details ,
... start code ...
Inspection ix = new Inspection(); ix.setX(....); ix.setEtc(...); Detail detx = new Detail(); detx.setType3_special_field(...); detx.setEtc(.....); ix.setDetail(detx);
.... end code ...
I think I can use "Table Per Class" poliymorphism strategy , I can save details one table and when I read a Inspection I can get detail without sorry about detail type is which kind.
???
And when I show inspection and details how do I build a HQuery ?
I need some example mapping and code. I ' m begginer Hibernate user , now I ' m using with many-to-one , and all basic properties.No problem for them.I have read Hibernate doc and looked at forums.
If these are reply or so easy , please excuse me.
Thanks from now.
Mehmet ,
|