0

データベースから値を取得するためのクエリを作成し、jsf ページのデータグリッドに表示します。しかし、私はdaoimpl層で例外的に育てられています。文字列バッファを文字列に変換して配列に取得しているときに、エラーが発生しました。私が行った間違いを見つけてください

DaoImpl.Java

@SuppressWarnings({ "unchecked", "null" })
      @Override
      public List<Barragedetail> searchBarDetails(String offCode) throws Exception {
            System.out.println("Entering AssetDaoImpl");
            System.out.println("Office Code"+offCode);
            List<Barragedetail> barrageBList = null;
            try {
                  barrageBList = new ArrayList<Barragedetail>();
                  StringBuffer queryInfo = new StringBuffer();
                  Query query = null;
                  queryInfo.append(" FROM Eimsuser eu,Barragedetail bd");
                  queryInfo.append(" where eu.usercode = bd.userid");
                  /*if( offCode != null ) {
                        queryInfo.append(" and bd.officecode =:officCode ");
                        //query.setParameter("password", password); 
                        }*/
                        System.out.println("String Buffer"+queryInfo.toString());
                        /*if(offCode != null ) { 
                        query.setParameter("officCode",offCode); 
                        }*/
                        query = entityManager.createQuery(queryInfo.toString()); 
                  barrageBList=query.getResultList();
                  System.out.println("Barrage Size " + barrageBList.size());
                  for (Barragedetail barragedetail : barrageBList) {
                        System.out.println("BarrageName "+ barragedetail.getBarragename());
                        System.out.println("Head Work Type "+ barragedetail.getHeadwrktype());
                  }

            } catch (Exception e) {
                  e.printStackTrace();
                  System.out.println("Exception"+e.getMessage());
            }
            return barrageBList;

      }

スタックレース

String Buffer FROM Eimsuser eu,Barragedetail bd where eu.usercode = bd.userid
java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: userid of: org.gov.tnwrd.entity.Barragedetail [ FROM org.gov.tnwrd.entity.Eimsuser eu,org.gov.tnwrd.entity.Barragedetail bd where eu.usercode = bd.userid]
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1222)
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1168)
    at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:271)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
    at $Proxy114.createQuery(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
    at $Proxy114.createQuery(Unknown Source)
    at org.gov.tnwrd.dao.AssetDaoImpl.searchBarrageDetails(AssetDaoImpl.java:42)
    at org.gov.tnwrd.service.AssetServiceImpl.searchBarrageDetails(AssetServiceImpl.java:31)
    at org.gov.tnwrd.action.AssetAction.searchBarrage(AssetAction.java:115)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.el.parser.AstValue.invoke(AstValue.java:191)
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:101)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.QueryException: could not resolve property: userid of: org.gov.tnwrd.entity.Barragedetail [ FROM org.gov.tnwrd.entity.Eimsuser eu,org.gov.tnwrd.entity.Barragedetail bd where eu.usercode = bd.userid]
    at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:81)
    at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:75)
    at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1465)
    at org.hibernate.hql.ast.tree.FromElementType.getPropertyType(FromElementType.java:315)
    at org.hibernate.hql.ast.tree.FromElement.getPropertyType(FromElement.java:487)
    at org.hibernate.hql.ast.tree.DotNode.getDataType(DotNode.java:611)
    at org.hibernate.hql.ast.tree.DotNode.prepareLhs(DotNode.java:263)
    at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:210)
    at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:117)
    at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:113)
    at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:880)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1330)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4471)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3947)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2047)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:831)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:617)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:244)
    at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254)
    at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
    at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
    at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
    at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
    at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:124)
    at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
    at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
    at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1770)
    at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:268)
    ... 43 more
Exceptionorg.hibernate.QueryException: could not resolve property: userid of: org.gov.tnwrd.entity.Barragedetail [ FROM org.gov.tnwrd.entity.Eimsuser eu,org.gov.tnwrd.entity.Barragedetail bd where eu.usercode = bd.userid]

BarrageDetail.java

package org.gov.tnwrd.entity;

import java.io.Serializable;
import javax.persistence.*;


/**
 * The persistent class for the barragedetails database table.
 * 
 */
@Entity
@Table(name="barragedetails")
public class Barragedetail implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(unique=true, nullable=false)
    private Integer barrageid;

    @Column(length=80)
    private String barragename;

    @Column(length=80)
    private String headworkdt;

    @Column(length=80)
    private String headwrktype;

    @Column(length=80)
    private String latitude;

    @Column(length=80)
    private String location;

    @Column(length=80)
    private String longitude;

    private Integer maxcanalgaugread;

    private Integer maxcanalheaddisch;

    private Integer maxdischdown;

    private Integer maxdowngaugeread;

    @Column(length=80)
    private String maxgaugeupstream;

    @Column(length=80)
    private String officecode;

    @Column(length=50)
    private String season;

    //bi-directional many-to-one association to Block
    @ManyToOne
    @JoinColumn(name="blockid")
    private Block block;

    //bi-directional many-to-one association to District
    @ManyToOne
    @JoinColumn(name="districtid")
    private District district;

    //bi-directional many-to-one association to Division
    @ManyToOne
    @JoinColumn(name="divisionid")
    private Division division;

    //bi-directional many-to-one association to Eimsuser
    @ManyToOne
    @JoinColumn(name="userid")
    private Eimsuser eimsuser;


    //bi-directional many-to-one association to Section
    @ManyToOne
    @JoinColumn(name="sectionid")
    private Section section;

    //bi-directional many-to-one association to Taluk
    @ManyToOne
    @JoinColumn(name="talukid")
    private Taluk taluk;

    public Barragedetail() {
    }

    public Integer getBarrageid() {
        return this.barrageid;
    }

    public void setBarrageid(Integer barrageid) {
        this.barrageid = barrageid;
    }

    public String getBarragename() {
        return this.barragename;
    }

    public void setBarragename(String barragename) {
        this.barragename = barragename;
    }

    public String getHeadworkdt() {
        return this.headworkdt;
    }

    public void setHeadworkdt(String headworkdt) {
        this.headworkdt = headworkdt;
    }

    public String getHeadwrktype() {
        return this.headwrktype;
    }

    public void setHeadwrktype(String headwrktype) {
        this.headwrktype = headwrktype;
    }

    public String getLatitude() {
        return this.latitude;
    }

    public void setLatitude(String latitude) {
        this.latitude = latitude;
    }

    public String getLocation() {
        return this.location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public String getLongitude() {
        return this.longitude;
    }

    public void setLongitude(String longitude) {
        this.longitude = longitude;
    }

    public Integer getMaxcanalgaugread() {
        return this.maxcanalgaugread;
    }

    public void setMaxcanalgaugread(Integer maxcanalgaugread) {
        this.maxcanalgaugread = maxcanalgaugread;
    }

    public Integer getMaxcanalheaddisch() {
        return this.maxcanalheaddisch;
    }

    public void setMaxcanalheaddisch(Integer maxcanalheaddisch) {
        this.maxcanalheaddisch = maxcanalheaddisch;
    }

    public Integer getMaxdischdown() {
        return this.maxdischdown;
    }

    public void setMaxdischdown(Integer maxdischdown) {
        this.maxdischdown = maxdischdown;
    }

    public Integer getMaxdowngaugeread() {
        return this.maxdowngaugeread;
    }

    public void setMaxdowngaugeread(Integer maxdowngaugeread) {
        this.maxdowngaugeread = maxdowngaugeread;
    }

    public String getMaxgaugeupstream() {
        return this.maxgaugeupstream;
    }

    public void setMaxgaugeupstream(String maxgaugeupstream) {
        this.maxgaugeupstream = maxgaugeupstream;
    }

    public String getOfficecode() {
        return this.officecode;
    }

    public void setOfficecode(String officecode) {
        this.officecode = officecode;
    }

    public String getSeason() {
        return this.season;
    }

    public void setSeason(String season) {
        this.season = season;
    }

    public Block getBlock() {
        return this.block;
    }

    public void setBlock(Block block) {
        this.block = block;
    }

    public District getDistrict() {
        return this.district;
    }

    public void setDistrict(District district) {
        this.district = district;
    }

    public Division getDivision() {
        return this.division;
    }

    public void setDivision(Division division) {
        this.division = division;
    }

    public Eimsuser getEimsuser() {
        return this.eimsuser;
    }

    public void setEimsuser1(Eimsuser eimsuser) {
        this.eimsuser = eimsuser;
    }



    public Section getSection() {
        return this.section;
    }

    public void setSection(Section section) {
        this.section = section;
    }

    public Taluk getTaluk() {
        return this.taluk;
    }

    public void setTaluk(Taluk taluk) {
        this.taluk = taluk;
    }

}
4

2 に答える 2