开发者

Hibernate update with default value

after some research i haven't found a solution. I need a query like this in Hibernate:

UPDATE table_name SET field=DEFAULT

it's possible to instruct hibernate to generate that query when I need to generate database default value on an update?

I have already try setting insert="false" and update="false", but this work only for insert que开发者_开发百科ry, when I perform an update simply hibernate doesn't set the field annotated with update="false".

Thank you in advance


There is probably some much better sequence to get to the default value but I'm rusty on Hibernate.

PersistentClass pClass 
    = configuration.getClassMapping(yourJavaClass.class.getName());
Column col = pClass.getTable(getColumn("Column Name in Table"));

Now you can use col.getDefaultValue() and replace nulls with it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜