简体   繁体   中英

How can I use large a script to query data when using Spring Data Jpa?

I have in problem statemant a script, a large script with query to database Oracle.

    SELECT /*+ LEADING(T) INDEX (T IDX_MONITORING_SIGNWORK)*/
         COUNT(*) OVER(PARTITION BY t.house, t.point, t.signwork)  koltc1,
         ...
      FROM monitoring t

    ...

The code above is a single query , it is very long.

We have many similar queries.

I would not want to use that script in an annotation @Query. How can I point a path to the script. The script will be in classpath an application.

Why wouldn't you create a view (which is a stored query, within the database) and simply reference it using a simple select statement, eg

create or replace view v_monitoring as
  select /*+ leading(t) index ... */
    count(*) over (...) koltc1,
    ...
  from monitoring t
  ...;

and then

select koltc1, 
       ...
from v_monitoring
where additional_conditions_if_necessary

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM