3.0:
This is a simple parent-child relation
Mapping documents:
in "Source"
Code:
<set name="jobs" order-by="firstSeen" inverse="true">
<meta attribute="field-description">
Jobs from this source
</meta>
<key column="source_id"/>
<one-to-many class="jobfinder.data.Job"/>
</set>
in "Job":
Code:
<many-to-one class="jobfinder.data.Source" name="source" column="source_id" lazy="false">
<meta attribute="field-description">
Where job found
</meta>
</many-to-one>
ExportSchema generates the following contraints on "job"
Code:
alter table job
add constraint FK19BBD79457373
foreign key (source_id)
references source;
alter table job
add constraint FK19BBDAB343541
foreign key (contact_id)
references contact;
alter table job
add constraint FK19BBD99AD0491
foreign key (job_id)
references source;
The first two are fine but I don't understand where the third is coming from. I was unable to save job entities until I dropped this extra constraint.
job_id is, of course, the synthetic key of the job table and definitely doesn't point to source.
Name and version of the database you are using:
Postgressql