简体   繁体   中英

Hibernate: column does not exist

When I try to load an Entity with Hibernate I get the following error in postgres-log:

ERROR: column appuser0_.device_token does not exist at character 35
STATEMENT:  select appuser0_.id as id1_27_0_, appuser0_.device_token as device_t2_27_0_,....

The column device_token definitely exists - and if I copy-paste the whole logged statement and execute it in PGAdmin, I get the expected result.

So what do I forget? What is the difference between the Hibernate statement and the manually executed one?

此问题是由多租户配置引起的,因此选择了错误的数据源。

Depending on how you defined the query, the problem might be located somewhere else: For example, HQL Queries are using the "property-names" of the class, not the column names.

And if you have something like:

@Column("device_token")
private String deviceToken;

Then your HQL-Query should target "deviceToken" and not "device_token". We also encountered a similar error once: Hibernate was reporting "user_id" is missing, because we named the property "userId" with the underscored version for the column name only.

This might be not the problem for you but worth double checking it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM