benaich
benaich

Reputation: 922

Spring batch - hibernate integration

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.

Upvotes: 0

Views: 303

Answers (3)

smaiakov
smaiakov

Reputation: 480

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.

Upvotes: 1

Dean Clark
Dean Clark

Reputation: 3868

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.

Upvotes: 0

Michael Pralow
Michael Pralow

Reputation: 6630

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

Upvotes: 0

Related Questions