开发者

How to force Grails to use proper column type in MySQL for Map field

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 'somethin开发者_开发技巧g_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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜