日期:2014-05-20  浏览次数:20605 次

hibernate 视图的问题
有2个表结构一样 ALARM 和 ALARM_HIS
建立一个视图 UV_ALARM (视图单独测试没问题)
SQL code

CREATE OR REPLACE VIEW "UV_ALARM" ("ALARMID", "ALARMTIME", ...., "AS
  SELECT "ALARMID",
      "ALARMTIME",
      .....
  FROM ALARM UNION ALL
  SELECT "ALARMID",
    "ALARMTIME",
    ....
    FROM ALARM_HIS;



新建了个PO(建构与alarm一样)和 uv_alarm.hbm.xml
XML code

  <hibernate-mapping package="com.gge.ulicss.domain">
    <class name="uvalarm" table="UV_ALARM">
        <id name="alarmID" column="alarmID">    </id>
        <property name="alarmTime"></property>
        。。。。        
    </class>
</hibernate-mapping>


hql="from UV_ALARM";
调用时提示:UV_ALARM is not mapped [from UV_ALARM];用联合主键包含alarmid或全部字段也是同样报错

该如何设置?




------解决方案--------------------
给视图建立个主键,不要联合主键
------解决方案--------------------
探讨
视图没有主键吧?

------解决方案--------------------
还要注意null的问题·········