Hi all,
I have a question it may sound pretty naive to all of you guys but i am trying it from last 2 days.
I am trying to implement one-to many relationship using hibernate below is my mapping file
i need a query which will select all the managers and employees work for them
which collection set i can use for it?
can i do it in one query or first i have to get all the managers and then get emplyees one by one for each manager and store them in a list.
i think i can do it with hash table where manager will be the key representing all the employee belongs to him.. but i doono how to implement it.
can someone please give me some direction and the query?
I have a question it may sound pretty naive to all of you guys but i am trying it from last 2 days.
I am trying to implement one-to many relationship using hibernate below is my mapping file
Code:
<class name="ManagerDTO" table="Manager"> <id name="managerId" type="int" column="manager_id"> <generator class="native"/></id> <set name="managerToEmployee" cascade="all" inverse="true"> <key column="manager_ide"/> <one-to-many class="EmployeeDTO"/> </set> <property name="managerName" type="string" column="manager_name" length="255" not-null="true"/> </class> <class name="EmployeeDTO" table="Employee"> <id name="emploeeId" type="int" column="employee_id"> <generator class="native"/></id> <property name="employeeName" type="string" column="employee_name" length="255" not-null="true"/> <many-to-one name="managerToEmployee" column="manager_ide" lazy="false" class="ManagerDTO"/> <!--<many-to-one name="enrolledDTO" column="sectionId" lazy="false" class="SectionDTO" fetch="join"/> --> </class>
which collection set i can use for it?
can i do it in one query or first i have to get all the managers and then get emplyees one by one for each manager and store them in a list.
i think i can do it with hash table where manager will be the key representing all the employee belongs to him.. but i doono how to implement it.
can someone please give me some direction and the query?