[英]In a JPA sql query, HIbernate can't resolve the foreignKey column
[英]Hibernate can't resolve column
我在解析列“名称”时遇到问题。 因此,我将数据源和另一个类解析为列。 我也试图刷新数据。 而且我不明白怎么了。
MeteoStation实体
@Table(appliesTo = "meteo_station")
public class MeteoStation {
@Id
@GeneratedValue
private int id;
@Column(name = "name")
private String name;
public MeteoStation() {
}
//getters,setter, hashcode and equals.
}
休眠配置文件:
<?xml version="1.0" encoding="UTF-8" ?>
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:postgresql://localhost:5432/meteoreports</property>
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.username">postgres</property>
<property name="connection.password">root</property>
<property name="dialect">org.hibernate.dialect.PostgreSQL94Dialect</property>
<property name="show_sql">true</property>
<property name="hibernate.enable_lazy_load_no_trans">true</property>
<mapping class="ru.skilanov.model.Users"/>
<mapping class="ru.skilanov.model.Role"/>
<mapping class="ru.skilanov.model.MeteoStation"/>
<mapping class="ru.skilanov.model.MeteoStationData"/>
<mapping class="ru.skilanov.model.Reports"/>
<mapping class="ru.skilanov.model.ReportColumns"/>
<mapping class="ru.skilanov.model.ReportRows"/>
<mapping class="ru.skilanov.model.MeteoStationDataPk"/>
</session-factory>
</hibernate-configuration>
meteo_station
表的DDL脚本:
CREATE TABLE meteo_station (
id SERIAL PRIMARY KEY NOT NULL,
name TEXT
);
似乎您正在使用的@Table
注释来自Hibenate。 尝试更改导入以使用javax.persistence.Table
,然后使用@Table(name="meteo_station")
。 在这种情况下,实体也应来自javax.persistance
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.