java - spring data repository query included collection -


i'm having issue performing custom query through use of spring data jpa repository.

i have repository class implementing jparepository<>. works expected of built-in crud queries along custom queries, doing qualification among inner collections isn't working , returning full result set though qualification of collection did not exist.

for example, here query:

public interface messagerepository extends jparepository<message, integer> { @query("select message a, message_topic b a.systemnm = :thesystem , a. applicationnm = :theapplication , b.topicnm = :thetopicname , a.insertts between :thestartdate , :theenddate , 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); 

with following jpa entities:

message:

@entity public class message implements serializable { private static final long serialversionuid = 1l;  @id @column(name="message_id") private int messageid;  @column(name="application_nm") private string applicationnm;  @column(name="execution_instance_txt") private string executioninstancetxt;  @temporal(temporaltype.timestamp) @column(name="expiration_dt") private date expirationdt;  @column(name="grouping_des") private string groupingdes;  @temporal(temporaltype.timestamp) @column(name="insert_ts") private date insertts;  @column(name="message_detail_txt") private string messagedetailtxt;  @column(name="message_summary_txt") private string messagesummarytxt;  @column(name="severity_des") private string severitydes;  @column(name="system_nm") private string systemnm;  //uni-directional many-to-one association message_topic @onetomany(fetch=fetchtype.eager) @joincolumn(name="message_id", referencedcolumnname="message_id") private set<message_topic> messagetopics; 

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; 

this query:

select message a, message_topic b a.systemnm = :thesystem , a. applicationnm = :theapplication , b.topicnm = :thetopicname , a.insertts between :thestartdate , :theenddate , a.expirationdt > current_timestamp 

where message , message_topic joined?, if transform query native query, possible can detect fault.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -