-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: table mapping
PostPosted: Mon Oct 30, 2006 2:58 am 
Newbie

Joined: Mon Oct 30, 2006 2:31 am
Posts: 8
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


Top
 Profile  
 
 Post subject: mapping tables
PostPosted: Mon Oct 30, 2006 4:21 am 
Newbie

Joined: Mon Oct 30, 2006 2:31 am
Posts: 8
i just found out the cause and the solution of my mapping. i add cascade="all" in employee.hbm.xml and <many-to-one> ni employeetimesheet.hbm.xml

moderator, pls close this thread...

tnx


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.