SQL Error: 17006, SQLState: 99999 invalid column name
reported an error when using hibernate for query today. This is simply recorded here.
problem description:
USES hibernate to query an entity for an error.
reason analysis:
String sql = "select emplId,name from employee";
try {
Session session = sessionFactory.getCurrentSession();
SQLQuery query = session.createSQLQuery(sql.toString());
query.addScalar("emplId", StringType.INSTANCE);
query.addScalar("emplName", StringType.INSTANCE);
query.setResultTransformer(Transformers.aliasToBean(Employee.class));
employeeList = query.list();
}
......
The field for the
SQL query is name, and the field for the entity is emplName. Name inconsistency results.
solution:
String sql = "select emplId, name as emplName from employee";
try {
Session session = sessionFactory.getCurrentSession();
SQLQuery query = session.createSQLQuery(sql.toString());
query.addScalar("emplId", StringType.INSTANCE);
query.addScalar("emplName", StringType.INSTANCE);
query.setResultTransformer(Transformers.aliasToBean(Employee.class));
employeeList = query.list();
}
......
div>
Read More:
- How to Fix SQL Error: 1054, SQLState: 42S22 Unknown column ‘markcardex0_.art_service_time’ in ‘field list’
- Cause: java.sql.SQLException: invalid column type: 1111 Error [How to Fix]
- DB2 SQL ERROR: SQLCODE=-803, SQLSTATE=23505, SQL
- SQL Error: 904, SQLState: 42000
- SQL Error: 17059, SQLState: 99999
- In the SQL query statement, add the column that does not exist in the table and set the fixed value of the column
- SQL Error: 1452, SQLState: 23000
- DB2 SQL Error: SQLCODE=-206, SQLSTATE=42703
- DB2 SQL error: SQLCODE: -433, SQLSTATE: 22001, SQLERRMC
- Solve a bug harvest of DB2 (sqlcode = – 805, sqlstate = 51002, error message = DB2 SQL error: sqlcode = – 805, sqlstate = 5100
- SQL Error: 0, SQLState: 08S01 & Communications link failure
- DB2 SQL error: sqlcode = – 433, sqlstate = 22001 solved
- DB2 SQL error: sqlcode = – 803, sqlstate = 23505, sqlerrmc = 2 [solution]
- Cause: java.sql.BatchUpdateException: Unknown column ‘xxx‘ in ‘field list‘
- DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=;;,?,?,?,?,?,?,?,?);END-OF-STATEMENT
- Invalid column reference when using round in hive
- SQL error: 156, sqlstate: S1000 error encountered in Hibernate
- Error attempting to get column time from result set. Cause: java.sql.SQLFe
- Error when connecting to database: DB2 SQL error: sqlcode = – 204, sqlstate = 42704, sqlerrmc= YXUAT.CUST_ BLK_ REL, DRIVER=4.25.13
- ERROR processing query/statement. Error Code: 0, SQL state: TStatus(statusCode:ERROR_STATUS sqlState