我正在研究 Spring over Hibernate 项目,但我才刚刚开始。我正在尝试使用 SpringBootApplication 向 MsSql 写入一些 LogEntries 对象。我有一些不同的包:
这是课程:
LogEntryFacadeImpl.class :
package com.tradingSystem.dataAccess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.tradingSystem.entity.LogEntry;
@Service
public class LogEntryFacadeImpl implements LogEntryFacade{
@Autowired
private LogEntryDAO logEntryDao;
@Transactional
@Override
public Long addLogEntry(LogEntry log) {
return this.logEntryDao.save(log).getId();
}
@Override
public LogEntry getLogEntry(Long logId) {
return this.logEntryDao.findOne(logId);
}
}
Run Code Online (Sandbox Code Playgroud)
LogEntryDAO.类:
package com.tradingSystem.dataAccess;
import org.springframework.data.jpa.repository.JpaRepository;
import com.tradingSystem.entity.LogEntry;
public interface LogEntryDAO extends JpaRepository<LogEntry, Long> {
}
Run Code Online (Sandbox Code Playgroud)
我使用这个类作为测试器:
测试应用程序.类:
package com.testings;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import …Run Code Online (Sandbox Code Playgroud)