java - “无法在bigint上调用方法。”错误(使用JPA)

时间:2014-05-22 06:23:54

标签: java tsql jpa jpql bigint

我在java中的查询中一直使用JPQL。我遇到了这个问题。

Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: Exception [EclipseLink-4002]  (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Cannot call methods on bigint.
Error Code: 258

这是我在jpql中的查询:

TypedQuery<WholeResultRecord> query = em.createQuery("SELECT NEW project.WholeResultRecord(v,c,h) FROM Vehiclehistory AS h JOIN h.vehicleID AS v ON h.vehicleID = v.vehicleID JOIN h.clientID AS c ON h.clientID = c.clientID",WholeResultRecord.class);
WholeResultRecord result = query.getSingleResult();
result.go();

WholeResultRecord.java

package project;

public class WholeResultRecord {

    private Vehicles vehicle;
    private Clients client;
    private Vehiclehistory history;

    public WholeResultRecord(Vehicles vehicle, Clients client, Vehiclehistory history){
        this.vehicle = vehicle;
        this.client = client;
        this.history = history;
    }

    protected void go(){
        System.out.println(vehicle.toString());
        System.out.println(client.toString());
        System.out.println(history.toString());
    }

}

我认为查询没问题。因为错误行在

  

WholeResultRecord result = query.getSingleResult();

我已经阅读了有关此错误的其他问题,但这些都与我的相关。他们说必须使用 T-SQL 吗?

请帮帮我。谢谢。

Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: Exception [EclipseLink-4002] 

(Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Cannot call methods on bigint.
Error Code: 258
Call: SELECT t0.VehicleID, t0.AutomaticTrans, t0.BodyType, t0.CRNo, t0.CatalyticConverter, t0.ChassisNo, t0.Classification, t0.Color, t0.EngineNo, t0.FuelType, t0.GrossWeight, t0.MVFileNo, t0.MVType, t0.Make, t0.NaturallyAspirated, t0.NetCapacity, t0.ORNo, t0.ORType, t0.PlateNo, t0.Series, t0.Turbo, t0.VehicleFirstReg, t0.YearModel, t2.ClientID, t2.Address, t2.City, t2.FirstName, t2.isCompany, t2.LastName, t2.MiddleName, t1.VehicleHistoryID, t1.AuthenticationNo, t1.BCTechPersonCode, t1.BCUserCode, t1.CECNumber, t1.CertIssued, t1.DENR_Result, t1.DateInserted, t1.DateTimeTested, t1.DateTimeUploaded, t1.DocStatus, t1.EmissionPurpose, t1.HDDSerial, t1.isUrban, t1.LocalCertDateIssued, t1.PETC_AmountPaid, t1.PETC_CompanyCode, t1.PETC_OrNumber, t1.PETC_PriorityNo, t1.PETC_Result, t1.PETC_UnitCode, t1.Remarks, t1.Reprint, t1.Retest, t1.Server_DateUploaded, t1.Server_UploadConfirmationCode, t1.StatusCode, t1.StatusDesc, t1.TEST_OilTemp, t1.Technician, t1.TESDA, t1.TEST_AVE, t1.TEST_CO, t1.TEST_CO2, t1.TEST_HC, t1.TEST_O2, t1.TRAN_ID, t1.VHGuidKey, t1.ClientID, t1.VehicleID FROM vehicles t0, clients t2, vehiclehistory t1 WHERE (((t0.VehicleID = t1.VehicleID) AND (t1.VehicleID = t0.VehicleID.t0.VehicleID)) AND ((t2.ClientID = t1.ClientID) AND (t1.ClientID = t2.ClientID.t2.ClientID)))
Query: ReportQuery(referenceClass=Vehiclehistory sql="SELECT t0.VehicleID, t0.AutomaticTrans, t0.BodyType, t0.CRNo, t0.CatalyticConverter, t0.ChassisNo, t0.Classification, t0.Color, t0.EngineNo, t0.FuelType, t0.GrossWeight, t0.MVFileNo, t0.MVType, t0.Make, t0.NaturallyAspirated, t0.NetCapacity, t0.ORNo, t0.ORType, t0.PlateNo, t0.Series, t0.Turbo, t0.VehicleFirstReg, t0.YearModel, t2.ClientID, t2.Address, t2.City, t2.FirstName, t2.isCompany, t2.LastName, t2.MiddleName, t1.VehicleHistoryID, t1.AuthenticationNo, t1.BCTechPersonCode, t1.BCUserCode, t1.CECNumber, t1.CertIssued, t1.DENR_Result, t1.DateInserted, t1.DateTimeTested, t1.DateTimeUploaded, t1.DocStatus, t1.EmissionPurpose, t1.HDDSerial, t1.isUrban, t1.LocalCertDateIssued, t1.PETC_AmountPaid, t1.PETC_CompanyCode, t1.PETC_OrNumber, t1.PETC_PriorityNo, t1.PETC_Result, t1.PETC_UnitCode, t1.Remarks, t1.Reprint, t1.Retest, t1.Server_DateUploaded, t1.Server_UploadConfirmationCode, t1.StatusCode, t1.StatusDesc, t1.TEST_OilTemp, t1.Technician, t1.TESDA, t1.TEST_AVE, t1.TEST_CO, t1.TEST_CO2, t1.TEST_HC, t1.TEST_O2, t1.TRAN_ID, t1.VHGuidKey, t1.ClientID, t1.VehicleID FROM vehicles t0, clients t2, vehiclehistory t1 WHERE (((t0.VehicleID = t1.VehicleID) AND (t1.VehicleID = t0.VehicleID.t0.VehicleID)) AND ((t2.ClientID = t1.ClientID) AND (t1.ClientID = t2.ClientID.t2.ClientID)))")
    at org.eclipse.persistence.internal.jpa.QueryImpl.getDetailedException(QueryImpl.java:378)
    at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:260)
    at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:469)

等...

我的表格是Vehiclehistory,Clients,Vehicles。

enter image description here

0 个答案:

没有答案