读书人

hibernate annoation (10 映射查询)

发布时间: 2012-11-09 10:18:48 作者: rapoo

hibernate annoation (十 映射查询)

在类级别上配置:

cacheable是否可以与二级缓存交互(默认false)cacheRegion设置缓存名称(默认othewise)timeout查询超时设定fetchSice所获取的结果集大小flushMode本次查询所用的刷新模式cacheMode本次查询所用的缓存模式readOnly是否将本次查询所加载的实体设为只读(默认false)comment将查询注释下如所生成的sql

?

?映射本地化查询(普通sql查询):

使用:@NamedNativeQueries和@SqlResultSetMappings

例如:

Query q = session.getNamedQuery("nativesql1");List<B> list = q.list();for (Iterator iterator = list.iterator(); iterator.hasNext();) {B a2 = (B) iterator.next();System.out.println(a2.getBname());}

?此时如果要显示:System.out.println(a2.getId());则会报: could not execute query ---Column 'id1_0_' not found.异常

?

读书人网 >软件架构设计

热点推荐