views:

25

answers:

1

I have a legacy database table to map to with a grails app

I have to use a hibernate mapping file for a grails domain class in order to get some decimal precision values correct. I tried all sorts of tricky ways to do it with straight grails constraints and it is like herding cats. And so column size and precision value do not map quite right.

As an added bonus, the table has a composite key. It is for defining a relationship of postal codes in a country thus the country name and postal code are the parts for the composite key.

So I thought I would reverse eng a hibernate mapping file. It defines the right precision values and a composite id that matches what I want. So that part worked.

Now to get that to work properly with my grails app is proving troublesome.

The hibernate mapping file defines a "composite-id name ="id" class ="xxx.PostalCodeId"" that has the keys that are from the composite. If I create a grails class to hold these then le voila it works but there is another table called PostalCodeId which I do not want

I can get it to work if I want to have an extra table for the key value but I do not want that.

I guess my problem is really how to map a hibernate mapping file that has composite ids with a grails domain class.

A: 

thanks everyone for viewing this but I figured out an answer that works for my situation.

I did have some "finger" issues with the hibernate configuration file that exacerbated the problem.

I declared the composite key class in the same file as the domain and the hibernate mapping file picked it up and created one table with the right stuff. I can't included what I did here because the xml is not displayed (due to the blog's attempt to interpret as html).

Regards

Larry1