I am a newbie here and need some expertise help for my problem, it get me stuck for a long time and project needs due soon. I really appreciate help from here.
I'm trying to grab some records from tables and views and insert the results into a new table. The query runs fine in oracle sql developer, but throws ORA-00904 when it runs in the application. Here is the stack trace: insert into g2proto.watch_list ( device_id, device_name, interface_id, interface_name, cpu_percent, memory_percent, traffic_thruput_mb, in_percent_util, out_percent_util, in_errors, out_errors, in_discards, out_discards, trk_crt_date) select t.device_id, t.device_name, i.interface_id, i.name as interface_name, t.cpu_percent, t.memory_percent, round(nvl(it.out_throughput, 0)+nvl(it.in_throughput, 0)/1000000, 2) as traffic_thruput_mb, round(nvl(it.in_percent_util, 0), 2) as in_percent_util, round(nvl(it.out_percent_util, 0), 2) as out_percent_util, round(nvl(it.in_errors, 0), 2) as in_errors, round(nvl(it.out_errors, 0), 2) as out_errors, round(nvl(it.in_discards, 0), 2) as in_discards, round(nvl(it.out_discards, 0), 2) as out_discards, sysdate as trk_crt_date from (select d.device_id, d.tid as device_name, round(nvl(dt.cpu_5min, 0), 2) as cpu_percent, round(nvl(dt.mem_percent, 0), 2) as memory_percent from G2PROTO.device_data_vw dt, G2PROTO.devices d where d.tid = ? and d.device_id = dt.device_id and dt.collect_time = ( select Max(collect_time) from G2PROTO.device_data_vw ) ) t, G2PROTO.interface_data_vw it, G2PROTO.interfaces i where t.device_id = i.device_id and i.interface_id = it.interface_id and it.collect_time = ( select Max(collect_time) from G2PROTO.interface_data_vw ) 12:49:13,555 ERROR [STDERR] 195009 [http-127.0.0.1-8080-1] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 904, SQLState: 42000 12:49:13,555 ERROR [STDERR] 195009 [http-127.0.0.1-8080-1] ERROR org.hibernate.util.JDBCExceptionReporter - ORA-00904: "OUT_DISCARDS": invalid identifier 12:49:13,617 ERROR [application] org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute native bulk manipulation query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query javax.faces.el.EvaluationException: org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute native bulk manipulation query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query at com.sun.faces.application.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
WatchList.hbm.xml: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Mapping file autogenerated by MyEclipse Persistence Tools --> <hibernate-mapping> <class name="com.cox.tsd.gen2.model.iad.WatchList" table="WATCH_LIST" schema="G2PROTO"> <id name="watchId" type="java.math.BigDecimal"> <column name="WATCH_ID" precision="22" scale="0" /> <generator class="sequence"></generator> </id> <many-to-one name="user" class="com.cox.tsd.gen2.model.iad.User"> <column name="USER_ID" precision="15" scale="0" /> </many-to-one> <many-to-one name="deviceInterface" class="com.cox.tsd.gen2.model.iad.DeviceInterface"> <column name="INTERFACE_ID" precision="15" scale="0" not-null="true" /> </many-to-one> <many-to-one name="device" class="com.cox.tsd.gen2.model.iad.Device"> <column name="DEVICE_ID" precision="15" scale="0" not-null="true" /> </many-to-one> <property name="deviceName" type="java.lang.String"> <column name="DEVICE_NAME" length="150" /> </property> <property name="interfaceName" type="java.lang.String"> <column name="INTERFACE_NAME" length="100" /> </property> <property name="cpuPercent" type="java.lang.Double"> <column name="CPU_PERCENT" precision="18" scale="5" /> </property> <property name="memoryPercent" type="java.math.BigDecimal"> <column name="MEMORY_PERCENT" precision="22" scale="0" /> </property> <property name="trafficThruputMb" type="java.math.BigDecimal"> <column name="TRAFFIC_THRUPUT_MB" precision="22" scale="0" /> </property> <property name="inPercentUtil" type="java.math.BigDecimal"> <column name="IN_PERCENT_UTIL" precision="22" scale="0" /> </property> <property name="outPercentUtil" type="java.math.BigDecimal"> <column name="OUT_PERCENT_UTIL" precision="22" scale="0" /> </property> <property name="inErrors" type="java.lang.Double"> <column name="IN_ERRORS" precision="18" scale="5" /> </property> <property name="outErrors" type="java.lang.Double"> <column name="OUT_ERRORS" precision="18" scale="5" /> </property> <property name="inDiscards" type="java.lang.Double"> <column name="IN_DISCARDS" precision="18" scale="5" /> </property> <property name="outDiscards" type="java.lang.Double"> <column name="OUT_DISCARDS" precision="18" scale="5" /> </property> <property name="cpuEnabled" type="java.lang.Integer"> <column name="CPU_ENABLED" length="1" /> </property> <property name="memoryEnabled" type="java.lang.Integer"> <column name="MEMORY_ENABLED" length="1" /> </property> <property name="trafficEnabled" type="java.lang.Integer"> <column name="TRAFFIC_ENABLED" length="1" /> </property> <property name="ioUtilEnabled" type="java.lang.Integer"> <column name="IO_UTIL_ENABLED" length="1" /> </property> <property name="ioErrorsEnabled" type="java.lang.Integer"> <column name="IO_ERRORS_ENABLED" length="1" /> </property> <property name="trkCrtDate" type="java.sql.Date"> <column name="TRK_CRT_DATE" length="7" /> </property> <property name="trkModDate" type="java.sql.Date"> <column name="TRK_MOD_DATE" length="7" /> </property> <property name="trkModBy" type="java.lang.String"> <column name="TRK_MOD_BY" length="50" /> </property>
</class> </hibernate-mapping>
WatchList.java package com.cox.tsd.gen2.model.iad;
import java.math.BigDecimal; import java.sql.Date;
/** * WatchList entity. @author MyEclipse Persistence Tools */
public class WatchList implements java.io.Serializable {
// Fields
private BigDecimal watchId; private User user; private DeviceInterface deviceInterface; private Device device; private String deviceName; private String interfaceName; private Double cpuPercent; private BigDecimal memoryPercent; private BigDecimal trafficThruputMb; private BigDecimal inPercentUtil; private BigDecimal outPercentUtil; private Double inErrors; private Double outErrors; private Double inDiscards; private Double outDiscards; private Integer cpuEnabled; private Integer memoryEnabled; private Integer trafficEnabled; private Integer ioUtilEnabled; private Integer ioErrorsEnabled; private Date trkCrtDate; private Date trkModDate; private String trkModBy;
// Constructors
/** default constructor */ public WatchList() { }
/** minimal constructor */ public WatchList(DeviceInterface deviceInterface, Device device) { this.deviceInterface = deviceInterface; this.device = device; }
/** full constructor */ public WatchList(User user, DeviceInterface deviceInterface, Device device, String deviceName, String interfaceName, Double cpuPercent, BigDecimal memoryPercent, BigDecimal trafficThruputMb, BigDecimal inPercentUtil, BigDecimal outPercentUtil, Double inErrors, Double outErrors, Double inDiscards, Double outDiscards, Integer cpuEnabled, Integer memoryEnabled, Integer trafficEnabled, Integer ioUtilEnabled, Integer ioErrorsEnabled, Date trkCrtDate, Date trkModDate, String trkModBy) { this.user = user; this.deviceInterface = deviceInterface; this.device = device; this.deviceName = deviceName; this.interfaceName = interfaceName; this.cpuPercent = cpuPercent; this.memoryPercent = memoryPercent; this.trafficThruputMb = trafficThruputMb; this.inPercentUtil = inPercentUtil; this.outPercentUtil = outPercentUtil; this.inErrors = inErrors; this.outErrors = outErrors; this.inDiscards = inDiscards; this.outDiscards = outDiscards; this.cpuEnabled = cpuEnabled; this.memoryEnabled = memoryEnabled; this.trafficEnabled = trafficEnabled; this.ioUtilEnabled = ioUtilEnabled; this.ioErrorsEnabled = ioErrorsEnabled; this.trkCrtDate = trkCrtDate; this.trkModDate = trkModDate; this.trkModBy = trkModBy; }
// Property accessors
public BigDecimal getWatchId() { return this.watchId; }
public void setWatchId(BigDecimal watchId) { this.watchId = watchId; }
public User getUser() { return this.user; }
public void setUser(User user) { this.user = user; }
public DeviceInterface getDeviceInterface() { return this.deviceInterface; }
public void setDeviceInterface(DeviceInterface deviceInterface) { this.deviceInterface = deviceInterface; }
public Device getDevice() { return this.device; }
public void setDevice(Device device) { this.device = device; }
public String getDeviceName() { return this.deviceName; }
public void setDeviceName(String deviceName) { this.deviceName = deviceName; }
public String getInterfaceName() { return this.interfaceName; }
public void setInterfaceName(String interfaceName) { this.interfaceName = interfaceName; }
public Double getCpuPercent() { return this.cpuPercent; }
public void setCpuPercent(Double cpuPercent) { this.cpuPercent = cpuPercent; }
public BigDecimal getMemoryPercent() { return this.memoryPercent; }
public void setMemoryPercent(BigDecimal memoryPercent) { this.memoryPercent = memoryPercent; }
public BigDecimal getTrafficThruputMb() { return this.trafficThruputMb; }
public void setTrafficThruputMb(BigDecimal trafficThruputMb) { this.trafficThruputMb = trafficThruputMb; }
public BigDecimal getInPercentUtil() { return this.inPercentUtil; }
public void setInPercentUtil(BigDecimal inPercentUtil) { this.inPercentUtil = inPercentUtil; }
public BigDecimal getOutPercentUtil() { return this.outPercentUtil; }
public void setOutPercentUtil(BigDecimal outPercentUtil) { this.outPercentUtil = outPercentUtil; }
public Double getInErrors() { return this.inErrors; }
public void setInErrors(Double inErrors) { this.inErrors = inErrors; }
public Double getOutErrors() { return this.outErrors; }
public void setOutErrors(Double outErrors) { this.outErrors = outErrors; }
public Double getInDiscards() { return this.inDiscards; }
public void setInDiscards(Double inDiscards) { this.inDiscards = inDiscards; }
public Double getOutDiscards() { return this.outDiscards; }
public void setOutDiscards(Double outDiscards) { this.outDiscards = outDiscards; }
public Integer getCpuEnabled() { return this.cpuEnabled; }
public void setCpuEnabled(Integer cpuEnabled) { this.cpuEnabled = cpuEnabled; }
public Integer getMemoryEnabled() { return this.memoryEnabled; }
public void setMemoryEnabled(Integer memoryEnabled) { this.memoryEnabled = memoryEnabled; }
public Integer getTrafficEnabled() { return this.trafficEnabled; }
public void setTrafficEnabled(Integer trafficEnabled) { this.trafficEnabled = trafficEnabled; }
public Integer getIoUtilEnabled() { return this.ioUtilEnabled; }
public void setIoUtilEnabled(Integer ioUtilEnabled) { this.ioUtilEnabled = ioUtilEnabled; }
public Integer getIoErrorsEnabled() { return this.ioErrorsEnabled; }
public void setIoErrorsEnabled(Integer ioErrorsEnabled) { this.ioErrorsEnabled = ioErrorsEnabled; } public Date getTrkCrtDate() { return this.trkCrtDate; } public void setTrkCrtDate(Date trkCrtDate) { this.trkCrtDate = trkCrtDate; } public Date getTrkModDate() { return this.trkModDate; } public void setTrkModDate(Date trkModDate) { this.trkModDate = trkModDate; } public String getTrkModBy() { return this.trkModBy; } public void setTrkModBy(String trkModBy) { this.trkModBy = trkModBy; }
}
|