The goal is to bind URLs.
Using the following sql,
CREATE TABLE `profiles` (
`id` serial ,
`url` varchar(256) ,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `linked_profiles` (
`profile` bigint unsigned references profiles(id),
`linked` bigint unsigned references profiles(id),
PRIMARY KEY (`profile`, `linked`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
This is a sleep mode mapping.
<hibernate-mapping>
<class name="LinkedProfiles" table="linked_profiles">
<composite-id>
<key-property name="profile" column="profile" type="long" />
<key-property name="linked" column="linked" type="long" />
</composite-id>
<one-to-one name="profile" class="Profile" cascade="save-update">
</one-to-one>
<one-to-one name="linked" class="Profile" cascade="save-update">
</one-to-one>
</class>
<class name="Profile" table="profiles">
<id name="id" type="long">
<column name="id" not-null="true"/>
<generator class="identity"/>
</id>
<property name="url" type="java.lang.String">
<column name="url"/>
</property>
</class>
</hibernate-mapping>
Purpose: Each unique url will have one entry in the "profiles" table. "Linked_profiles" refers to two URLs.
This leads to this exception.
org.hibernate.MappingException: displaying a broken column for: profile.id of: LinkedProfiles
Is this a defect in hibernate? See https://hibernate.atlassian.net/browse/HHH-1771
source
share