开发者

How to implement capitalization in nHibernate?

开发者 https://www.devze.com 2023-02-04 13:08 出处:网络
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) ?

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

精彩评论

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

关注公众号