I have question on ORM. I have two tables and want to create one object- java class based on them. I have specific requirement to write class in below fashion.
Table: ComputerFranchise Fields: id - number (primary key) address - varchar2
ComputerType Fields: computerName: varchar2 compFranchiseId: number (foreign key referencing to id of computerFranchise) dailySales: number
Based on above tables i want to create single java class with below fileds and methods.
@Entity public class ComputerFranchise {
@Id int id; public int getId(){..} public void setId(int id){..}
@Column String address; public String getAddress(){} public void setAddress(String add){..}
HashMap dailysales<String,Integer> - This is hashmap of computertype mapped to thier daily sales per franchise, and should be sorted by computername. What annotations should i use to create this hashmap and here real question is i don's want to create javaclass for ComputerType? Should i use secondary table concept or should i use read only query or is there better to create this field?
public HashMap getDailySales() { .. }
public void setDailySales(HashMap map) { ... }
}
So question is best way to create dailysales hasmap filed and operation on it. How should i map this filed to table and what annotations should i use?
Thanks in advance for any suggestions/pointers.
|