i have a class attendance like
public class Attendance implements Serializable
{
private Integer id,userId;
private Date date;
private OfficeTime officeTime;
private Set<TimeSlice> timeSlices;
public Attendance()
{
}
}
now i'm try to make two primary key's using hibernate mapping composite-id
<hibernate-mapping>
<class name="Attendance">
<composite-id>
<key-property name="id"><generator class="increment"/></key-property>
<key-property name="date" />
</composite-id>
<property name="userId" />
<set name="timeSlices" cascade="all" >
<key column="attendanceId" />
<one-to-many class="TimeSlice" />
</set>
<many-to-one name="officeTime" class="OfficeTime"
column="office_id" unique="true" not-null="true"
cascade="all" />
</class>
</hibernate-mapping>
while am doing like this i got error The content of element type "key-property" must match "(meta*,column*,type?)". how to set two primary key's and one must be increment automatically.Thanks in advance.
Your current configuration is not following the schema that is set for the composite-id element. Here is the schema doc for the composite id:
This is a sample configuration:
The documentation for this is here: https://docs.jboss.org/hibernate/orm/3.3/reference/en/html/mapping.html#mapping-declaration-compositeid