views:

194

answers:

1

Hi,

I have a problem in Grails 1.1.2 + MySQL.

My domain class Something contains field

Map<String, Map<Integer, Integer>> priceMap

When I run the app, Grails creates table 'something' and sub-table 'something_price_map'. 'something_price_map' contains

BIGINT(20) price_map
VARCHAR(255) price_map_idx
TINYBLOB price_map_elt

The problem is that when I fill-in the column priceMap even with small map data like this 'priceMap:[en:[100:4, 500:20, 600:24]]', the size of the data exceeds the limit of 255bytes.

Is there any way of specifying maxSize constraint for the inner map (Map), so that Grails uses MEDIUMBLOB or BLOBK instead of TINYBLOB?

Btw... Using in-mem DB, everything works fine.

+1  A: 

As you may know, there is a mapping constraint for a domain class. However, your issue may be too complex for that functionality.

In such cases, you can specify an explicit Hibernate mapping (via hbm file) for a domain class. This allows the complete flexibility of Hibernate.

Michael Easter
Yeah, that's the problem - the complexity. For simple map I could use maxSize constraint, but I need to specify the maxSize for inner map.Thanks for recommendation of hbm file. If I don't find better solution, I will try this one.
Pavel P