Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.1.2
Mapping documents:
from document 1.3.4
Code:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.tanabe.hibernate.pojo.Person" table="person">
<id name="id" column="person_id">
<generator class="native"/>
</id>
<property name="age"/>
<property name="firstName"/>
<property name="lastName"/>
<set name="emailAddresses" table="person_email_addr">
<key column="person_id"/>
<element type="string" column="email_addr"/>
</set>
</class>
</hibernate-mapping>
The generated SQL (show_sql=true):
create table person_email_addr (person_id bigint not null, email_addr varchar(255))
alter table person_email_addr add constraint FKBC8ADDEF605C68A foreign key (person_id) references person
in chapter1.3.4
it says "You can see that the primary key of the collection table is in fact a composite key, using both columns. This also implies that there can't be duplicate email addresses per person, which is exactly the semantics we need for a set in Java."
but the sql generated by schemaexport doesnt look like it.
there is just one foreign key for person_id,
but no primary key constrain for person_email_addr table.
or its my miss understanding?