在重读Hibernate时,在4.2.2一节发现这么一段话:
Hibernate exposes database identity to the application in two ways(Hibernate的API提供了两种方法来获得数据库ID):
■ The value of the identifier property of a persistent instance (通过处于持久太对象的getId方法)
■ The value returned by Session.getIdentifier(Object entity) (调用Session.getIdentifier(Object entity)方法)
前面两句话理解上没有任何问题, 最后一句有些疑问:这个方法有什么实际意义?当得到一个Model类后不也就自然而然地以getId方式获得它的ID,为什么还要绕一下呢?这里面有什么玄机?
看Session实现类SessionImpl对getIdentifier方法实现的源码,也没发现什么特殊之处。
大家说说看这个方法ession.getIdentifier(Object entity)有什么特殊意义?Hibernate为什么加这么个方法呢?实际中怎么用?
分享到:
相关推荐
本文实例讲述了Android使用getIdentifier()获取资源Id的方法。分享给大家供大家参考,具体如下: int i= getResources().getIdentifier(icon, drawable, getPackageName()) ; if(i>0) {Log.i(aa,aa);} else {Log....
int id = context.getResources().getIdentifier(iconName, "string", context.getPackageName()); String str = context.getResources().getString(id); 获取Drawable资源: int id = context.getResources()....
使用getIdentifier()方法可以方便的获各应用包下的指定资源ID。 方式一 int indentify = getResources().getIdentifier(“com.test.demo:drawable/icon”,null,null); 第一个参数格式是:包名 + : +资源文件夹名 +...
接触过Android开发的同学们都知道在Android中访问程序资源基本都是通过资源ID来访问。这样开发起来很简单,并且... 通过调用Resources的getIdentifier可以很轻松地得到资源ID。 几个简单的示例: 代码如下: Resources
Android安卓-获取控件的id(标识符)-根据控件id获取对应的值或控件名字-动态获取R.string的值
int strId = getResources().getIdentifier(OK, string, getPackageName()); 1.2 color型 比如下面: <”colorPrimary”>>#3F51B5 << /color>> //color资源中 id 获取 int colorId = getRe
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { result = getResources().getDimensionPixelSize(resourceId); } return result; } 3,...
交互编程 - 实验室作业 -... getIdentifier(name, " drawable " , context . getPackageName()); } 然后在您的视图类中,您有一个要将图像传递给的组件(例如 ),然后执行以下操作: ImageView img = // You either
SqInject目录一,功能说明二,接收说明三,使用范例四,工程模块说明五,版本说明一,功能说明1,使用BindView将属性和id绑定(绑定采用的是getIdentifier的方式绑定的,非R.id) 2,BindId将id的值注入到属性中...
{ int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); try { return getResources().getDimensionPixelSize(resourceId); } catch (Resources....
使用getIdentifier()方法根据资源名来获取资源id
private static string GetIdentifier(string wmiClass, string wmiProperty, string wmiMustBeTrue) { string result = ; System.Management.ManagementClass mc = new System.Management.ManagementClass(wmi...
串行和并行执行器 ParallelAndSerialExecutor 是一个执行器,它将根据传入的任务并行或串行运行任务。要串行执行任务,请使用扩展 {@link SerialRunnable} 的... public String getIdentifier() { return identifier;