File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes many-to-one relationship to non-PK field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "many-to-one relationship to non-PK field" Watch "many-to-one relationship to non-PK field" New topic
Author

many-to-one relationship to non-PK field

Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
I'm trying to declare a foreign key relationship between two entities where the type is java.lang.String and the related entity field is not a primary key but is a unique field. If I attempt the same thing, but relating to a primary key field (by leaving off the property-ref attribute which defaults to the id), I have no problem.

I have narrowed down a test case in an attempt to solve this problem but to no avail. The problem is that 'schemaexport' will generate the two tables X and Y but will not create the relationship and I don't understand why (also, why it does the create the relationship when relating to a PK field). I am using the Microsoft type 4 driver for MS SQL Server 2000.

Please find below two source files annotated with XDoclet and corresponding mapping files. Any assistance is most appreciated.









Tony Morris
Java Q&A (FAQ, Trivia)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: many-to-one relationship to non-PK field