开发者

How to implement capitalization in nHibernate?

The below MS-SQL update script capitalizes the first letter of a word.

How does this statement look 开发者_如何学Golike in nHibernate HQL (criteria also ok) ?

UPDATE T_Example  
SET LANG_DE = UPPER(LEFT(LANG_DE, 1)) + RIGHT(LANG_DE, LEN(LANG_DE) - 1) 


hibernate hql supports also a function called upper()

see: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html


You can just calculate the value of LANG_DE in code and pass the value for the update?


Seems like I just have to replace left and right with substring, and len with length.
Looks like this then:

UPDATE T_Example  
    SET MT_Lang_DE = upper(substring(MT_Lang_DE, 1, 1)) + substring(lower(MT_Lang_DE), 2, length(MT_Lang_DE)-1)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜