Hi,
i got 2 tables wich look like the following.
table Organization (orgId (pk), orgName)
table Employee (empId, empName, fk_orgId)
This is a one (Organization) - to - many (Employee) relationship.
I'd like to have a bidirection relation here, what causes me to insert the following method in the Organization class, i'd like to have all the employees for a specific company (i know that i can get this data from a find query in Employee class, but i'd like to make it this way - straigth call).
Code:
public Set getEmployees()
Naturally, this method doesn't map to a physical field.
I'm trying to use this mapping on Organization.hbm.xml
[code]
<set
name="employees"
lazy="true"
inverse="false"
cascade="none"
sort="unsorted"
order-by="firstName"
>
<key column="fk_orgId"/>
<one-to-many
class="hibernate.Employee"
/>
</set>[/code
But i get a null pointer exception when trying to access it in the following way.
[code]
Set org10Employees = org1.getEmployees();[/code]
Does anyone know what i'm doing wrong???
Thanks,
ltcmelo