今天周末,被头儿过来改bug
其中一个在hql查询的时候报org.hibernate.hql.ast.QuerySynt
axException: unexpected token: ApplyInfo near line 1, column 23这样的错误,貌似看起来hibernate不认识ApplyInfo这个映射持久类,但是这个类非常确定的是已经映射了,而且在别处用的非常正常。郁闷,找啊找
在网上找org.hibernate.hql.ast.QuerySynt
axException: unexpected token的错误有
1、持久类写错了,要不就是写成了数据库表名
2、hibernate3.0不支持select中嵌套查询,据说from中也不行,只支持where中嵌套查询,好像3.1支持了select中嵌套
3、sql语句中字段是用了保留关键字
然后就是我发现的这个隐蔽错误了
发现的from后的空格是一个全角的空格,半角
空格,全角
空格。距离比一样啊,原来就看出from后面的空格大了,还以为是两个空格呢。
隐蔽,太隐蔽了。
org.hibernate.hql.ast.QuerySynt
axException: unexpected token: ApplyInfo near line 1, column 23 [SELECT contCount FROM ApplyInfo where applyId = (select applyId from com.capinfo.hibernate.person
.pojo.AContinueInfo where id=25)]
at org.hibernate.hql.ast.ErrorCoun
ter.throwQueryException(ErrorCounter.java:59)
at org.hibernate.hql.ast.QueryTran
slatorImpl.parse(QueryTranslatorImpl.java:244)
at org.hibernate.hql.ast.QueryTran
slatorImpl.doCompile(QueryTranslatorImpl.java:155)
at org.hibernate.hql.ast.QueryTran
slatorImpl.compile(QueryTranslatorImpl.java:109)
at org.hibernate.engine.query
.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
at org.hibernate.engine.query
.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
at org.hibernate.engine.query
.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.AbstractSess
ionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
at org.hibernate.impl.AbstractSess
ionImpl.createQuery(AbstractSessionImpl.java:113)
at org.hibernate.impl.SessionImpl
.createQuery(SessionImpl.java:1602)
at com.capinfo.zgbm.print.dao
.PrintQueryDAO.getContinueCount(PrintQueryDAO.java:273)
at com.capinfo.zgbm.print.action
.PrintContinueCountAction
.execute(PrintContinueCountAction.java:95)
at org.apache.struts.action
.RequestProcessor.processAction
Perform(RequestProcessor.java:484)
at org.apache.struts.action
.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action
.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action
.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet
.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet
.service(HttpServlet.java:856)
at weblogic.servlet.internal
.StubSecurityHelper$ServletServ
iceAction.run(StubSecurityHelper.java:225)
at weblogic.servlet.internal
.StubSecurityHelper.invokeServl
et(StubSecurityHelper.java:127)
at weblogic.servlet.internal
.ServletStubImpl.execute(ServletStubImpl.java:283)
at weblogic.servlet.internal
.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal
.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at com.capinfo.util.LoginFilter
.doFilter(LoginFilter.java:61)
at weblogic.servlet.internal
.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at com.capinfo.util.SetCharacterEn
codingFilter.doFilter(SetCharacterEncodingFilter.java:67)
at weblogic.servlet.internal
.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal
.WebAppServletContext$ServletIn
vocationAction.run(WebAppServletContext.java:3212)
at weblogic.security.acl.internal
.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service
.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal
.WebAppServletContext.securedEx
ecute(WebAppServletContext.java:1983)
at weblogic.servlet.internal
.WebAppServletContext.execute(WebAppServletContext.java:1890)
at weblogic.servlet.internal
.ServletRequestImpl.run(ServletRequestImpl.java:1344)
at weblogic.work.ExecuteThread
.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
Caused by: line 1:23: unexpected token: ApplyInfo
at org.hibernate.hql.antlr
.HqlBaseParser.identPrimary(HqlBaseParser.java:4021)
at org.hibernate.hql.antlr
.HqlBaseParser.primaryExpressio
n(HqlBaseParser.java:861)
at org.hibernate.hql.antlr
.HqlBaseParser.atom(HqlBaseParser.java:3422)
at org.hibernate.hql.antlr
.HqlBaseParser.unaryExpression(HqlBaseParser.java:3200)
at org.hibernate.hql.antlr
.HqlBaseParser.multiplyExpressi
on(HqlBaseParser.java:3082)
at org.hibernate.hql.antlr
.HqlBaseParser.additiveExpressi
on(HqlBaseParser.java:2802)
at org.hibernate.hql.antlr
.HqlBaseParser.concatenation(HqlBaseParser.java:570)
at org.hibernate.hql.antlr
.HqlBaseParser.relationalExpres
sion(HqlBaseParser.java:2586)
at org.hibernate.hql.antlr
.HqlBaseParser.equalityExpressi
on(HqlBaseParser.java:2449)
at org.hibernate.hql.antlr
.HqlBaseParser.negatedExpressio
n(HqlBaseParser.java:2413)
at org.hibernate.hql.antlr
.HqlBaseParser.logicalAndExpres
sion(HqlBaseParser.java:2331)
at org.hibernate.hql.antlr
.HqlBaseParser.logicalOrExpress
ion(HqlBaseParser.java:2296)
at org.hibernate.hql.antlr
.HqlBaseParser.expression(HqlBaseParser.java:2082)
at org.hibernate.hql.antlr
.HqlBaseParser.aliasedExpressio
n(HqlBaseParser.java:2249)
at org.hibernate.hql.antlr
.HqlBaseParser.selectedProperti
esList(HqlBaseParser.java:1455)
at org.hibernate.hql.antlr
.HqlBaseParser.selectClause(HqlBaseParser.java:1365)
at org.hibernate.hql.antlr
.HqlBaseParser.selectFrom(HqlBaseParser.java:1106)
at org.hibernate.hql.antlr
.HqlBaseParser.queryRule(HqlBaseParser.java:702)
at org.hibernate.hql.antlr
.HqlBaseParser.selectStatement(HqlBaseParser.java:296)
at org.hibernate.hql.antlr
.HqlBaseParser.statement(HqlBaseParser.java:159)
at org.hibernate.hql.ast.QueryTran
slatorImpl.parse(QueryTranslatorImpl.java:238)
... 33 more
系统中有个功能用户点击一个按钮要调用webservice,可能会等待较长时间,如果用户不耐烦,再点按钮或点击别的功能就乱套了
想到屏蔽页面所有功能,思路是用户点击按钮,调用一个javascript方法,显示预先在页面中定义好的隐藏div,返回结果后再隐藏div,允许用户继续操作。
==========================================================
<html>
<head>
<title>半透明div</title>
<style>
.#mask {
visibility: hidden;
background-color: #cccccc;
left: 0px;
position: absolute;
top: 0px;
background-image: none;
filter: alpha(opacity : 50);
}
.#dialog {
visibility: hidden;
background-color: #f7fcfe;
z-index: 100;
width: 300px;
height: 50px;
position: absolute;
text-align: center;
font-size: 30px;
color: #FF0000;
font-weight: bold;
vertical-align: middle;
}
</style>
<script language="javaScript">
function show()
{
var d_mask=document.getElementById('mask');
var d_dialog = document.getElementById('dialog');
d_mask.style.width = document.body.clientWidth ;
d_mask.style.height=document.body.clientHeight;
//网页正文全文
//d_mask.style.width = document.body.scrollWidth ;
//d_mask.style.height=document.body.scrollHeight;
d_dialog.style.top = document.body.clientHeight / 2 - 60;
d_dialog.style.left =document.body.clientWidth / 2 -100;
d_mask.style.visibility='visible';
d_dialog.style.visibility='visible';
}
function divBlock_event_mousedown()
{
var e, obj, temp;
obj=document.getElementById('dialog');
e=window.event?window.event:e;
obj.startX=e.clientX-obj.offsetLeft;
obj.startY=e.clientY-obj.offsetTop;
document.onmousemove=document_event_mousemove;
temp=document.attachEvent?document.attachEvent('onmouseup',document_event_mouseup):document.addEventListener('mouseup',document_event_mouseup,'');
}
function document_event_mousemove(e)
{
var e, obj;
obj=document.getElementById('dialog');
e=window.event?window.event:e;
with(obj.style){
position='absolute';
left=e.clientX-obj.startX+'px';
top=e.clientY-obj.startY+'px';
}
}
function document_event_mouseup(e)
{
var temp;
document.onmousemove='';
temp=document.detachEvent?document.detachEvent('onmouseup',document_event_mouseup):document.removeEventListener('mouseup',document_event_mouseup,'');
}
window.onresize = function()
{
var d_mask=document.getElementById('mask');
var d_dialog = document.getElementById('dialog');
d_mask.style.width = document.body.clientWidth ;
d_mask.style.height=document.body.clientHeight;
}
</script>
</head>
<div id ="mask"></div>
<div id ="dialog" onmousedown="divBlock_event_mousedown()">处理中,请等待……</div>
<body>
<table border='0' width="100%" height="100%">
<tr>
<td>
测试
</td>
</tr>
<tr>
<td>
<input type="button" value="显示div" onclick="show()" />
</td>
</tr>
</table>
</body>
</html>
//dwr Message
function useLoadingMessage(message) {
var loadingMessage;
if (message) loadingMessage = message;
else loadingMessage = "Loading";
DWREngine.setPreHook(function() {
var disabledZone = $('disabledZone');
if (!disabledZone) {
disabledZone = document.createElement('div');
disabledZone.setAttribute('id', 'disabledZone');
disabledZone.style.position = "absolute";
disabledZone.style.zIndex = "1000";
disabledZone.style.left = "0px";
disabledZone.style.top = "0px";
disabledZone.style.width = "100%";
disabledZone.style.height = "100%";
document.body.appendChild(disabledZone);
var messageZone = document.createElement('div');
messageZone.setAttribute('id', 'messageZone');
messageZone.style.position = "absolute";
messageZone.style.top = "400px"; //定义显示加载信息层的位置
messageZone.style.left = "400px"; //定义显示加载信息层的位置
messageZone.style.width = "150"; //定义显示加载信息层的宽度
messageZone.style.height = "30"; //定义显示加载信息层的高度
messageZone.style.background = "red";//定义显示加载信息层的颜色
messageZone.style.color = "white";
messageZone.style.fontFamily = "Arial,Helvetica,sans-serif";
messageZone.style.padding = "4px";
disabledZone.appendChild(messageZone);
var text = document.createTextNode(loadingMessage);
messageZone.appendChild(text);
}
else {
$('messageZone').innerHTML = loadingMessage;
disabledZone.style.visibility = 'visible';
}
});
DWREngine.setPostHook(function() {
$('disabledZone').style.visibility = 'hidden';
});
}
sql语句编写能力很差啊,总不用就忘啊,用了聚合函数的查询,得有group by
第一个行,第二个不行
SELECT
(select rowname from RPT_ROWCODE_SERVCORP rs where rs.rowcode = r.rowcode and tname = 'RPT_AGG_ST_SERV_01_2007') rowname,
r.rowcode,
sum(r.N01),sum(r.N02),sum(r.N03),sum(r.N04),sum(r.N05),sum(r.N06),sum(r.N07),
sum(r.N08),sum(r.N09),sum(r.N10),sum(r.N11),sum(r.N12),sum(r.N13),sum(r.N14),sum(r.N15)
FROM RPT_AGG_ST_SERV_01_2007 r
WHERE r.offino in ('0001') group by r.rowcode
order by r.rowcode
SELECT
rrs.rowcode,rrs.rowname,
sum(r.N01),sum(r.N02),sum(r.N03),sum(r.N04),sum(r.N05),sum(r.N06),sum(r.N07),
sum(r.N08),sum(r.N09),sum(r.N10),sum(r.N11),sum(r.N12),sum(r.N13),sum(r.N14),sum(r.N15)
FROM RPT_AGG_ST_SERV_01_2007 r,RPT_ROWCODE_SERVCORP rrs
WHERE rrs.rowcode = r.rowcode and rrs.tname = 'RPT_AGG_ST_SERV_01_2007' and r.offino in ('0001') group by r.rowcode
order by r.rowcode