Hibernate version: 3.1
I need to import data only and did not want to use a join to read the data.
The problem is I did not managed to figure out a working mapping for my problem. The tables are coming from oscommerce and are IMHO not properly designed.
an attribute can have options in multiple languages. So option has a composite-pk of products_options_id,language_id.
I cannot find a solution to define a relation between attribute and option because the column products_options_id of product_options does not point to the primary key of products_attributes but to another column. The expected behaviour of normal many to many mappings is that the foreign key does always point to the primary key of a table.
Does anybody have an idea?
Best Regards Sebastian
Code:
CREATE TABLE `shop`.`products_attributes` (
`products_attributes_id` int(11) NOT NULL auto_increment,
`options_id` int(11) NOT NULL default '0',
PRIMARY KEY (`products_attributes_id`),
) ;
-- hint: options_id has a relation to products_options_id
CREATE TABLE `shop`.`products_options` (
`products_options_id` int(11) NOT NULL default '0',
`language_id` int(11) NOT NULL default '1',
`products_options_name` varchar(32) collate latin1_german1_ci NOT NULL default '',
PRIMARY KEY (`products_options_id`,`language_id`)
);
CREATE TABLE `shop`.`languages` (
`languages_id` int(11) NOT NULL auto_increment,
`name` varchar(32) collate latin1_german1_ci NOT NULL default '',
PRIMARY KEY (`languages_id`)
);