下划线不正确的 JPA 列
我使用JPA进行数据库访问,并用正确的名称注释每列。现在,如果我执行查询(例如),它会返回findAll()
Unknown column 'program0_.program_id' in 'field list'
错误消息是否正确是未知的,因为真实姓名是 。program_id
programId
型号:程序
@Entity
@Table(name = "programs")
@XmlRootElement
public class Program implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "programId")
private Long programId;
@ManyToMany
@JoinTable(
name = "programlabels",
joinColumns = {
@JoinColumn(name = "program", referencedColumnName = "programId")},
inverseJoinColumns = {
@JoinColumn(name = "label", referencedColumnName = "labelId")})
private Collection<Label> labels;
}
标签
@Entity
@Table(name = "labels")
@XmlRootElement
public class Label implements Serializable {
@Id
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 100)
@Column(name = "labelId")
private String labelId;
}
查询
select program0_.program_id as program_1_5_, ...
JPA将“programId”更改为“program_id”是有原因的,还是我缺少任何配置?
谢谢
编辑:哦,对不起,忘记添加查询代码/信息。
我使用Spring Data的界面并尝试了查询。JpaRepository
findAll()
@Repository
public interface ProgramRepository extends JpaRepository<Program, Long> {}