1

I am using Spring data and jpaRepository for interacting with DB.

    public interface TelevisionSourceRepository extends JpaRepository<MyTelevisionSource, Long> {

        @Query("select new com.tivo.extract.config.dto.SourceListDTO(s.SourceId, s.SourceName, t.TvsourceLongName) from MyTelevisionSource t join fetch RCMSource s ON s.SourceId = t.SourceId")
        List<SourceListDTO> findSourceList(Pageable pageable);
    }

I want to keep the query in properties file and want to use those query.

I tried with

    @PropertySource("classpath:/Query.properties")


    @Value("${RCM.findSourceList}")
        List<SourceListDTO> findSourceList(Pageable pageable);

but its not working, any other way is there

v.ladynev
  • 19,275
  • 8
  • 46
  • 67
mohan
  • 447
  • 4
  • 11
  • 26

1 Answers1

1

I think if you declare a string with @Value. and put the string in @Query value. in application.properties

spring.queries.status-query=SELECT * FROM mydb.project ORDER BY purchase_order ASC,customer_name ASC

and in your class

@Value("${spring.queries.status-query}")
    String status_query="0";


@Query(value = status_query,nativeQuery = true)
    List<project> findAllSorted();