在EJB3.0代碼里直接用select new EntityClass(p.attr1,substring(p.attr2),...) .....報錯,說不能識別“(”,估計就是substring后面的“(”,難道是EJB QL沒這種語法?
在網(wǎng)上找這樣的代碼或?qū)崿F(xiàn)方法未果,查
EJB 3.0規(guī)范,里面有一個EJB QL的范式描述,原來在QL里只能在where條件里使用字符串函數(shù),在select new里估計是不行了,后來想到
select new 要調(diào)用EntityClass的構(gòu)造函數(shù)來構(gòu)建EntityClass實例,所以考慮在EntityClass的構(gòu)造方法里調(diào)用substring等方法,實踐之,執(zhí)行成功,mark!
(文章短了點,但如果能解決別人的問題,也是不錯的。post完繼續(xù)寫程序,hoho)
版權所有 羅明