Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Hibernate EJB非法辩论_Java_Hibernate_Ejb_Ejb 3.1 - Fatal编程技术网

Java Hibernate EJB非法辩论

Java Hibernate EJB非法辩论,java,hibernate,ejb,ejb-3.1,Java,Hibernate,Ejb,Ejb 3.1,我有一个神秘的HibernateQL异常。它包括三类: package com.systemspecs.Entity; import java.io.Serializable; import java.util.Date; import javax.persistence.*; /** * * @ * @author-Admin */ @Entity @Table(name = "echequeupload") @DiscriminatorColumn(name = "TYPE",

我有一个神秘的HibernateQL异常。它包括三类:

package com.systemspecs.Entity;

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

/**
 *
 * @
 * @author-Admin
 */
@Entity
@Table(name = "echequeupload")
@DiscriminatorColumn(name = "TYPE", discriminatorType = DiscriminatorType.STRING)
public class EchequeUpload implements Serializable {

    private Long id;
    private String bank_acronym = "";
    private String accountHolderId = "";
    private String accountNumber = "";
    private Double trasanctionAmount = 0.0;
    private String shortDesc = "";
    private String longDesc = "";
    private String filePath = "";
    private Long batchNo = new Long(System.currentTimeMillis());
    private Date transactionDate = new Date();
    private String status = "OK";
    private String idNumber = "";
    private String surname = "";
    private String firstname = "";
    private String othernames = "";
    private String switch_id = "";
    private String accountType = "";
    private String payPeriod = "";
    private String company_id = "";
    private String mobile = "";
    private String email = "";
    private String uploadType = "";
    private String processed = "OK";
    private Account account = null;
    private String variance = null;
    private String rejected = "N";
    private Double grossAmount = 0.0;
    private Double withholdingTax = 0.0;
    private String taxOffice = "";
    private Double whtRate = 0.0;
    private String taxFlag = "OK";
    private String bankBranch;
    private String taxState;
    private String bankName;
    private Long dividendId;
    private String customerNumber="";

    /** Creates a new instance of PensionSalary */
    public EchequeUpload() {
    }
    public EchequeUpload(String bank_acronym, String accountNumber, String accountType, Double trasanctionAmount,
            String shortDesc, String longDesc, String surname, String mobile, String email, Double whtRate, String taxOffice,
            Long batchNo, String company_id, Long dividendId,String customerNumber) {
        this.bank_acronym = bank_acronym;
        this.accountNumber = accountNumber;
        this.accountType = accountType;
        this.trasanctionAmount = trasanctionAmount;
        this.shortDesc = shortDesc;
        this.longDesc = longDesc;
        this.surname = surname;
        this.mobile = mobile;
        this.email = email;
        this.whtRate = whtRate;
        this.taxOffice = taxOffice;
        this.batchNo = batchNo;
        this.company_id = company_id;
        this.dividendId=dividendId;
        this.customerNumber=customerNumber;

    }
    public EchequeUpload(String bank_acronym, String accountNumber, String accountType, Double trasanctionAmount,
            String shortDesc, String longDesc, String surname, String mobile, String email, Double whtRate, String taxOffice,
            Long batchNo, String company_id, Long dividendId) {
        this.bank_acronym = bank_acronym;
        this.accountNumber = accountNumber;
        this.accountType = accountType;
        this.trasanctionAmount = trasanctionAmount;
        this.shortDesc = shortDesc;
        this.longDesc = longDesc;
        this.surname = surname;
        this.mobile = mobile;
        this.email = email;
        this.whtRate = whtRate;
        this.taxOffice = taxOffice;
        this.batchNo = batchNo;
        this.company_id = company_id;
        this.dividendId=dividendId;

    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

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

    public String getBank_acronym() {
        return bank_acronym;
    }

    public void setBank_acronym(String bank_acronym) {
        if (bank_acronym != null) {
            this.bank_acronym = bank_acronym.trim();
        }
    }

    public String getAccountHolderId() {
        return accountHolderId;
    }

    public void setAccountHolderId(String accountHolderId) {
        if (accountHolderId != null) {
            this.accountHolderId = accountHolderId.trim();
        }
    }

    public Double getTrasanctionAmount() {
        return trasanctionAmount;
    }

    public void setTrasanctionAmount(Double trasanctionAmount) {
        if (trasanctionAmount != null)
            this.trasanctionAmount = trasanctionAmount;
    }

    public String getShortDesc() {
        return shortDesc;
    }

    public void setShortDesc(String shortDesc) {
        if (shortDesc != null) {
            this.shortDesc = shortDesc.trim();
        }
    }

    public String getAccountNumber() {
        return accountNumber;
    }

    public void setAccountNumber(String accountNumber) {
        if (accountNumber != null) {
            this.accountNumber = accountNumber.trim();
        }
    }

    public String getLongDesc() {
        return longDesc;
    }

    public void setLongDesc(String longDesc) {
        if (longDesc != null) {
            this.longDesc = longDesc.trim();
        }
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        if (filePath != null) {
            this.filePath = filePath.trim();
        }
    }

    public Date getTransactionDate() {
        return transactionDate;
    }

    public void setTransactionDate(Date transactionDate) {
        this.transactionDate = transactionDate;
    }

    public Long getBatchNo() {
        return batchNo;
    }

    public void setBatchNo(Long batchNo) {
        this.batchNo = batchNo;
    }

    public String getStatus() {
        return status;
    }

    public String getCustomerNumber() {
        return customerNumber;
    }

    public void setCustomerNumber(String customerNumber) {
        this.customerNumber = customerNumber;
    }

    public void setStatus(String status) {
        if (status != null) {
            this.status = status.trim();
        }
    }

    public String getAccountType() {
        return accountType;
    }

    public void setAccountType(String accountType) {
        if (accountType != null) {
            this.accountType = accountType.trim();
        }
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        if (email != null) {
            this.email = email.trim();
        }
    }

    public String getCompany_id() {
        return company_id;
    }

    public void setCompany_id(String company_id) {
        if (company_id != null) {
            this.company_id = company_id.trim();
        }
    }

    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        if (firstname != null) {
            this.firstname = firstname.trim();
        }
    }

    public String getIdNumber() {
        return idNumber;
    }

    public void setIdNumber(String idNumber) {
        if (idNumber != null) {
            this.idNumber = idNumber.trim();
        }
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        if (mobile != null) {
            this.mobile = mobile.trim();
        }
    }

    public String getPayPeriod() {
        return payPeriod;
    }

    public void setPayPeriod(String payPeriod) {
        if (payPeriod != null) {
            this.payPeriod = payPeriod.trim();
        }
    }

    public String getProcessed() {
        return processed;
    }

    public void setProcessed(String processed) {
        if (processed != null) {
            this.processed = processed.trim();
        }
    }

    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        if (surname != null) {
            this.surname = surname.trim();
        }
    }

    public String getSwitch_id() {
        return switch_id;
    }

    public void setSwitch_id(String switch_id) {
        if (switch_id != null) {
            this.switch_id = switch_id.trim();
        }
    }

    public String getUploadType() {
        return uploadType;
    }

    public void setUploadType(String uploadType) {
        if (uploadType != null) {
            this.uploadType = uploadType.trim();
        }
    }

    public String getOthernames() {
        return othernames;
    }

    public void setOthernames(String othernames) {
        if (othernames != null) {
            this.othernames = othernames.trim();
        }
    }

    @ManyToOne
    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    @Column
    public String getVariance() {
        return variance;
    }

    public void setVariance(String variance) {
        this.variance = variance;
    }

    @Column
    public String getRejected() {
        return rejected;
    }

    public void setRejected(String rejected) {
        this.rejected = rejected;
    }

    public Double getGrossAmount() {
        return grossAmount;
    }

    public void setGrossAmount(Double grossAmount) {
        if (grossAmount != null) {
            this.grossAmount = grossAmount;
        }
    }

    public String getTaxOffice() {
        return taxOffice;
    }

    public void setTaxOffice(String taxOffice) {
        this.taxOffice = taxOffice;
    }

    public Double getWithholdingTax() {
        return withholdingTax;
    }

    public void setWithholdingTax(Double withholdingTax) {
        if (withholdingTax != null) {
            this.withholdingTax = withholdingTax;
        }
    }

    public Double getWhtRate() {
        return whtRate;
    }

    public void setWhtRate(Double whtRate) {
        if (whtRate != null) {
            this.whtRate = whtRate;
        }
    }

    @Column(length = 4)
    public String getTaxFlag() {
        return taxFlag;
    }

    public void setTaxFlag(String taxFlag) {
        if (taxFlag != null) {
            this.taxFlag = taxFlag;
        }
    }

    /**
     * @return the bankBranch
     */
    public String getBankBranch() {
        return bankBranch;
    }

    /**
     * @param bankBranch the bankBranch to set
     */
    public void setBankBranch(String bankBranch) {
        this.bankBranch = bankBranch;
    }

    /**
     * @return the taxState
     */
    public String getTaxState() {
        return taxState;
    }

    /**
     * @param taxState the taxState to set
     */
    public void setTaxState(String taxState) {
        this.taxState = taxState;
    }

    /**
     * @return the bankName
     */
    public String getBankName() {
        return bankName;
    }

    /**
     * @param bankName the bankName to set
     */
    public void setBankName(String bankName) {
        this.bankName = bankName;
    }

    /**
     * @return the dividendId
     */
    public Long getDividendId() {
        return dividendId;
    }

    /**
     * @param dividendId the dividendId to set
     */
    public void setDividendId(Long dividendId) {
        this.dividendId = dividendId;
    }
}
其他两类没有关联。我将两个不相关的类CustomerLimits和DividendUpload通过公共字段
customerNumber

public List<EchequeUpload> findUploadedAllByTransactionIDAndCustomerNumber(
            Long transaction_id) {
        String ql = "select new EchequeUpload(c.account.switch.switchId, c.account.accountnumber, c.account.accountType, nvl(d.amount,0), ";
        ql += "d.shortDescription, d.longDescription, c.accountHolder.name, c.accountHolder.mobile, c.accountHolder.email, nvl(d.tax,0), d.taxState, ";
        ql += "d.batchNo, d.company_id, d.id,d.customerNumber) from DividendUpload d , CustomerLimits c where d.customerNumber=c.customerNumber and d.transaction_id=?1";

        return this.entityManager.createQuery(ql).setParameter(1,
                transaction_id).setHint("org.hibernate.cacheable",
                new Boolean(true)).setHint("org.hibernate.readOnly",
                new Boolean(true)).getResultList();
    }
公共列表FindUpLoadedAllByTransactionId和CustomerNumber(
长事务(U id){
String ql=“选择新的EchequeUpload(c.account.switch.switchId,c.account.accountnumber,c.account.accountType,nvl(d.amount,0),”;
ql+=“d.shortDescription,d.longsdescription,c.accountHolder.name,c.accountHolder.mobile,c.accountHolder.email,nvl(d.tax,0),d.taxState,”;
ql+=“d.batchNo,d.company_id,d.id,d.customerNumber)来自DividendUpload d,CustomerLimits c,其中d.customerNumber=c.customerNumber和d.transaction_id=?1”;
返回此.entityManager.createQuery(ql).setParameter(1,
事务id).setHint(“org.hibernate.cacheable”,
新建布尔值(true)).setHint(“org.hibernate.readOnly”,
新的布尔值(true)).getResultList();
}
现在的问题是,它一直给我这个错误。IllegalArgumentException自然会表明我的构造函数不正确,但它是正确的。事实上,这是非常正确的,所以我在这里不知所措

    2011-02-25 15:37:34,968 ERROR [org.hibernate.hql.PARSER]  Unable to locate appropriate constructor on class [com.systemspecs.Entity.EchequeUpload]
[cause=org.hibernate.PropertyNotFoundException: no appropriate constructor in class: com.systemspecs.Entity.EchequeUpload]
2011-02-25 15:37:35,015 INFO  [STDOUT] In error================================:
2011-02-25 15:37:35,015 ERROR [STDERR] java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [com.systemspecs.Entity.EchequeUpload] [select new EchequeUpload(c.account.switch.switchId, c.account.accountnumber, c.account.accountType, nvl(d.amount,0), d.shortDescription, d.longDescription, c.accountHolder.name, c.accountHolder.mobile, c.accountHolder.email, nvl(d.tax,0), d.taxState, d.batchNo, d.company_id, d.id,d.customerNumber) from com.systemspecs.Entity.DividendUpload d , com.systemspecs.Entity.CustomerLimits c where d.customerNumber=c.customerNumber and d.transaction_id=?1]
2011-02-25 15:37:35,031 ERROR [STDERR]  at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:616)
2011-02-25 15:37:35,031 ERROR [STDERR]  at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:95)
2011-02-25 15:37:35,046 ERROR [STDERR]  at org.jboss.ejb3.entity.TransactionScopedEntityManager.createQuery(TransactionScopedEntityManager.java:134)
2011-02-25 15:37:35,046 ERROR [STDERR]  at com.systemspecs.dao.EchequeUploadDAO.findUploadedAllByTransactionIDAndCustomerNumber(EchequeUploadDAO.java:103)
2011-02-25 15:37:35,046 ERROR [STDERR]  at com.systemspecs.businessobjects.EchequeUploadService2.saveEchequeUpload(EchequeUploadService2.java:705)
2011-02-25 15:37:35,046 ERROR [STDERR]  at com.systemspecs.businessobjects.EchequeUploadService2$$FastClassByCGLIB$$c253fe58.invoke(<generated>)
2011-02-25 15:37:35,046 ERROR [STDERR]  at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
2011-02-25 15:37:35,046 ERROR [STDERR]  at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
2011-02-25 15:37:34968错误[org.hibernate.hql.PARSER]在类[com.systemspecs.Entity.EchequeUpload]上找不到合适的构造函数
[原因=org.hibernate.PropertyNotFoundException:类com.systemspecs.Entity.EchequeUpload中没有合适的构造函数]
2011-02-25 15:37:35015信息[STDOUT]出错=
2011-02-25 15:37:35015错误[STDERR]java.lang.IllegalArgumentException:org.hibernate.hql.ast.QuerySyntaxException:无法在类[com.systemspecs.Entity.EchequeUpload]上找到合适的构造函数][选择新的EchequeUpload(c.account.switch.switchId,c.account.accountnumber,c.account.accountType,nvl(d.amount,0),d.shortDescription,d.longsdescription,c.accountHolder.name,c.accountHolder.mobile,c.accountHolder.email,nvl(d.tax,0),d.taxState,d.batchNo,d.company_id,d.id,d.customerNumber)来自com.systemspecs.Entity.DividendUpload,com.systemspecs.Entity.CustomerLimits c其中d.customerNumber=c.customerNumber和d.transaction_id=?1]
2011-02-25 15:37:35031 org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException上的错误[STDERR](AbstractEntityManagerImpl.java:616)
2011-02-25 15:37:35031 org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:95)上的错误[STDERR]
2011-02-25 15:37:35046 org.jboss.ejb3.entity.TransactionScopedEntityManager.createQuery(TransactionScopedEntityManager.java:134)上的错误[STDERR]
2011-02-25 15:37:35046 com.systemspecs.dao.EchequeUploadDAO.finduploatedAllByTransactionId和CustomerNumber上的错误[STDERR](EchequeUploadDAO.java:103)
2011-02-25 15:37:35046 com.systemspecs.businessobjects.EchequeUploadService2.saveEchequeUpload(EchequeUploadService2.java:705)上的错误[STDERR]
2011-02-25 15:37:35046 com.systemspecs.businessobjects.EchequeUploadService2$$FastClassByCGLIB$$c253fe58.invoke()上的错误[STDERR]
2011-02-25 15:37:35046 net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)处的错误[STDERR]
2011-02-25 15:37:35046 org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)上的错误[STDERR]

我想说-从查询中删除那个巨大的构造函数。查询中没有编译时安全性,因此必须手动验证每个参数的类型和正确顺序,等等-这是一个维护地狱


相反,选择从中获取字段的实体,并用纯Java构建对象。最好使用一个构建器,而不是一个有这么多参数的构造函数——这是一种“代码味道”——从查询中删除那个巨大的构造函数。查询中没有编译时安全性,因此必须手动验证每个参数的类型和正确顺序,等等-这是一个维护地狱


相反,选择从中获取字段的实体,并用纯Java构建对象。最好使用一个构建器,而不是一个有这么多参数的构造函数-这是一种“代码气味”

你的两个构造函数每个都有15个参数(

在hql构造函数中,您将通过14


例外意味着什么。你拥有的构造器和你认为拥有的构造器没有写出来……此外,正如一条评论所指出的,很可能某些类型是不正确的。

你的两个构造器每个都有15个参数(

在hql构造函数中,您将通过14


例外意味着什么。你拥有的构造函数和你认为拥有的构造函数没有写出来……此外,正如一条评论所指出的,很可能有些类型是不正确的。

没有,他在查询中也有15个参数。我数了两次。但不要介意有一个好的规则:如果你的函数有3个以上的参数,你至少忘记了一个。例如,切勿编写此类API。你没有发给我们的课程是相关的。我认为您使用的某些参数类型错误。特别是检查长和双。你确定所有的长参数都很长(不是int)吗?如果你包含了无参数的构造函数,那么就有两个或者三个构造函数。一个是14,另一个是15。@chinedu,关键是另一个开发人员不应该信任你;)他们应该能够在几秒钟内验证构造函数是否正确。@hvgotcodes:你是对的,这和我说的一样。我只是在维护代码,我不是最初写代码的人。我还没有让它工作。yetNo,他在查询中也有15个参数。我数了两次。但别介意有一条好规则:如果函数有3个以上的参数,那么