Hi all,
im new to this forum and also for using hibernate. i hope i can find answers from the experts here. i'm solving this problem 2 days now and i haven't found the cause yet. the situation is: i have an employee which is the parent and employeetimesheet is the child. now when i inserted data to both tables the all fields in child has value aside from the employeeId field. my mapping look like these:
employee.hbm.xml
Code:
<hibernate-mapping>
<class name="com.xxx.Employee" table="employees">
<id name="employeeId" type="long" unsaved-value="0">
<generator class="native"/>
</id>
<property name="firstName" type="string" length="25" not-null="true"/>
<property name="middleName" type="string" length="25" not-null="true"/>
<property name="lastName" type="string" length="25" not-null="true"/>
<property name="fullName" type="string" length="100"/>
<many-to-one name="shiftSchedule" column="shiftScheduleCode" class="com.xxx.ShiftSchedule" cascade="save-update"/>
<set name="employeeTimesheets">
<key column="employeeId"/>
<one-to-many class="com.xxx.EmployeeTimesheet"/>
</set>
</class>
</hibernate-mapping>
employeetimesheet.hbm.xml
Code:
<hibernate-mapping>
<class name="com.xxx.EmployeeTimesheet" table="employee_timesheets">
<id name="employeeTimesheetId" type="long" unsaved-value="0">
<generator class="native"/>
</id>
<property name="shiftScheduleCode" type="string" length="10" not-null="true"/>
<property name="timesheetDate" type="date"/>
<property name="timeIn" type="timestamp"/>
<property name="timeOut" type="timestamp"/>
<property name="activityType" type="string" length="50"/>
<property name="duration" type="long"/>
</class>
</hibernate-mapping>
i dont know where ive done wrong. any help is appreciated.
regards,
think