hibernate 出现Caused by: java.sql.SQLException: Column 'id' not found.异常

用hibernate进行映射查询时,出现Caused by: java.sql.SQLException: Column ‘id’ not found 异常,检查数据库表及映射都有id且已经正确映射,google后发现原因为:

Your query doesn’t return a field named id即查询sql中没有查询出主键id列,但返回结果集中用到,故出现异常特此记录。

详细解答见下:

http://stackoverflow.com/questions/34164411/caused-by-java-sql-sqlexception-column-id-not-found

原文地址:https://blog.csdn.net/motrsky/article/details/52369614

hibernate 出现Caused by: java.sql.SQLException: Column 'id' not found.异常

原文地址:https://www.cnblogs.com/jpfss/p/11165527.html

时间: 2024-10-29 19:12:30

hibernate 出现Caused by: java.sql.SQLException: Column 'id' not found.异常的相关文章

Hibernate中Caused by: java.sql.SQLException: Field 'address_id'doesn't have a default value

在学习Hibernate中,相信很多人都遇到过: Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not execute statement Caused by: java.sql.SQLException: Field 'address_id' doesn't have a default value 很是纳闷,明明我的address_id是主键,为毛还提示我不存在默认值?主

Caused by: java.sql.SQLException: Column 'show_type' not found

今天在处理个问题的时候遇到了这么个bug,难住了老半天.网上找了挺多资料.这是因为hibernate在别名上的不支持.处理方案是在jdbc数据库连接上计入了这么个配置. 绿色的相当于是个连接符. url="jdbc:mysql://localhost:3306/game_center?useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true" 参考的博文是:http://blog.c

Caused by: java.sql.SQLException: Field 'id' doesn't have a default value

1.错误描述 org.hibernate.exception.GenericJDBCException: error executing work at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(Sql

resultset 对象获取行字段数据时报:java.sql.SQLException: Column 'id' not found.

resultset 对象获取行字段数据时报:java.sql.SQLException: Column 'id' not found. 代码: String sql="SELECT d.content,c.name AS categoryName FROM news_detail d,news_category c WHERE d.categoryId=c.id"; Object[] params ={}; System.out.println(this.executeQuery(sq

java.sql.SQLException: Column 'class' not found.异常没有找到列

1 /**处理当个对象的 ,rs中要么有一条,要么一条没有. 2 * @param <T> 3 */ 4 public class BeanHandler<T> implements ResultSetHandler<T> { 5 private Class<T> type; 6 public BeanHandler(Class<T> type){ 7 this.type = type; 8 } 9 /**将rs->T t 10 */ 11

Caused by: java.sql.SQLException: Operand should contain 1 column(s)

1.错误描述 [ERROR:]2015-05-05 15:48:55,847 [异常拦截] org.hibernate.exception.DataException: error executing work at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:135) at org.hibernate.exception.internal.

Caused by: java.sql.SQLException: Incorrect integer value: &#39;&#39; for column &#39;clientId&#39; at row 41

1.错误描述 [ERROR:]2015-06-10 13:48:26,253 [异常拦截] oa.exception.ExceptionHandler org.hibernate.exception.GenericJDBCException: error executing work at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.jav

mysql 保存emoji时报,数据库报错:Caused by: java.sql.SQLException: Incorrect string value: &#39;\xF0\x9F\x98\x82\xF0\x9F...&#39; for column &#39;review&#39; at row 1

错误原因:我们可以看到错误提示中的字符0xF0 0x9F 0x98 0x84 ,这对应UTF-8编码格式中的4字节编码(UTF-8编码规范).正常的汉字一般不会超过3个字节,为什么为出现4个字节呢?实际上是它对应的是智能手机输入法中的表情.那为什么会报错呢?因为mysql中的utf-8并不是真正意义上的utf-8,它只能存储1~3个字节长度的utf-8编码,如果想存储4个字节的必须用utf8mb4类型.不而要使用utf8mb4类型,首先要保证Mysql版本要不低于 MySQL 5.5.3. 常用

Caused by: java.sql.SQLException: Parameter index out of range (1 &gt; number of parameters, which is 0

1.错误描述 org.hibernate.exception.GenericJDBCException: error executing work at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(Sql