存儲庫模板

2018-04-22 13:11 更新

框架提供了一個基本的存儲庫操作模板BeanRepository<T>,使用示例如下

定義接口

import test.entity.User;

public interface UserService 
{
	public void save(User user) throws Exception;
}


編寫實現(xiàn)類


import org.jfaster.domain.BeanRepository;
import org.jfaster.mvc.annotation.Implement;

import test.entity.User;
import test.service.UserService;

@Implement
public class UserServiceImpl extends BeanRepository<User> implements UserService
{
	public void save(User user) throws Exception 
	{
		try
		{
			supper.save(User.class, user);
		} catch (Exception e) 
		{
			e.printStackTrace();
			throw e;
		}
		
	}
}

這里是放在了服務(wù)接口實現(xiàn)類里面,當(dāng)然也可以是在放在dao層里面



以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號