调度数据没有保存JPA

时间:2015-12-18 09:02:42

标签: java spring hibernate spring-data-jpa

这段代码我很有趣。但是数据没有保存,但你好打印请指导我。

@Service
public class TestService {

    @Autowired
    TestRepository testRepo;

    final static Logger log = Logger.getLogger(TestService.class);

    @PostConstruct
    public void init() {
        new Thread() {
            public void run() {
                try {
                    while (true) {
                        process();
                        Thread.sleep(10000);
                    }

                } catch (Exception exception) {
                    log.info("Exception while starting schedular :" + exception);
                }

            }
        }.start();
    }

    @Transactional
    public void process() {
        Test t=new Test(); 
        t.id=null;
        t.name="Lokesh";
        testRepo.save(t);
       log.info("hello");
    }
}

问题是Lokesh没有为表测试保存....

0 个答案:

没有答案