0
votes

i'm working on a batch project that uses the spring batch core library the library uses jdbcTemplate to persist jobs meta data

and i'm trying to use hibernate in order to read the data about a specific job

package com.ben.batch.repository;

import org.springframework.batch.core.JobInstance;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface JobInstanceRepository extends JpaRepository<JobInstance,Long> {

    @Query("select count(j) from JobInstance j where j.jobName in :jobName ") //Can't resolve symbol 'JobInstance'
    Long countBuJobName(String jobName);
}

in ordinary spring boot project this works but now it shows this error

Can't resolve symbol 'JobInstance'

tho I imported the class correctly

Any idea would be much appreciated.

3

3 Answers

1
votes

For similar purposes exists JobRepository http://docs.spring.io/spring-batch/apidocs/org/springframework/batch/core/repository/JobRepository.html It allows you to fetching any information regarding your jobs.

0
votes

the spring batch infrastructure is not yet available as spring-data repository, see this JIRA Ticket BATCH-2203

0
votes

JobInstance is not a Hibernate entity (source code for reference). You'll need to implement your own Hibernate persistence layer if you'd like to query the tables using Hibernate. The primary reason for this is that the framework allows you to define any table prefix you like so your tables would end up as BATCH_JOB_EXECUTION, NIGHTLY_JOB_EXECUTION, ABCD_JOB_EXECTION, etc. Because of that the Hibernate model wouldn't know what table names to point to.