Java spring数据存储库查询包含集合

Java spring数据存储库查询包含集合,java,spring,hibernate,jpa,spring-data,Java,Spring,Hibernate,Jpa,Spring Data,我在使用SpringDataJPA存储库执行自定义查询时遇到了一个问题 我有一个实现JPARepository的存储库类。对于所有内置CRUD查询以及一些自定义查询,一切都按预期工作,但是在内部集合之间进行限定不起作用,并且返回完整的结果集,就好像集合的限定不存在一样 例如,下面是一个查询: public interface MessageRepository extends JpaRepository<Message, Integer> { @Query("SELECT a FRO

我在使用SpringDataJPA存储库执行自定义查询时遇到了一个问题

我有一个实现JPARepository的存储库类。对于所有内置CRUD查询以及一些自定义查询,一切都按预期工作,但是在内部集合之间进行限定不起作用,并且返回完整的结果集,就好像集合的限定不存在一样

例如,下面是一个查询:

public interface MessageRepository extends JpaRepository<Message, Integer> {
@Query("SELECT a FROM Message a, Message_Topic b WHERE a.systemNm = :theSystem AND a. applicationNm = :theApplication AND b.topicNm = :theTopicName AND a.insertTs BETWEEN :theStartDate AND :theEndDate AND a.expirationDt > CURRENT_TIMESTAMP")
List<Message> findMessagesByTopic(@Param("theSystem") String theSystem,
        @Param("theApplication") String theApplication,
        @Param("theTopicName") String theTopicName,
        @Param("theStartDate") Date theStartDate,
        @Param("theEndDate") Date theEndDate);
这是您的查询:

SELECT a FROM Message a, Message_Topic b WHERE a.systemNm = :theSystem AND a. applicationNm = :theApplication AND b.topicNm = :theTopicName AND a.insertTs BETWEEN :theStartDate AND :theEndDate AND a.expirationDt > CURRENT_TIMESTAMP

Message和Message_Topic在哪里连接?如果您将此查询转换为本机查询,您可能会检测到故障。

感谢您修复我的问题。。。有些日子比其他日子好。
@Entity
public class Message_Topic implements Serializable {
private static final long serialVersionUID = 1L;

@Id
@Column(name="message_topic_id")
private int messageTopicId;

@Column(name="message_id", insertable=false, updatable=false)
private int messageId;

@Column(name="topic_nm")
private String topicNm;

@Column(name="topic_value_txt")
private String topicValueTxt;
SELECT a FROM Message a, Message_Topic b WHERE a.systemNm = :theSystem AND a. applicationNm = :theApplication AND b.topicNm = :theTopicName AND a.insertTs BETWEEN :theStartDate AND :theEndDate AND a.expirationDt > CURRENT_TIMESTAMP