Hibernate Criteria查询 could not resolve property: user_id of 错误

User实体关系配置
图片说明
图片说明
User_Info实体关系配置
图片说明
图片说明

查询语句:
DetachedCriteria dc = DetachedCriteria.forClass(User_Info.class);
dc.add(Restrictions.like("user_id", user.getUser_id()));
List user_Infos = getHibernateTemplate().findByCriteria(dc);*****这条语句出错*****
org.springframework.orm.hibernate5.HibernateQueryException: could not resolve property: user_id of

1个回答

非常奇怪的是:我项目修改某个地方再保存后,Tomcat自动更新完成后,这个问题就解决了

最后自己解决了 修改代码:dc.add(Restrictions.like("user.user_id", user.getUser_id()));

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
hibernate中 could not resolve property
hibernate could not resolve propertyrn配置是正确的,偶尔才会出现这个错误,求解。。。。。。
could not resolve property
[b]rn用Criteria进行链表模糊查询时,报拉could not resolve property错,该怎么解决?rnrnrnrn/b]
HibernateQueryException: could not resolve property
org.springframework.orm.hibernate3.HibernateQueryException: could not resolve property: createSN.department.id of: cn.jbit.demo.entity.ClaimVoucher; nested exception is org.hibernate.QueryException: could not resolve property: createSN.department.id of: cn.jbit.demo.entity.ClaimVoucherrn at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:656)rn at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)rn at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)rn at org.springframework.orm.hibernate3.HibernateTemplate.executeFind(HibernateTemplate.java:343)rn at cn.jbit.demo.dao.impl.VoucherDaoImpl.getPage(VoucherDaoImpl.java:33)rn at cn.jbit.demo.service.impl.VoucherServiceImpl.getPage(VoucherServiceImpl.java:32)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)rn at java.lang.reflect.Method.invoke(Method.java:606)rn at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)rn at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)rn at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)rn at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)rn at com.sun.proxy.$Proxy24.getPage(Unknown Source)rn at cn.jbit.demo.service.web.action.VoucherAction.searchClaimVoucher(VoucherAction.java:58)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)rn at java.lang.reflect.Method.invoke(Method.java:606)rn at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)rn at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)rn at org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)rn at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:139)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)rn at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)rn at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)rn at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)rn at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)rn at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)rn at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)rn at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:655)rn at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:277)rn at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2381)rn at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2370)rn at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)rn at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)rn at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)rn at java.lang.Thread.run(Thread.java:745)rn使用Criteria查询时出现的问题,Hibernate用的是注解映射,能在JSP页面使用获取到值,求帮助
could not resolve property:
遇到了一个问题请教一下大家!先谢谢了哈!rn*.hbm.xml文件中有一个字段workfId的映射关系:rnrn rn rnrn我在查询中运用的是:rn public List getCombinationWorkfId(String workfId)rn rn Criteria criteria = getHibernateTemplate().getSessionFactory().openSession().createCriteria(Combination.class); rn criteria.add(Expression.eq("workfId","015"));rn List list = criteria.list(); rn System.out.print(list.size());rn getHibernateTemplate().getSessionFactory().close();rn return list; rn rn用debuge试也也能得到workId的值,但就是在 List list = criteria.list();取不到值,请各位指点!
hibernate报错:could not resolve property: roomTypes of:
这是异常信息:rnrn[code=text]could not resolve property: roomTypes of: com.qlw.hotelmanagenemt.model.Rooms [select r.roomId,r.roomTypes.typeName,r.roomStatus from com.qlw.hotelmanagenemt.model.Rooms r][/code]rnrn用的是注解的方式rnRooms跟RoomTypes是多对一的关系rn多方:rnrn[code=java]package com.qlw.hotelmanagenemt.model;rnrnimport javax.persistence.CascadeType;rnimport javax.persistence.Entity;rnimport javax.persistence.GeneratedValue;rnimport javax.persistence.JoinColumn;rnimport javax.persistence.ManyToOne;rnrnimport javax.persistence.Id;rnrnrn@Entityrnpublic class Rooms rnrn private int id;rn @Idrn @GeneratedValuern public int getId() rn return id;rn rn public void setId(int id) rn this.id = id;rn rn rn rn private RoomTypes roomTypes;rn rn @ManyToOne(cascade=CascadeType.ALL,targetEntity = RoomTypes.class)rn @JoinColumn(name="typeId",updatable=false,insertable=false)rn public RoomTypes getRoomtypes() rn return roomTypes;rn rn public void setRoomtypes(RoomTypes roomTypes) rn this.roomTypes = roomTypes;rn rn rn private int typeId;rn private String roomId;rn private int roomStatus;rn rn rn public int getTypeId() rn return typeId;rn rn public void setTypeId(int typeId) rn this.typeId = typeId;rn rn public String getRoomId() rn return roomId;rn rn public void setRoomId(String roomId) rn this.roomId = roomId;rn rn public int getRoomStatus() rn return roomStatus;rn rn public void setRoomStatus(int roomStatus) rn this.roomStatus = roomStatus;rn rn rnrn[/code]rnrn一方:rn[code=java]package com.qlw.hotelmanagenemt.model;rnrnimport java.util.ArrayList;rnimport java.util.Date;rnimport java.util.List;rnrnimport javax.persistence.Entity;rnimport javax.persistence.GeneratedValue;rnimport javax.persistence.JoinColumn;rnimport javax.persistence.OneToMany;rnrnimport javax.persistence.Id;rnrnrn@Entityrnpublic class RoomTypes rnrn private int id;rn @Idrn @GeneratedValuern public int getId() rn return id;rn rn public void setId(int id) rn this.id = id;rn rnrn private String typeName;rn private int bedNum;rn private String bedType;rn private int wifi; //0表示没有;1表示有rn private String area;rn private int price;rn private String remark;rn rn public String getTypeName() rn return typeName;rn rn public void setTypeName(String typeName) rn this.typeName = typeName;rn rn public int getBedNum() rn return bedNum;rn rn public void setBedNum(int bedNum) rn this.bedNum = bedNum;rn rn public String getBedType() rn return bedType;rn rn public void setBedType(String bedType) rn this.bedType = bedType;rn rn public int getWifi() rn return wifi;rn rn public void setWifi(int wifi) rn this.wifi = wifi;rn rn public String getArea() rn return area;rn rn public void setArea(String area) rn this.area = area;rn rn public int getPrice() rn return price;rn rn public void setPrice(int price) rn this.price = price;rn rn public String getRemark() rn return remark;rn rn public void setRemark(String remark) rn this.remark = remark;rn rn rnrn[/code]rnrn这是出错的地方:rnrn[code=java]public List getRooms() rn return (List)hibernateTemplate.find("select r.roomId,r.roomTypes.typeName,r.roomStatus from Rooms r");rn rn[/code]rnrnRoomInfo是一个DTOrn[code=java]package com.qlw.hotelmanagenemt.model;rnrnrnrnpublic class RoomInfo rnrn private int typeId;rn private String roomId;rn private int roomStatus;rn private String typeName;rn private int bedNum;rn private String bedType;rn private int wifi; //0表示没有;1表示有rn private String area;rn private int price;rn private String remark;rn rn rn public int getTypeId() rn return typeId;rn rn public void setTypeId(int typeId) rn this.typeId = typeId;rn rn public String getRoomId() rn return roomId;rn rn public void setRoomId(String roomId) rn this.roomId = roomId;rn rn public int getRoomStatus() rn return roomStatus;rn rn public void setRoomStatus(int roomStatus) rn this.roomStatus = roomStatus;rn rn public String getTypeName() rn return typeName;rn rn public void setTypeName(String typeName) rn this.typeName = typeName;rn rn public int getBedNum() rn return bedNum;rn rn public void setBedNum(int bedNum) rn this.bedNum = bedNum;rn rn public String getBedType() rn return bedType;rn rn public void setBedType(String bedType) rn this.bedType = bedType;rn rn public int getWifi() rn return wifi;rn rn public void setWifi(int wifi) rn this.wifi = wifi;rn rn public String getArea() rn return area;rn rn public void setArea(String area) rn this.area = area;rn rn public int getPrice() rn return price;rn rn public void setPrice(int price) rn this.price = price;rn rn public String getRemark() rn return remark;rn rn public void setRemark(String remark) rn this.remark = remark;rn rn rnrn[/code]rnrn新人求帮助!!!
org.hibernate.QueryException: could not resolve property: DownloadFile
帮我找一下原因rnrnrn public DownloadFile get(String trueUrl, String baseUrl) rn DownloadFile downloadFile = (DownloadFile) sessionFactoryrn .getCurrentSession()rn .createQuery(rn "select d from SpiderUrls s inner join fetch s.DownloadFile as d where d.trueUrl =:trueUrl and s.pageUrl =: pageUrl")rn .setString("trueUrl", trueUrl).setString("pageUrl", baseUrl).uniqueResult();rn return downloadFile;rn rnrnrnrnrnorg.hibernate.QueryException: could not resolve property: DownloadFile of: com.spider.service.SpiderUrls [select d from com.spider.service.SpiderUrls s inner join fetch s.DownloadFile as d where d.trueUrl = :trueUrl and s.pageUrl =: pageUrl]rn at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:81)rn at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:75)rn at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1451)rn at org.hibernate.hql.ast.tree.FromElementType.getPropertyType(FromElementType.java:312)rn at org.hibernate.hql.ast.tree.FromElement.getPropertyType(FromElement.java:487)rn at org.hibernate.hql.ast.tree.DotNode.getDataType(DotNode.java:611)rn at org.hibernate.hql.ast.tree.DotNode.prepareLhs(DotNode.java:263)rn at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:210)rn at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:117)rn at org.hibernate.hql.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:366)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3583)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3364)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3237)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:724)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:575)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:292)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:235)rn at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254)rn at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)rn at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)rn at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:101)rn at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:80)rn at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:98)rn at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)rn at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)rn at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1760)rn at com.spider.service.DownloadFileService.get(DownloadFileService.java:33)rn at com.spider.service.DownloadFileService$$FastClassByCGLIB$$f3dc331c.invoke()rn at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)rn at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)rn at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)rn at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)rn at com.spider.service.DownloadFileService$$EnhancerByCGLIB$$818c190c.get()rn at com.spider.extractor.ExtractorImage.download(ExtractorImage.java:102)rn at com.spider.extractor.ExtractorImage.extract(ExtractorImage.java:73)rn at org.archive.crawler.extractor.Extractor.innerProcess(Extractor.java:67)rn at org.archive.crawler.framework.Processor.process(Processor.java:109)rn at org.archive.crawler.framework.ToeThread.processCrawlUri(ToeThread.java:306)rn at org.archive.crawler.framework.ToeThread.run(ToeThread.java:154)rn
hibernate3报错: could not resolve property
求高手修改我的HQL语句。(SSH2/hibernate3)rnrn我的HQL语句如下:rnString hql = "From Question AS q WHERE q.qid IN(SELECT a.qid FROM Answer AS a WHERE a.userid=?)";rnrn报错信息:org.hibernate.QueryException: could not resolve property: qid of: org.lxh.myzngt.vo.Answer [From org.lxh.myzngt.vo.Question AS q WHERE q.qid IN(SELECT a.qid FROM org.lxh.myzngt.vo.Answer AS a WHERE a.userid=?)]rnrnrn表结构:表Answer 中有外键:qid 对应到表Question 中的q.id.rnrnQuestion.hbm.xml:rnrn rn rn rn rn rn rn rn rn rn rn rn rnrnAnswer.hbm.xml:rnrn rn rn rn rn rn rn rn rnrnrnrnQuestion.java:rnrnpublic class Question rn private int qid;rn private Set answers;rn public int getQid() rn return qid;rn rn public void setQid(int qid) rn this.qid = qid;rn rn public Set getAnswers() rn return answers;rn rn public void setAnswers(Set answers) rn this.answers = answers;rn rnrnrnAnswer.java:rnrnpublic class Answer rn private int aid;rn private int qid;rn private Question question;rn rn public Question getQuestion() rn return question;rn rn public void setQuestion(Question question) rn this.question = question;rn rn public int getAid() rn return aid;rn rn public void setAid(int aid) rn this.aid = aid;rn rn public int getQid() rn return qid;rn rn public void setQid(int qid) rn this.qid = qid;rn rn rn rnrn
could not resolve property: patientid of: com.dentist.domain.Case
之前的几个模块都没有报这个字段不匹配异常啊rnrn[code=java]rnrnrnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrn[/code]rn[code=java]rnrnrnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn 照片rn rn rn rn rn rn rn rn rn rnrn[/code]rn[code=java]public Page findCase(Case c,Integer pageNum) rn rn DetachedCriteria dc = DetachedCriteria.forClass(Case.class);rn //患者idrn if(c.getPatient().getId()!=null)rn dc.add(Restrictions.eq("patientid", c.getPatient().getId()));rn rn //病历创建日期rn if(c.getDate() != null)rn dc.add(Restrictions.eq("date", c.getDate()));rn rn rn return findByPropertyWithCriteria(dc, pageNum);rn [/code]rn[code=java]rn /**rn * 分页rn */rn private Page findByPropertyWithCriteria(DetachedCriteria dc, int currPage) rn Session session = this.getSession();rn // 查总条数rn dc.setProjection(Projections.rowCount());rn Criteria c = dc.getExecutableCriteria(session);rn int countNum = (Integer) c.uniqueResult();//此行在运行时控制台报错rn // 总页数rn int totalPage = 1;rn if (countNum % Constants.PAGE_NUMBER == 0) rn totalPage = countNum / Constants.PAGE_NUMBER;rn else rn totalPage = countNum / Constants.PAGE_NUMBER + 1;rn rn Page page = new Page();rn page.setTotalPage(totalPage);rnrn // 去掉刚刚添加rowCount投影rn dc.setProjection(null);rn Criteria c1 = dc.getExecutableCriteria(session);rn int num = (currPage - 1) * Constants.PAGE_NUMBER;rn c1.setFirstResult(num);rn c1.setMaxResults(Constants.PAGE_NUMBER);rn List result = c1.list();rn page.setResult(result);rn page.setCurrPage(currPage);rn return page;rn [/code]
could not resolve property: UserID of: com.Bean.Products [from com.Bean.Products
Products.java:rnpublic class Products rn private Integer productID;rn private String productName;rn private Integer userID;rn private String picture;rn private Integer counts;rn private Float price;rn private String productDsc;rn private Integer parentID;rn //getter&setter&construterrnxml:rnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnDALProducts.java:rnpublic List findProductsByUserID(int id) rn String sql="from Products p where p.UserID=?";rn List list=new ArrayList();rn //testrn if (this.getHibernateTemplate()==null) rn System.out.println("get null value!");rn rn list = this.getHibernateTemplate().find(sql,new Integer(id)); rn return list;rn 配置文件感觉没有错啊 麻烦大神们帮忙看下!
could not resolve property 实体类和映射文件都没问题
servlet [JeeCmsFront] in context with path [] threw exception [Request processing failed; nested exception is org.hibernate.QueryException: could not resolve property: zanUsers of: com.jeecms.cms.enti...
[求高手解答]could not resolve property 的问题
could not resolve property: TSNotice of: org.jeecgframework.web.system.pojo.fwxt.TSNoticern 这里报错 差了下出错的方法是Hibernet中 下面这个方法rn private final Map typesByPropertyPath = new HashMap();rnrnrnpublic Type toType(String propertyName) throws QueryException rn Type type = (Type) typesByPropertyPath.get(propertyName);rn if ( type == null ) rn throw propertyException( propertyName );rn rn return type;rn rnrn这个问题 应该怎么解决 ? 求大神解答rn
org.hibernate.QueryException: could not resolve property: dep_id of: pojo.Studen
public ArrayList getliststudent(String depname) rn ArrayList list=new ArrayList();rn Session session = HibernateSessionFactory.getSession();rn String hql="from Departments d where d.depname='"+depname+"'";rn List list1=session.createQuery(hql).list();rn Departments depart=new Departments();rn Iterator iter1=list1.iterator();rn if(iter1.hasNext())rn depart=(Departments) iter1.next();rn int id=depart.getDep_id();rn String hql1="from Student stu where stu.dep_id='"+id+"'";rn list= (ArrayList) session.createQuery(hql1).list();rn System.out.print(list.size());rn rn return list;rn rn rn注意:dep_id是外键rn
Hibernate criteria查询
用Hibernate Criteria查询rnrnrn```rnCriteria criteria = session.createCriteria(User.class);rncriteria.add(Restrictions.eq("username", username));rncriteria.add(Restrictions.eq("password", password));rnlist = criteria.list();rnreturn list;rn```rnMySQL数据库中的表rnid\_ username\_ password\_rn1 ZhangSan 123rn在页面输入用户名和密码:zhangsan,123rn还是能查询并返回数据,难道不区分大小写吗rn
Unable to resolve property: id,Hibernate异常
nn```n org.hibernate.HibernateException: Unable to resolve property: idn org.hibernate.tuple.entity.EntityMetamodel.getPropertyIndex(EntityMetamodel.java:487)n org.hibernate.persister.entity.AbstractEntityPersister.getPropertyIndex(AbstractEntityPersister.java:1684)n org.hibernate.engine.EntityEntry.getLoadedValue(EntityEntry.java:233)n org.hibernate.type.CollectionType.getKeyOfOwner(CollectionType.java:363)n org.hibernate.type.CollectionType.resolve(CollectionType.java:424)n org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139)n org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:877)n org.hibernate.loader.Loader.doQuery(Loader.java:752)n org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)n org.hibernate.loader.Loader.loadEntity(Loader.java:1885)n org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:71)n org.hibernate.loader.entity.EntityLoader.loadByUniqueKey(EntityLoader.java:108)n org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:1662)n org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:641)n org.hibernate.type.EntityType.resolve(EntityType.java:415)n org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139)n org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:877)n org.hibernate.loader.Loader.doQuery(Loader.java:752)n org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)n org.hibernate.loader.Loader.loadEntity(Loader.java:1885)n org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:71)n org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:65)n org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3062)n org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:434)n org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:415)n org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:165)n org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:121)n org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:906)n org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:864)n org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:141)n org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:174)n org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)n com.znyy.bean.lis.LisTm_$$_jvst3fe_1a.getZyyzjymx(LisTm_$$_jvst3fe_1a.java)n com.znyy.service.lis.LisBBServiceImpl.getXtJyLisBbdj(LisBBServiceImpl.java:224)n sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)n sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)n sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)n java.lang.reflect.Method.invoke(Method.java:601)n org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)n org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)n org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)n org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)n org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)n org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)n org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)n org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)n sun.proxy.$Proxy11.getXtJyLisBbdj(Unknown Source)n com.znyy.action.lis.LisBBAction.getXtJyLisBbdj(LisBBAction.java:229)n sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)n sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)n sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)n java.lang.reflect.Method.invoke(Method.java:601)n com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)n com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)n com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)n com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)n org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)n com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)n com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)n com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:270)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)n com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)n com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)n org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)n org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:498)n org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:434)n org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)n org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)n org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)n org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)n```nn
hibernateCriteria查询
Criteria查询将数据查询条件封装成为一个对象,可以堪称是传统SQL的对象化表示。
hibernate Criteria查询
rnpublic class BaseHibernateDAO rn public List search(Class cl,Object condition)rn rn List list=null;rn tryrn list=this.getSession().createCriteria(cl).add(Example.create(condition)).list();rn rn catch(Exception e)rn rn e.printStackTrace();rn finallyrn rn this.closeSession();rn rn return list;rn rn 其它方法省略。。。rnrnrnpublic static void main(String[] args) rn Account condition=new Account();rn condition.setBalance(100);rn BaseHibernateDAO bd=new BaseHibernateDAO();rn List list=(List)bd.search(Account.class, condition);rn for(int i=0;i100的要怎么改呢?
Property 'user_id' not found on type java.la
用SSH框架 在jsp页面出现错误rnrnrnaction 代码:rnpublic String queryMemorabilia() throws Exceptionrn List memo=idao.query("from Memorabilia order by memorabiliaDate desc");rn request.setAttribute("memo", memo);rn return "Memorabilia";rn rnjsprnrn rn 第条留言rn 留言内容rn 留言人rn rn rnrnrn
Spring错误:Could not resolve placeholder 'jdbc.driver'
使用spring-framework-3.0.3,配置文件如下:rnapplicationContext.xmlrn[code=XML]rnrn]>rnrn rn rn /WEB-INF/config/jdbc.propertiesrn rn rn rn rn rn rn rn rn[/code]rnrnjdbc.properties文件在/WEB-INF/config目录下rn[code=XML]jdbc.driver=oracle.jdbc.OracleDriverrnjdbc.url=jdbc:oracle:thin:@127.0.0.1:1521:orclrnjdbc.user=scottrnjdbc.password=tiger[/code]rnrn当启动tomcat时,产生如下错误rn[code=XML]严重: Context initialization failedrnorg.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in ServletContext resource [/WEB-INF/config/applicationContext.xml]: Could not resolve placeholder 'jdbc.driver'rn at org.springframework.beans.factory.config.PropertyPlaceholderConfigurernr.processProperties(PropertyPlaceholderConfigurer.java:272)rn at org.springframework.beans.factory.config.PropertyResourceConfigurer.prnostProcessBeanFactory(PropertyResourceConfigurer.java:75)rn at org.springframework.context.support.AbstractApplicationContext.invokernBeanFactoryPostProcessors(AbstractApplicationContext.java:663)rn at org.springframework.context.support.AbstractApplicationContext.invokernBeanFactoryPostProcessors(AbstractApplicationContext.java:638)rn at org.springframework.context.support.AbstractApplicationContext.refresrnh(AbstractApplicationContext.java:407)rn at org.springframework.web.context.ContextLoader.createWebApplicationConrntext(ContextLoader.java:276)rn at org.springframework.web.context.ContextLoader.initWebApplicationConternxt(ContextLoader.java:197)rn at org.springframework.web.context.ContextLoaderListener.contextInitialirnzed(ContextLoaderListener.java:47)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContexrnt.java:4323)rn at org.apache.catalina.core.StandardContext.startInternal(StandardContexrnt.java:4771)rn at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBasern.java:785)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:76rn3)rn at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:558)rnrn at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.javrna:1124)rn at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.jrnava:1047)rn at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:542rn)rn at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1390)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.javarn:355)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecyclrneSupport.java:119)rn at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBarnse.java:89)rn at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:31rn2)rn at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:29rn2)rn at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.jarnva:998)rn at org.apache.catalina.core.StandardHost.startInternal(StandardHost.javarn:772)rn at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)rn at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.jarnva:990)rn at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.rnjava:275)rn at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)rn at org.apache.catalina.core.StandardService.startInternal(StandardServicrne.java:424)rn at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)rn at org.apache.catalina.core.StandardServer.startInternal(StandardServer.rnjava:648)rn at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:576)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.rnjava:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesrnsorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)rn2010-7-27 11:18:35 org.apache.catalina.core.StandardContext startInternal[/code]rnrn为什么会产生上面的错误呢?如何修改?rn谢谢!rn
org.springframework.orm.hibernate3.HibernateQueryException: could not resolve pr
报错rn[code=text]rnorg.springframework.orm.hibernate3.HibernateQueryException: could not resolve property: userid of: com.smartcountry.domain.PowerService; nested exception is org.hibernate.QueryException: could not resolve property: userid of: com.smartcountry.domain.PowerServicern org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:656)rn org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)rn org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)rn org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)rn org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:1046)rn com.smartcountry.dao.impl.PowerServiceDaoImpl.findByPage(PowerServiceDaoImpl.java:63)rn com.smartcountry.service.impl.UserServiceImpl.findByPage(UserServiceImpl.java:65)rn sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)rn sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)rn java.lang.reflect.Method.invoke(Method.java:601)rn org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)rn org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)rn org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)rn org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)rn org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)rn org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)rn org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)rn org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)rn sun.proxy.$Proxy8.findByPage(Unknown Source)rn com.smartcountry.action.UserAction.findBuyOrderAll(UserAction.java:110)rn sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)rn sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)rn java.lang.reflect.Method.invoke(Method.java:601)rn ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:870)rn ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1293)rn ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)rn com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethodWithDebugInfo(XWorkMethodAccessor.java:117)rn com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:108)rn ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1369)rn ognl.ASTMethod.getValueBody(ASTMethod.java:90)rn ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)rn ognl.SimpleNode.getValue(SimpleNode.java:258)rn ognl.Ognl.getValue(Ognl.java:494)rn ognl.Ognl.getValue(Ognl.java:458)rn com.opensymphony.xwork2.ognl.OgnlUtil$2.execute(OgnlUtil.java:309)rn com.opensymphony.xwork2.ognl.OgnlUtil.compileAndExecute(OgnlUtil.java:340)rn com.opensymphony.xwork2.ognl.OgnlUtil.getValue(OgnlUtil.java:307)rn com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:423)rn com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:287)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:250)rn org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)rn org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:76)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn org.apache.struts2.interceptor.DateTextFieldInterceptor.intercept(DateTextFieldInterceptor.java:125)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:253)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:139)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)rn org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)rn org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:564)rn org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)rn org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)rn[/code]rn[code=java]rnpublic List findByPage(User user, int begin, int pageSize) rn DetachedCriteria criteria = DetachedCriteria.forClass(PowerService.class).add(Restrictions.eq("state",new String("1")))rn .add(Restrictions.eq("userid", user))rn .addOrder(Order.desc("timer"));rn List list = this.getHibernateTemplate().findByCriteria(criteria,rn begin, pageSize);rn return list;rn rn[/code]rn出错的地方是 .add(Restrictions.eq("userid", user))rn不知道怎么解决,请教各位大神哥哥姐姐弟弟妹妹们
Velocity Could not resolve view
使用Velocity发送请求转发到vm文件报错???是几个意思??容器启动正常rnapplicationContext.xml配置:rn[code=html]rn rn rn rn rn rn rn rn rn [/code]rnrn[code=java]javax.servlet.ServletException: Could not resolve view with name 'test.vm' in servlet with name 'do'rn at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1190)rn at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)rn at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)rn at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)rn at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)rn at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)rn at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)rn at java.lang.Thread.run(Thread.java:662)[/code]rnrnrn
Could not resolve host: http
curl_init请求返回Could not resolve host: http,系统linux,环境apache+phprn求解,急
could not resolve service name ???
<% text1=request("text1")rn response.Write(text1)rn 'response.End()rnset conn=server.createobject("adodb.connection") rnDSNTemp="Provider=MSDAORA.1;Password=ZHUANGZI;User ID=ZHUANGZI;Data Source=SJZ Persist Security Info=True" rnconn.open DSNtemp rnstr="insert into TEXT(text)values('"&text1&"')"rnconn.execute strrn%>rnrnMicrosoft VBScript 编译器错误 错误 '800a03f6' rnrn缺少 'End' rnrn/iisHelp/common/500-100.asp,行242 rnrnMicrosoft OLE DB Provider for Oracle 错误 '80004005' rnrnORA-12154: TNS:could not resolve service name rnrn/123/add.asp,行6 就是CONN。EXECUTE STRrnrn请问是怎么回事呀rn
Could not resolve placeholder 'hibernate.driverClassName'
将Tomcat下的SSH架构的项目移植到weblogic下,tomcat下是可以运行的rnrn在weblogic下部署项目rnrn部署成功,登陆页面点击登录报错No bean named 'sessionFactory' is definedrnrn然后我在weblogic.xml下加入rn rn true rn rnrn再在weblogic下部署,部署失败,并报错rnweblogic.application.ModuleException: :org.springframework.beans.factory.BeanDefinitionStoreException:Invalid bean definition with name 'dataSource' defined in file [D:\SDK\Workspace\Workspace fo MyEclipse\PersonnelPro\WebRoot\WEB-INF\classes\applicationContext-common.xml]: Could not resolve placeholder 'hibernate.driverClassName'rnrn我的applicationContext-common.xml文件rnrnrnrn rn rn rn rn classpath:hibernate.propertiesrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrnrn rn rnrn rn rn rn truern updatern rn org.hibernate.dialect.OracleDialectrn rn rn rn rn rn rn rn com/personnel/model/Message.hbm.xmlrn com/personnel/model/Organization.hbm.xmlrn com/personnel/model/User.hbm.xmlrn rn rn rnrnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn mgr rn rn rn rn rn rn rn rn transactionInterceptor rn rn rn rn rn rnrnrnrn我的web.xml文件rnrnrnrnrnrn rn rncontextConfigLocation rn classpath:applicationContext-*.xmlrnrn rn rn org.springframework.web.context.ContextLoaderListener rn rn rnrn rn rn rn encodingFilterrn org.springframework.web.filter.CharacterEncodingFilterrn rn encodingrn gbkrn rn rn rn pathfilterrn com.personnel.filter.FilterServletrn rn rn pathfilterrn /*rn rn rn rn rn struts2rn org.apache.struts2.dispatcher.FilterDispatcherrn rn rn rn hibernateFilterrn org.springframework.orm.hibernate3.support.OpenSessionInViewFilterrn rn rn hibernateFilterrn *.actionrn rn rn encodingFilterrn *.actionrn rn rn encodingFilterrn *.jsprn rn rn struts2rn *.actionrn rn rn rn rn ConnectorServletrn rn net.fckeditor.connector.ConnectorServletrn rn 1rn rnrn rn ConnectorServletrn /fckeditor/editor/filemanager/connectors/*rn rnrn rnrn login.jsprnrnrnrnrn
Could not resolve placeholder
2012-03-05 12:11:13,836] main org.springframework.web.context.ContextLoader ERROR - Context initialization failedrnorg.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name '_formLoginFilter' defined in null: Could not resolve placeholder 'ql.security.cas.server.loginUrl'rn at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:268)rn at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75)rn at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:553)rn at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:527)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:362)rn at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)rn at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)rn at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3795)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4252)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)rn at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)rn at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:980)rn at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:943)rn at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)rn at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1203)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:319)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)rn at org.apache.catalina.core.StandardService.start(StandardService.java:448)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:552)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)rn[2012-03-05 12:11:13,840] main org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/anyangwrm] ERROR - Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
JPA通过外键查询时报错:could not resolve property
以下有两个实体类:rnimport java.util.Date;rnimport java.util.HashSet;rnimport java.util.Set;rnrnimport javax.persistence.CascadeType;rnimport javax.persistence.ElementCollection;rnimport javax.persistence.Entity;rnimport javax.persistence.FetchType;rnimport javax.persistence.JoinColumn;rnimport javax.persistence.OneToMany;rnrn@Entity(name="record")rnpublic class Record extends BaseObject rnrn private String name; //姓名rn rn private String sex; //性别rn rn private Date birthday; //出生年月rn rn private String family; //民族rn rn private String marital_status; //婚姻状况rn rn private String politics_status; //政治面貌 rn rn private String id_number; //身份证号rn rn @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY)//级联保存、更新、删除、刷新;延迟加载 rn @JoinColumn(name="record_id")//在eduexp表增加一个外键列来实现一对多的单向关联rn private Set eduexp = new HashSet(); //教育培训经历rnrn省略 getter 和 setter 方法rnrnrnimport java.util.Date;rnrnimport javax.persistence.CascadeType;rnimport javax.persistence.Entity;rnimport javax.persistence.FetchType;rnimport javax.persistence.JoinColumn;rnimport javax.persistence.ManyToOne;rnrn@Entity(name="eduexp")rnpublic class Eduexp extends BaseObject rnrn private Date edu_time; //起始时间rn private Date edu_endtime;//结束时间rn private String edu_org; //教育培训机构rn private String course; //专业或课程rn rn @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER, optional = false) rn private Record record;rn rn 省略 getter 和 setter 方法rnrnrn我想通过 eduexp 中的外键 record_id 查询 eduexp 中的数据。rnrn查询方法:rnrnpublic String queryReocrdData()rn rn StringBuffer str_hql = new StringBuffer();rn str_hql.append("SELECT new com.ewayit.model.Eduexp(E.edu_time, E.edu_endtime, E.edu_org, E.course) FROM ")rn .append("com.ewayit.model.Eduexp E WHERE E.RECORD_ID = ?1");rn rn try rn toJson(getService().find(str_hql.toString(), id));rnrn catch (IllegalAccessException | IllegalArgumentExceptionrn | InvocationTargetException | IntrospectionException e) rnrn e.printStackTrace();rn rn rn return Action.SUCCESS;rnrnrn但是报错:rn[img=https://img-bbs.csdn.net/upload/201409/18/1411027168_913041.png][/img]
请问这是什么原因 org.hibernate.QueryException: could not resolve property: lsbh of: com.cisa.hibernate.sys.data.lspslsdb
请问这是什么原因 org.hibernate.QueryException: could not resolve property: lsbh of: com.cisa.hibernate.sys.data.lspslsdb [select new com.cisa.bean.databean.lspslsdbshow(lsdb.lsdh,lsdb.lsdmc,lsdb.dz,lsdb.dh,lsdb.sjlx,lsdb.lb) from com.cisa.hibernate.sys.data.lspslsdb as lsdb where lsdb.lsbh like :lsdbs or lsdb.lsdmc like :lsdbs order by lsdb.lsdh]rn
hibernate Criteria查询问题。
createCriteria.forClass(A.class).add(Restrictions.like("customerId",arg[0].toString()+"%")) 这个怎么老是提示说java.lang.String cannot be cast to java.lang.Integerjava.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer 转换String我试过了 转换成Int我也试过了 不明白它到底要穿什么类型的参数。请问过的指点一下 谢谢。数组肯定是对的没有问题。现在就是不清楚到底要穿什么类型的值。转换String int 我都试了。rn
Hibernate中Criteria查询常用方法
Hibernate中Criteria查询常用方法
Hibernate的Criteria查询分页示例
[color=red]前言:需要注意的是时间区间的查询,字符串转时间一定要转换正确。[/color] 1、时间转换 [code=&quot;java&quot;] /** * 字符串时间通过Calendar转成Date类型 * * @param date 字符串时间 * * @param format 匹配日期格式 * @r...
懂Hibernate的Criteria查询的进
现在想一个问题。大家在做报表查询的时候。往往会有很多条件给用户选择。比如什么:用户名,经办人,报表时间...rnrn在后台呢,我们拿到用户名。会先判断他是不是空(null或则""),如果是的话,那么我就才把它放到sql的where里面去查询。其他的也是,这里假设查询条件有20个。rnrn我想问一下,用Hibernate来做。rn 第一种方式是HQL(我也最喜欢这种),但是这个要拼接HQL,这样如果20个,代码过于臃肿,而且难看。rnrn 第二种方式用Criteria,这种方式可读性就比较高了,,但是也有个问题。 就是 Criteria怎么用字符串函数呢,怎么用日期函数呢,我们知道HQL里面可以用month(),day(),length()等等,我翻遍了Criteria的Projedction和Restictions都没有找到。这两个只提供一般的逻辑和聚合函数。对于字符串日期(还有很多么,比如:数字)的函数一个字都没有提。但是我敢坚新的是Criteria肯定可以用这些函数,只是我找不到,希望高手解答。rnrn[color=#FF0000]rn问题:rn 第一个问题:Criteria怎么用length之类的函数。(不要告诉我用sqlRestriction(String sql) ,这个是对底层数据库专用的,是SQL不是HQL,所以不垮数据库)rn 第二个问题:大家对很多条件,是不是都要先判断是否为空,或者其他的什么。Hibernate难道没有提供类似的工具?我心里面觉得可能不会吧。[/color]
hibernate的criteria查询的问题
我在用criteria.setFirstResult(0).setMaxResults(limit)时:oracle中没有问题,而在mysql5.0中 rn就提示:Every derived table must have its own alias, rn请指点!
hibernate 做Criteria查询的问题
我想用hibernate的Criteria实现 像 select b FROM Blog b,UserFriendRelation u WHERE b.userId=u.friendUserId AND u.userId=? 这样的查询,应该怎么实现? 其中 b 和 u 不存在任何映射关系。多谢!
hibernate系列十七:Criteria查询
Criteria查询是Hibernate提供的另一种查询方式,与HQL基于字符串的查询形式完全不同。Hibernate提供了org.Hibernate.Criteria接口、org.hibernate.criterion.Criterion接口和org.hibernate.criterion .Restrictions类等Criteria API,用于支持在运行时动态生成查询语句。 1.  条件
Hibernate DetachedCriteria查询的问题
DetachedCriteria criteria = DetachedCriteria.forClass(User.class);rncriteria.add(Restrictions.eq("username", "webmaster"));rncriteria.add(Restrictions.eq("realname", "aaa"));rnservice.count(criteria);rnservice.find(criteria);rnrn代码如上,问题是这样,DetachedCriteria不能只保存查询条件,如果我先执行统计总数,下一个方法查询列表,但是实际查询结果打印的语句还是select count(*) from User,如果把2个方法调换顺序也是不对,不知道各位遇见这个问题了么?rnrnspring2.5.6rnrn在网上找到遇到这个问题的人了,这么描述的。rnDetachedCriteria确实实现的不是很完善,我们希望它是一个无状态的,仅保存查询条件的值对象,但实际上它做不到。一个DetachedCriteria对象反复做分页查询,第一次查询时调用的setMaxResults方法和setFirstResult方法后,这个状态保存在DetachedCriteria上了,会影响下一次count操作,因此每次查询必需new一个DetachedCriteria。同样的原因导致第一个问题交换操作顺序也不行。
Hibernate之Criteria查询及注解
1. 前言 之前从来没有接触过Hibernate,跳槽之后的公司使用的是Hibernate的Criteria查询。简单整理一下。 2.什么是Criteria查询QBC(Query By Criteria) Criteria查询是Hibernate提供的另一种查询方式,比HQL更加面向对象的查询方式 2.1.基本用法 2.1.1.获取Criteria查询对象 Criteria criteria ...
关于Hibernate Criteria查询问题
简单介绍一下出的问题rn A表关联了B,C,D表 当我用Criteria通过A表中唯一字段查询唯一A对象时(此唯一字段是有值的,排除查询A为空这个问题), 在产生的hql中有很多inner join字段,于是就差不出A对象了.rnrn请问是怎么回事 能否详细是说明一下 谢谢
Hibernate的Criteria查询问题
在项目中rn[code=java]rnCriteria criteria=getSession().createCriteria(getEntityClass());rncriteria.add(Restrictions.eq("termNum",mun)); rncriteria.add(Restrictions.eq("termState",1));rnSystem.out.println(criteria.list()); //查不出数据rnString hql="from RTTerminals where termNum="+mun+" and termState="+Property.STATE_USE;rnif (super.find(hql, null).size()<1) rn return null;rnrnreturn (RTTerminals) super.find(hql, null).get(0);rn[/code]rn为什么使用hql就可以查询出来懂 但是使用Criteria 就查询不出来东西rn我是过来.就是criteria.add(Restrictions.eq("termNum",mun));rn加上上面那句就查不出来 rnmun是字符串类型的rn
Hibernate之HQL(Criteria查询)
本教程从基础的三大框架开始介绍,到进行整合,同时加入了FreeMarker模板和Spring OSGI的说明及应用。后以Maven项目进行整理,让学员能够将知识融会贯通,活学活用,把技术知识运用到实际的项目中来。其中分布介绍了,各个框架的基本独立使用,以及后续Maven的安装和应用,包括私服Nexus的搭建解决网络问题。项目中对EasyUI的通用及独特之处均有相应的模板。
hibernate错误"Could not execute query"
我的java代码如下,数据库是oraclernpackage com.frame.db.user;rnrnimport javax.servlet.*;rnimport net.sf.hibernate.*;rnimport net.sf.hibernate.cfg.Configuration;rnimport java.io.*;rnimport java.sql.Date;rnimport java.sql.Timestamp;rnimport java.util.*;rnrnpublic class BusinessServicern public static SessionFactory sessionFactory;rn staticrn tryrn // Create a configuration based on the properties file we've putrn // in the standard place.rn Configuration config = new Configuration();rn config.addClass(UserInfo.class);rn // Get the session factory we can use for persistencern sessionFactory = config.buildSessionFactory();rn catch(Exception e)e.printStackTrace();rn rnrn rnrn rn public void test(ServletContext context,OutputStream out) throws Exceptionrnrn UserInfo userInfo=new UserInfo();rnrn Session session = sessionFactory.openSession();rn Transaction tx = null;rn try rn tx = session.beginTransaction();rn //UserInfo user=(UserInfo)session.load(UserInfo.class,new Long(1));rn Query query = session.createQuery("from user_info where user_id=1");//(UserInfo.class,new Long(1));rn //query.setLong(0, id);rn rn //List list = session.find("from user_info");rn rn List list = query.list();rn if(list.size() > 0)rn rn UserInfo user = (UserInfo)list.get(0);rn System.out.println(user.getLogin_name());rn System.out.println(user.getUser_name());rn rn elsern rn System.out.println("没有找到对应的数据"); rn rn //tx.commit();rn catch (Exception e) rn if (tx != null) rn // Something went wrong; discard all partial changesrn tx.rollback();rn rn throw e;rn finally rn // No matter what, close the sessionrn session.close();rn rnrn rnrn public static void main(String args[]) throws Exception rn new BusinessService().test(null,System.out);rn sessionFactory.close();rn rnrnrnrn运行之后,出现如下错误:rnlog4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).rnlog4j:WARN Please initialize the log4j system properly.rnHibernate: select from where (user_id=1 )rnException in thread "main" net.sf.hibernate.exception.SQLGrammarException: Could not execute queryrn at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)rn at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:30)rn at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:4110)rn at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1556)rn at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)rn at com.frame.db.user.BusinessService.test(BusinessService.java:41)rn at com.frame.db.user.BusinessService.main(BusinessService.java:67)rnCaused by: java.sql.SQLException: ORA-00936: 缺少表达式rnrn at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)rn at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)rn at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)rn at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)rn at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:830)rn at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2391)rn at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2672)rn at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)rn at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:527)rn at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:88)rn at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)rn at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)rn at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)rn at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)rn at net.sf.hibernate.loader.Loader.list(Loader.java:1024)rn at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)rn at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1553)rn ... 3 morern高手们帮忙看看,我写得不对吗?rn
Hibernate 发出这个异常HibernateQueryException: could not resolve property: 请教各位高手怎末办
oplevel of: com.dk.ykt.model.OperFunction [from com.dk.ykt.model.OperFunction as op where op.oplevel=22]; nested exception is org.hibernate.QueryException: could not resolve property: oplevel of: com.dk.ykt.model.OperFunction [from com.dk.ykt.model.OperFunction as op where op.oplevel=22]rnorg.hibernate.QueryException: could not resolve property: oplevel of: com.dk.ykt.model.OperFunction [from com.dk.ykt.model.OperFunction as op where op.oplevel=22]rn at org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException(AbstractPropertyMapping.java:43)rn at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:37)rn at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1265)rn at org.hibernate.hql.ast.tree.FromElementType.getPropertyType(FromElementType.java:279)rn at org.hibernate.hql.ast.tree.FromElement.getPropertyType(FromElement.java:372)rn at org.hibernate.hql.ast.tree.DotNode.getDataType(DotNode.java:539)rn at org.hibernate.hql.ast.tree.DotNode.prepareLhs(DotNode.java:221)rn at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:172)
相关热词 c# 标准差 计算 c#siki第五季 c#入门推荐书 c# 解码海康数据流 c# xml的遍历循环 c# 取 查看源码没有的 c#解决高并发 委托 c#日期转化为字符串 c# 显示问号 c# 字典对象池