【发布时间】:2018-05-11 10:55:49
【问题描述】:
我在解析“名称”列时遇到问题。所以我评估数据源和另一个类解析列。我也尝试刷新数据。而且我不明白出了什么问题。
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
);
【问题讨论】:
-
通常在编程中使用流行的词是不好的做法,比如'name'。也许对于 JPA 来说是可以的,但对于底层数据库来说是错误的。可能会出现很多问题
-
Jacek Cz,谢谢你的建议,我改了。
标签: java sql postgresql hibernate