我正在尝试在JPA中执行自定义查询(SELECT URI AS NUMBER_URI FROM TSRECORD
),并且收到以下错误消息:
java.sql.SQLException:无效的列名
能否请您帮我解决此错误?
SpringBootApplication.java:
@SpringBootApplication
public class RecordDisposal1Application
{
public static void main(String[] args)
{
SpringApplication.run(RecordDisposal1Application.class, args);
}
}
Repository.java:
@org.springframework.stereotype.Repository
public interface Repository extends JpaRepository<tsrecord, Integer>
{
@Query(nativeQuery = true, value="SELECT URI as NUMBER_URI FROM TSRECORD WHERE RCRECTYPEURI NOT IN ('264','263')")
public List<tsrecord> findAllbyPaperRecord();
}
tsrecord.java:
@实体 @Table(name =“ TSRECORD”) 公开课tsrecord {
public tsrecord(){}
@Id
@GeneratedValue
@Column(name ="URI",columnDefinition ="NUMBER(38,0)")
public Long URI;
@Column(name ="RECORDID",columnDefinition ="NVARCHAR2(50 CHAR)")
public String RECORDID;
@Column(name ="TITLE",columnDefinition ="NVARCHAR2(254 CHAR)")
public String TITLE;
@Column(name ="RCSCHEDULEURI",columnDefinition ="NUMBER(38,0)")
public Long RCSCHEDULEURI;
@Column(name ="RCRECTYPEURI",columnDefinition ="NUMBER(38,0)")
public Long RCRECTYPEURI;
@Column(name ="RCFILEPLANURI",columnDefinition ="NUMBER(38,0)")
public Long RCFILEPLANURI;
@Column(name ="RCSECLEVEL",columnDefinition ="NUMBER(38,0)")
public Long RCSECLEVEL;
@Column(name ="RCNOTES",columnDefinition ="CHAR(1 BYTE)")
public String RCNOTES;
@Column(name ="ACCESSIONNBR",columnDefinition ="NUMBER(38,0)")
public Long ACCESSIONNBR;
@Column(name ="EXTERNALID",columnDefinition ="NVARCHAR2(50 CHAR)")
public String EXTERNALID;
@Column(name ="PRIORITY",columnDefinition ="NCHAR(5 CHAR)")
public String PRIORITY;
@Column(name ="ISPART",columnDefinition ="CHAR(1 BYTE)")
public String ISPART;
@Column(name ="ISROOT",columnDefinition ="CHAR(1 BYTE)")
public String ISROOT;
@Column(name ="ISRELATED",columnDefinition ="CHAR(1 BYTE)")
public String ISRELATED;
@Column(name ="ISPARENT",columnDefinition ="CHAR(1 BYTE)")
public String ISPARENT;
@Column(name ="ISATTACHED",columnDefinition ="CHAR(1 BYTE)")
public String ISATTACHED;
@Column(name ="FULLRECORDID",columnDefinition ="NVARCHAR2(50 CHAR)")
public String FULLRECORDID;
@Column(name ="CONSIGNMENT",columnDefinition ="NVARCHAR2(50 CHAR)")
public String CONSIGNMENT;
@Column(name ="CURRDISP",columnDefinition ="NUMBER(38,0)")
public Long CURRDISP;
@Column(name ="RCCLASS",columnDefinition ="NUMBER(38,0)")
public Long RCCLASS;
@Column(name ="RCCONTAINERURI",columnDefinition ="NUMBER(38,0)")
public Long RCCONTAINERURI;
@Column(name ="RCACCESSLOC",columnDefinition ="NUMBER(38,0)")
public Long RCACCESSLOC;
@Column(name ="RCSTRUCTUREDTITLE",columnDefinition ="NVARCHAR2(512 CHAR)")
public String RCSTRUCTUREDTITLE;
@Column(name ="REGDATETIME",columnDefinition ="CHAR(15 BYTE)")
public String REGDATETIME;
@Column(name ="CREATIONDATETIME",columnDefinition ="CHAR(15 BYTE)")
public String CREATIONDATETIME;
@Column(name ="CLOSEDATETIME",columnDefinition ="CHAR(15 BYTE)")
public String CLOSEDATETIME;
@Column(name ="RCDUEDATETIME",columnDefinition ="CHAR(15 BYTE)")
public String RCDUEDATETIME;
@Column(name ="LASTACTIONDATETIME",columnDefinition ="CHAR(15 BYTE)")
public String LASTACTIONDATETIME;
@Column(name ="INACTIVEDATETIME",columnDefinition ="CHAR(15 BYTE)")
public String INACTIVEDATETIME;
@Column(name ="RCFINALIZEDDATE",columnDefinition ="CHAR(15 BYTE)")
public String RCFINALIZEDDATE;
@Column(name ="RCREVIEWDATE",columnDefinition ="CHAR(15 BYTE)")
public String RCREVIEWDATE;
@Column(name ="HASHOLD",columnDefinition ="CHAR(1 BYTE)")
public String HASHOLD;
@Column(name ="RCDATEPUBLISHED",columnDefinition ="CHAR(15 BYTE)")
public String RCDATEPUBLISHED;
@Column(name ="RCACCESSISCONT",columnDefinition ="CHAR(1 BYTE)")
public String RCACCESSISCONT;
@Column(name ="RCLINKEDTOCOUNT",columnDefinition ="NUMBER(38,0)")
public Long RCLINKEDTOCOUNT;
@Column(name ="RCRECTYPESECFILTER",columnDefinition ="NUMBER(38,0)")
public Long RCRECTYPESECFILTER;
@Column(name ="RCAUTOPARTURI",columnDefinition ="NUMBER(38,0)")
public Long RCAUTOPARTURI;
@Column(name ="SYSLASTUPDATED",columnDefinition ="CHAR(15 BYTE)")
public String SYSLASTUPDATED;
@Column(name ="RCORIGIN",columnDefinition ="NUMBER(38,0)")
public Long RCORIGIN;
@Column(name ="RCDATEIMPORTED",columnDefinition ="CHAR(15 BYTE)")
public String RCDATEIMPORTED;
@Column(name ="RCSPURL",columnDefinition ="NVARCHAR2(255 CHAR)")
public String RCSPURL;
@Column(name ="RCSPGUID",columnDefinition ="NCHAR(32 CHAR)")
public String RCSPGUID;
@Column(name ="RCSPFARMID",columnDefinition ="NCHAR(32 CHAR)")
public String RCSPFARMID;
@Column(name ="RCSPLISTTYPE",columnDefinition ="NVARCHAR2(255 CHAR)")
public String RCSPLISTTYPE;
@Column(name ="RCSPSITECOLLID",columnDefinition ="NCHAR(32 CHAR)")
public String RCSPSITECOLLID;
@Column(name ="RCMEDIATYPE",columnDefinition ="NUMBER(38,0)")
public Long RCMEDIATYPE;
@Column(name ="RCFOLDERORIGIN",columnDefinition ="NUMBER(38,0)")
public Long RCFOLDERORIGIN;
@Column(name ="RC1CAVEAT",columnDefinition ="NUMBER(38,0)")
public Long RC1CAVEAT;
@Column(name ="RC2CAVEAT",columnDefinition ="NUMBER(38,0)")
public Long RC2CAVEAT;
@Column(name ="RC3CAVEAT",columnDefinition ="NUMBER(38,0)")
public Long RC3CAVEAT;
@Column(name ="RC4CAVEAT",columnDefinition ="NUMBER(38,0)")
public Long RC4CAVEAT;
@Column(name ="RC5CAVEAT",columnDefinition ="NUMBER(38,0)")
public Long RC5CAVEAT;
@Column(name ="RC6CAVEAT",columnDefinition ="NUMBER(38,0)")
public Long RC6CAVEAT;
@Column(name ="RC7CAVEAT",columnDefinition ="NUMBER(38,0)")
public Long RC7CAVEAT;
@Column(name ="RC8CAVEAT",columnDefinition ="NUMBER(38,0)")
public Long RC8CAVEAT;
@Column(name ="SYSLASTUPDATEDBY",columnDefinition ="NUMBER(38,0)")
public Long SYSLASTUPDATEDBY;
@Column(name ="RCSCHINACTIVECALC",columnDefinition ="NUMBER(38,0)")
public Long RCSCHINACTIVECALC;
@Column(name ="RCSCHINACTIVE",columnDefinition ="CHAR(8 CHAR)")
public String RCSCHINACTIVE;
@Column(name ="RCDISPOSALKEY",columnDefinition ="CHAR(9 CHAR)")
public String RCDISPOSALKEY;
@Column(name ="RCSCHDISPOSALKEY",columnDefinition ="CHAR(9 CHAR)")
public String RCSCHDISPOSALKEY;
@Column(name ="RCSCHDISPCALC",columnDefinition ="NUMBER(38,0)")
public Long RCSCHDISPCALC;
@Column(name ="RCHASLONGEVITYFMT",columnDefinition ="CHAR(1 BYTE)")
public String RCHASLONGEVITYFMT;
@Column(name ="RCHASREDACTABLEFMT",columnDefinition ="CHAR(1 BYTE)")
public String RCHASREDACTABLEFMT;
@Column(name ="RCHASOCRFMT",columnDefinition ="CHAR(1 BYTE)")
public String RCHASOCRFMT;
@Column(name ="RCCLIENTRECORD",columnDefinition ="NUMBER(38,0)")
public Long RCCLIENTRECORD;
@Column(name ="RCMATTERRECORD",columnDefinition ="NUMBER(38,0)")
public Long RCMATTERRECORD;
@Column(name ="RCCONSIGNMENTURI",columnDefinition ="NUMBER(38,0)")
public Long RCCONSIGNMENTURI;
@Column(name ="RCAUTOCONFIDENCE",columnDefinition ="NUMBER(38,0)")
public Long RCAUTOCONFIDENCE;
@Column(name ="RCDATESUPERSEDED",columnDefinition ="CHAR(15 BYTE)")
public String RCDATESUPERSEDED;
@Column(name ="RCDATERECEIVED",columnDefinition ="CHAR(15 BYTE)")
public String RCDATERECEIVED;
@Column(name ="RCGEOGRAPHY",columnDefinition ="SDO_GEOMETRY")
public String RCGEOGRAPHY;
@Column(name ="RCNEEDSREVIEW",columnDefinition ="CHAR(1 BYTE)")
public String RCNEEDSREVIEW;
@Column(name ="RCNEEDSAUTHORIZATION",columnDefinition ="CHAR(1 BYTE)")
public String RCNEEDSAUTHORIZATION;
@Column(name ="RCAUTHORIZATIONMETHOD",columnDefinition ="NUMBER(38,0)")
public Long RCAUTHORIZATIONMETHOD;
@Column(name ="RCREVIEWSTATE",columnDefinition ="NUMBER(38,0)")
public Long RCREVIEWSTATE;
@Column(name ="RCREVIEWSTATEDATE",columnDefinition ="CHAR(15 BYTE)")
public String RCREVIEWSTATEDATE;
@Column(name ="RCREVIEWDUEDATE",columnDefinition ="CHAR(15 BYTE)")
public String RCREVIEWDUEDATE;
@Column(name ="RCACLGROUPKEY",columnDefinition ="NUMBER(38,0)")
public Long RCACLGROUPKEY;
@Column(name ="RCACLCONTAINER",columnDefinition ="NUMBER(38,0)")
public Long RCACLCONTAINER;
@Column(name ="RCACLEXCLUSION",columnDefinition ="NUMBER(38,0)")
public Long RCACLEXCLUSION;
/ 获取器和设置器 /
controller.java:
@Controller
public class controller {
@Autowired
DataSource dataSource;
@Autowired
Repository Repository;
@RequestMapping("/")
public Iterable<tsrecord> show()
{
return Repository.findAll();
}
@RequestMapping("/home")
public String home()
{
return "dashboard";
}
@RequestMapping("/paper")
public String showpaper(HttpServletRequest req)
{
req.setAttribute("paper",Repository.findAllbyPaperRecord());
return "P_records";
}
}
堆栈跟踪:
java.sql.SQLException:无效的列名位于 oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:4146) 〜[ojdbc7-12.1.0.2.jar:12.1.0.2.0]在 oracle.jdbc.driver.InsensitiveScrollableResultSet.findColumn(InsensitiveScrollableResultSet.java:300) 〜[ojdbc7-12.1.0.2.jar:12.1.0.2.0]在 oracle.jdbc.driver.GeneratedResultSet.getLong(GeneratedResultSet.java:1361) 〜[ojdbc7-12.1.0.2.jar:12.1.0.2.0]在 com.zaxxer.hikari.pool.HikariProxyResultSet.getLong(HikariProxyResultSet.java) 〜[HikariCP-3.2.0.jar:na]在 org.hibernate.type.descriptor.sql.BigIntTypeDescriptor $ 2.doExtract(BigIntTypeDescriptor.java:63) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:47) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:261) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:257) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:247) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:333) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.loader.Loader.extractKeysFromResultSet(Loader.java:793) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:718) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.loader.Loader.processResultSet(Loader.java:990) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.loader.Loader.doQuery(Loader.java:948) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:340) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.loader.Loader.doList(Loader.java:2689) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.loader.Loader.doList(Loader.java:2672) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2506) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.loader.Loader.list(Loader.java:2501) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:338) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:2223) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.internal.AbstractSharedSessionContract.list(AbstractSharedSessionContract.java:1053) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.query.internal.NativeQueryImpl.doList(NativeQueryImpl.java:170) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1505) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.hibernate.query.Query.getResultList(Query.java:135) 〜[hibernate-core-5.3.7.Final.jar:5.3.7.Final]在 org.springframework.data.jpa.repository.query.JpaQueryExecution $ CollectionExecution.doExecute(JpaQueryExecution.java:129) 〜[spring-data-jpa-2.1.5.RELEASE.jar:2.1.5.RELEASE]在 org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:91) 〜[spring-data-jpa-2.1.5.RELEASE.jar:2.1.5.RELEASE]在 org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:136) 〜[spring-data-jpa-2.1.5.RELEASE.jar:2.1.5.RELEASE]在 org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:125) 〜[spring-data-jpa-2.1.5.RELEASE.jar:2.1.5.RELEASE]