codecamp

查询数据

获取指定id值的数据记录代码如下

String id="65d22337-102f-4f41-80e5-7981c9d578ae";
		Template<Product> template=new ProxyTemplate(Product.class).getInstance();
		try 
		{
			Product product=template.get(id);
			System.out.println("product="+product);
		} catch (Exception e) {
			e.printStackTrace();
		}finally
		{
			template.close();
		}

除了get方法外,还可以使用load方法,如

Product product=template.load(id);

get方法是先从缓存中获取,如果有就返回,如果没有再去查询数据表

load方法是从数据表中查询,然后放入缓存中并返回




修改数据
查询数据-ESQL方式
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }