Hibernate version: 3
Mapping documents: Annotations
Hi! I have what I think is a quite common situation and I'm just not able to find the appropriate mapping for it. It's a legacy (read, unnormalized) manytoone relationship between two tables that represents a single entity. This is a simplification of the situation:
Code:
CREATE TABLE cities
(id varchar(8) primary key,
name varchar(32), region char(4))
example: BAR87432, "Barcelona", "CAT"
Code:
CREATE TABLE territories
(regionCode varchar(12) primary key, region char(4))
example: CATA12345678, CAT
Code:
class City {
String id; <-- city
String name; <-- city
String regionCode; <-- territory
}
As you can see, the join is performed over an unique but non-primary-key field (region) and the only property I want to set is the regionCode string value.
Secondary tables doesn't work and I'm just not able to map a ManyToOne because the target property is a String.
Any help would be very appreciated :-)
jv