Authored by liangyi.chen@yoho.cn

Fix

... ... @@ -3,12 +3,10 @@ package com.yoho.datasync.consumer.dal.repository.grass;
import com.yoho.datasync.core.base.model.yh_grass.GrassArticle;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Optional;
public interface GrassArticleRepository extends JpaRepository<GrassArticle, Integer> {
Optional<GrassArticle> findById(Integer id);
GrassArticle findGrassArticleById(Integer id);
}
... ...
... ... @@ -5,7 +5,6 @@ import com.yoho.datasync.core.base.model.yh_grass.GrassArticle;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Optional;
@Service
public class GrassArticleService {
... ... @@ -14,7 +13,6 @@ public class GrassArticleService {
private GrassArticleRepository grassArticleRepository;
public GrassArticle getGrassArticleById(Integer id) {
Optional<GrassArticle> result = grassArticleRepository.findById(id);
return result == null ? null : result.get();
return grassArticleRepository.findGrassArticleById(id);
}
}
... ...
... ... @@ -8,7 +8,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.annotation.Resource;
import javax.persistence.EntityManager;
... ... @@ -16,7 +15,6 @@ import javax.sql.DataSource;
import java.util.Properties;
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
entityManagerFactoryRef = "entityManagerFactoryPrimary",
basePackages = {"com.yoho.datasync.consumer.dal.repository.pcms"})
... ...
... ... @@ -22,7 +22,7 @@ public class YhGrassDataSourceConfig {
@Resource
private Properties jpaProperties;
@Bean(name = "entityManagerYhCms")
@Bean(name = "entityManagerYhGrass")
public EntityManager entityManager(EntityManagerFactoryBuilder builder) throws Exception {
return entityManagerFactorySecondary(builder).getObject().createEntityManager();
}
... ...