我有两张桌子,Projects和TransitionAction。双方Projects并TransitionAction有一列request_no,其用于执行它们之间的连接。实体类如下:-
Project.java
@Entity
public class Project implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@SequenceGenerator(schema = "public", name="project_id_seq_gen",sequenceName="project_id_seq",initialValue=1,allocationSize=1)
@GeneratedValue(strategy= GenerationType.SEQUENCE,generator="project_id_seq_gen")
private Integer id;
@Column(name = "request_no")
private String request_no;
@Column(name = "title")
private String title;
@Column(name = "department")
private String department;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "requestNo")
private Set<TransitionAction> tacts;
@ManyToOne
@JoinColumn(name = "status_id")
private Status status;
@ManyToOne
@JoinColumn(name = "level_id")
private ProjectLevel level;
TransitionAction.java
@Entity
@Table(name = "transitionaction")
public class TransitionAction implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "request_no")
private String request_no;
@Column(name = "actionDate")
private Date actionDate;
用于检索项目列表的代码如下:-
public interface UserInfoRepository extends JpaRepository<UserInfo, Long> {
UserInfo findByUserName(String userName);
@Query("SELECT project FROM Project project Join project.tacts pta where project.request_no= pta.request_no and project.status.id=1")
List<Project> getAllUserProjects();
}
我得到无法提取 ResultSet 错误。当我检查控制台时,我发现正在生成以下查询:
select
distinct project0_.id as id1_1_,
project0_.department as departme2_1_,
project0_.level_id as level_id6_1_,
project0_.user_nodal_officer as user_nod3_1_,
project0_.request_no as request_4_1_,
project0_.status_id as status_i7_1_,
project0_.title as title5_1_
我不明白为什么项目。id 与 tact.request_no 结合并创建错误
运算符不存在:整数 = 字符变化
慕慕森
斯蒂芬大帝
相关分类