1, 当reverse(映射)一个没有primary key的table时候,List l =dao.getAll(); 打印l.size()是正确的,但是打印出来的l为:[null],[null],[null],[null]...答应l里面的object的时候说nullpointer1, 当reverse(映射)一个有primary key的table时候,List l =dao.getAll(); 结果完全正确.可以打印每一个object了数据.急求兄弟们解决.能够让没有primary key的table也能够得到正确的结果.没有primary key的table的SrResource.hbm.xml
<hibernate-mapping>
<class name="com.seagate.calib.bean.SrResource" table="SR_RESOURCE" schema="PARIS">
<composite-id name="id" class="com.seagate.calib.bean.SrResourceId">
<key-property name="site" type="java.lang.String">
<column name="SITE" length="2" />
</key-property>
<key-property name="facility" type="java.lang.String">
<column name="FACILITY" length="2" />
</key-property>
<key-property name="resourceId" type="java.lang.String">
<column name="RESOURCE_ID" length="8" />
</key-property>
<key-property name="modelResource" type="java.lang.String">
<column name="MODEL_RESOURCE" length="8" />
</key-property>
<key-property name="rftResourceId" type="java.lang.Long">
<column name="RFT_RESOURCE_ID" precision="5" scale="0" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>有primary key的table的SUserPref.hbm.xml配置如下:
<hibernate-mapping>
<class name="com.seagate.calib.bean.SUserPref" table="S_USER_PREF" schema="PARIS">
<composite-id name="id" class="com.seagate.calib.bean.SUserPrefId">
<key-property name="site" type="java.lang.String">
<column name="SITE" length="2" />
</key-property>
<key-property name="facility" type="java.lang.String">
<column name="FACILITY" length="2" />
</key-property>
<key-property name="userId" type="java.lang.String">
<column name="USER_ID" length="8" />
</key-property>
</composite-id>
<property name="pcHomePage" type="java.lang.String">
<column name="PC_HOME_PAGE" length="40" not-null="true" />
</property>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="com.seagate.calib.bean.SrResource" table="SR_RESOURCE" schema="PARIS">
<composite-id name="id" class="com.seagate.calib.bean.SrResourceId">
<key-property name="site" type="java.lang.String">
<column name="SITE" length="2" />
</key-property>
<key-property name="facility" type="java.lang.String">
<column name="FACILITY" length="2" />
</key-property>
<key-property name="resourceId" type="java.lang.String">
<column name="RESOURCE_ID" length="8" />
</key-property>
<key-property name="modelResource" type="java.lang.String">
<column name="MODEL_RESOURCE" length="8" />
</key-property>
<key-property name="rftResourceId" type="java.lang.Long">
<column name="RFT_RESOURCE_ID" precision="5" scale="0" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>有primary key的table的SUserPref.hbm.xml配置如下:
<hibernate-mapping>
<class name="com.seagate.calib.bean.SUserPref" table="S_USER_PREF" schema="PARIS">
<composite-id name="id" class="com.seagate.calib.bean.SUserPrefId">
<key-property name="site" type="java.lang.String">
<column name="SITE" length="2" />
</key-property>
<key-property name="facility" type="java.lang.String">
<column name="FACILITY" length="2" />
</key-property>
<key-property name="userId" type="java.lang.String">
<column name="USER_ID" length="8" />
</key-property>
</composite-id>
<property name="pcHomePage" type="java.lang.String">
<column name="PC_HOME_PAGE" length="40" not-null="true" />
</property>
</class>
</hibernate-mapping>
解决方案 »
- struts2上传时报错
- 新手請教大哥!開網站降低FLASH品質,較少CPU佔用,
- hibernate查询
- 请各位前辈进来看一下!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 请问大家现在开发BS系统的主流技术是什么啊?谢谢!
- 一个简单的问题
- 求助..........在线等
- ServletRequest.getRequestDispatcher()方法与ServletContextgetRequestDispatcher究竟有什么区别呢?
- 关于javaBean的调用问题
- 为什么修改功能成了添加?
- 关于HttpSession的一些问题啊
- request.getRequestDispatcher 问题 online wait................
没有pk你以什么去确定序列华?
有确定的,那不就是pk么