【发布时间】:2013-02-16 21:15:24
【问题描述】:
当我尝试在表上选择其中一列是外键时出现此错误:
select count(*) from cards where username = 'name';
我是通过 java jdbc 做的,所以我认为我的映射有问题,因为通过 MySql 命令行的相同查询工作正常:
<many-to-one name="users" class="table" update="false" insert="false" fetch="select">
<column name="username" length="45" not-null="true" />
</many-to-one>
2013-03-02 12:19:03,660 INFO [http-bio-8080-exec-5] (NullableType.java:203) - could not read column value from result set: username; Column 'username' not found.
2013-03-02 12:19:03,663 WARN [http-bio-8080-exec-5] (JDBCExceptionReporter.java:100) - SQL Error: 0, SQLState: S0022
2013-03-02 12:19:03,664 ERROR [http-bio-8080-exec-5] (JDBCExceptionReporter.java:101) - Column 'username' not found.
我发现了这个:
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/querysql.html#d0e13696
第 16.1.2 和 16.1.3 节可能是我问题的答案,但我想不通...
【问题讨论】:
-
(1) 检查您是否从正确的表格中选择。 (2) 检查您是否连接到正确的数据库。
-
是的,我支持 1 和 2
标签: java sql hibernate jdbc hibernate-mapping