彭老師:您好!請教個在jdonframework中關於查詢list中 KEY的問題???

javadavid發表於2005-12-28
彭老師:您好!
問題是這樣的:
比如我在sqlserver裡定義一個表,如:
CREATE TABLE [INFORM] (
[id] [bigint] IDENTITY (1, 1) NOT NULL ,
[content] [nvarchar] (50)
) ON [PRIMARY ]
其中:id列為主鍵,自增長
在jdon 框架列

model裡如下:
public class Inform extends Model {

private Integer id;
private String content;

public Inform() {

}

public Inform(Integer id, String content) {
this.id = id;
this.content = content;
}

// id
public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}


// content
public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}
}

相應的actionForm裡如下:
相應的actionForm順序項數等同上

相應的listaction裡如下:
public Model findModelByKey(HttpServletRequest request, Object key) {
Model model = null;
try {
TestService testService = (TestService) WebAppUtil.getService("testService",
request);
model = testService.getInform( (Integer) key);
} catch (Exception ex) {
logger.error(ex);
}
return model;

}

相應的dao裡如下:
public Inform getInform(Integer Id) {
String GET_FIELD = "select * from inform where id = ?";
List queryParams = new ArrayList();
queryParams.add(Id);

KQData ret = null;

try {
List list = pageIteratorSolverOfUser.queryMultiObject(queryParams,
GET_FIELD);
Iterator iter = list.iterator();
if (iter.hasNext()) {
Map map = (Map) iter.next();
ret = new Inform();
ret.setContent((String) map.get("content"));
ret.setId((Integer) map.get("id"));

}
} catch (Exception se) {
}
return ret;
}

public PageIterator getInform(int start, int count) throws Exception {
String GET_ALL_ITEMS_ALLCOUNT = "select count(1) from content ";

String GET_ALL_ITEMS = "select id from content ";

return pageIteratorSolverOfUser.getDatas("", GET_ALL_ITEMS_ALLCOUNT,
GET_ALL_ITEMS, start, count);
}

相應的服務實現裡如下:
public Inform getInform(Integer id) {
logger.debug(" get Inform from DAO + JDBC");
return jdbcDao.getInform(id);
}

public PageIterator getAllInforms(int start, int count) {
PageIterator pageIterator = new PageIterator(PageIterator.EMPTY, 0,
false);
try {
pageIterator = jdbcDao.getInforms(start, count);
} catch (Exception ex) {
logger.error(ex);
}
return pageIterator;

}
相應的服務裡如下:
public Inform getInform(Integer class_id);
public PageIterator getAllInforms(int start, int count);

相應的jdonframework.xml裡如下:
model key="id" class ="com.jdon.dataadmin.model.Inform"
actionForm name="informActionForm"/
handler
service ref="testService"
getMethod name="getInform" /
createMethod name="createInform" /
updateMethod name="updateInform" /
deleteMethod name="deleteInform" /
/service
/handler
/model

問題結果如下:
執行http://localhost:8080/test/informListAction.do
資料庫裡有資料,而頁面無顯示
後臺錯誤下;
2005-12-28 12:44:26,906 DEBUG [com.jdon.container.pico.PicoContainerWrapper] lookup: name=targetMetaDefLoader
2005-12-28 12:44:26,906 DEBUG [com.jdon.bussinessproxy.config.TargetMetaDefXmlLoader] metaDefs size:2
2005-12-28 12:44:26,906 DEBUG [com.jdon.controller.service.DefaultServiceFactory] getService found :testService
2005-12-28 12:44:26,906 DEBUG [com.jdon.container.visitor.VisitorFactory] first time get ComponentVisitor for com.jdon.dataadmin.service.TestServicePOJOImpcom.jdon.container.visitor.VisitorFactory
2005-12-28 12:44:26,906 DEBUG [com.jdon.container.visitor.HttpSessionProxyVisitor] valueBound active, sessionId :609EDA7847D62E8BB913C9FABA1586DD
2005-12-28 12:44:26,906 DEBUG [com.jdon.container.visitor.HttpSessionProxyVisitor] valueBound active, componentsboxs size:0
2005-12-28 12:44:26,906 DEBUG [com.jdon.controller.service.DefaultServiceFactory] proxyInstanceFactoryVisitable in action
2005-12-28 12:44:26,906 DEBUG [com.jdon.container.visitor.HttpSessionProxyVisitor] enter HttpSessionProxyVisitor
2005-12-28 12:44:26,906 DEBUG [com.jdon.container.visitor.ComponentOriginalVisitor] ComponentOriginalVisitor visit:proxyInstanceFactoryVisitable
2005-12-28 12:44:26,906 DEBUG [com.jdon.container.pico.PicoContainerWrapper] lookup: name=proxyInstanceFactoryVisitable
2005-12-28 12:44:26,906 DEBUG [com.jdon.bussinessproxy.dyncproxy.ProxyInstanceFactoryVisitable] enter Proxy.newProxyInstance
2005-12-28 12:44:26,906 DEBUG [com.jdon.bussinessproxy.dyncproxy.DynamicProxyWeaving] call method:com.jdon.dataadmin.service.TestService.getAllInform
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.AopClient] enter AOP invoker2 for:com.xbellwfdt.jxt.dataadmin.service.TestServicePOJOImp method:getAllInform
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.joinpoint.AdvisorChainFactory] enter create PointcutAdvisor
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.joinpoint.AdvisorChainFactory] find all service's interceptos size=1
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.joinpoint.AdvisorChainFactory] find pojoService's interceptos size=3
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.reflection.ProxyMethodInvocation] method.getName() :getAllInform
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.AopClient] MethodInvocation will proceed ...
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.reflection.ProxyMethodInvocation] <-----> enter ProxyMethodInvocation proceed() for -1
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.reflection.ProxyMethodInvocation] now call inteceptor : com.jdon.aop.interceptor.CacheInterceptor
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.interceptor.CacheInterceptor] enter cacheInteceptor method:getAllInform
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.interceptor.CacheInterceptor] methodMatchsModelGET: returnClassName = com.jdon.controller.model.PageIterator
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.interceptor.CacheInterceptor] cacheInteceptor don't action, enter next invocation.proceed()
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.reflection.ProxyMethodInvocation] <-----> enter ProxyMethodInvocation proceed() for 0
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.reflection.ProxyMethodInvocation] now call inteceptor : com.jdon.aop.interceptor.PoolInterceptor
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.interceptor.PoolInterceptor] enter PoolInterceptor
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.interceptor.PoolInterceptor] borrow a object:com.xbellwfdt.jxt.dataadmin.service.TestServicePOJOImp from pool
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.reflection.ProxyMethodInvocation] <-----> enter ProxyMethodInvocation proceed() for 1
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.reflection.ProxyMethodInvocation] now call inteceptor : com.jdon.aop.interceptor.StatefulInterceptor
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.interceptor.StatefulInterceptor] enter StatefulInterceptor
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.interceptor.StatefulInterceptor] target service is not Stateful: com.xbellwfdt.jxt.dataadmin.service.TestServicePOJOImp StatefulInterceptor unactiive
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.reflection.ProxyMethodInvocation] <-----> enter ProxyMethodInvocation proceed() for 2
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.reflection.ProxyMethodInvocation] finish call all inteceptors
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.reflection.ProxyMethodInvocation] enter method reflection
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.reflection.ProxyMethodInvocation] target:com.xbellwfdt.jxt.dataadmin.service.TestServicePOJOImp service's method:getAllKQDatasCon running..
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.reflection.ProxyMethodInvocation] it is pojo target service
2005-12-28 12:44:26,906 DEBUG [com.jdon.model.query.PageIteratorSolver] enter getPageIterator ..
2005-12-28 12:44:26,906 DEBUG [com.jdon.controller.cache.CacheManager] <-cache->try to get cache: PageIteratorPageIteratorSolverKEYSselect id from JXT_KQ_DATA where 1=1 order by student_timecard_code desc010
2005-12-28 12:44:26,906 DEBUG [com.jdon.controller.cache.CacheManager] <-cache->got it
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.reflection.MethodInvokerUtil] method invoke successfully
2005-12-28 12:44:26,906 DEBUG [com.jdon.aop.interceptor.PoolInterceptor] realease a object:com.xbellwfdt.jxt.dataadmin.service.TestServicePOJOImp to pool
2005-12-28 12:44:26,906 DEBUG [com.jdon.bussinessproxy.dyncproxy.DynamicProxyWeaving] call method:getAllInform finish!
2005-12-28 12:44:26,906 DEBUG [com.jdon.strutsutil.ModelListAction] getCache from db.
2005-12-28 12:44:26,906 DEBUG [com.jdon.container.pico.PicoContainerWrapper] lookup: name=targetMetaDefLoader
2005-12-28 12:44:26,906 DEBUG [com.jdon.bussinessproxy.config.TargetMetaDefXmlLoader] metaDefs size:2
2005-12-28 12:44:26,906 DEBUG [com.jdon.controller.service.DefaultServiceFactory] getService found :testService
2005-12-28 12:44:26,906 DEBUG [com.jdon.controller.service.DefaultServiceFactory] proxyInstanceFactoryVisitable in action
2005-12-28 12:44:26,906 DEBUG [com.jdon.container.visitor.HttpSessionProxyVisitor] enter HttpSessionProxyVisitor
2005-12-28 12:44:26,906 ERROR [com.xbellwfdt.jxt.dataadmin.web.KQDataListAction] java.lang.ClassCastException
2005-12-28 12:44:26,906 WARN [root] com.jdon.strutsutil.ModelListAction
java.lang.Exception: the model Id=(6) maybe be deleted!
at com.jdon.strutsutil.ModelListAction.fetchModel(ModelListAction.java:203)
at com.jdon.strutsutil.ModelListAction.getModelList(ModelListAction.java:144)
at com.jdon.strutsutil.ModelListAction.execute(ModelListAction.java:85)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:122)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:534)
2005-12-28 12:44:26,906 DEBUG [com.jdon.strutsutil.ModelListAction] listForm 's property: getList size is 0

資料庫僅有一條資料:id=6
如果我把資料庫裡的bigint改為char等字元型別
程式碼裡所有相應的Integer改為String就正常了,但我需要自增長的bigint型別列id。
麻煩彭老師您給多多指教,幫忙解決這個問題,還有
就是如果資料庫表裡列型別有int等非字元型的,執行後該列及其後面的列就不顯示資料等,只有同上述全部改為字元型的,一切才正常。
多謝彭老師幫忙解決一下上述問題。多謝!



相關文章