直接 String hql = "from Popdem";应该可以 吧。

解决方案 »

  1.   

    不行啊,这样的话就没办法加条件了:直接"from Popdem",Popdem对旬里面只有一个属性,试了下,也不对,就算对条件也没办法加呀,总不能是"from Popdem p where p.getId().getSequence()='"+XXX+"'"吧,,这样也不对咯
    映射的几个文件内容如下:Popdem.hbm.xml:
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- 
        Mapping file autogenerated by MyEclipse - Hibernate Tools
    -->
    <hibernate-mapping>
        <class name="com.ls.ggt.model.Popdem" table="popdem" schema="dbo" catalog="GGT">
            <composite-id name="id" class="com.ls.ggt.model.PopdemId">
                <key-property name="sequence" type="java.lang.String">
                    <column name="sequence" length="10" />
                </key-property>
                <key-property name="userid" type="java.lang.String">
                    <column name="userid" length="50" />
                </key-property>
                <key-property name="powerid" type="java.lang.String">
                    <column name="powerid" length="16" />
                </key-property>
                <key-property name="display" type="java.lang.String">
                    <column name="display" length="50" />
                </key-property>
                <key-property name="isTask" type="java.lang.String">
                    <column name="isTask" length="2" />
                </key-property>
                <key-property name="url" type="java.lang.String">
                    <column name="url" length="50" />
                </key-property>
                <key-property name="isForbid" type="java.lang.String">
                    <column name="isForbid" length="2" />
                </key-property>
                <key-property name="parentId" type="java.lang.String">
                    <column name="parentID" length="15" />
                </key-property>
                <key-property name="showSequence" type="java.lang.String">
                    <column name="showSequence" length="5" />
                </key-property>
            </composite-id>
        </class>
    </hibernate-mapping>Popdem.java:
    package com.ls.ggt.model;/**
     * Popdem generated by MyEclipse - Hibernate Tools
     */public class Popdem  implements java.io.Serializable {
        // Fields         private PopdemId id;
        // Constructors    /** default constructor */
        public Popdem() {
        }    
        /** full constructor */
        public Popdem(PopdemId id) {
            this.id = id;
        }   
        // Property accessors    public PopdemId getId() {
            return this.id;
        }
        
        public void setId(PopdemId id) {
            this.id = id;
        }
    }PopdemId.java:
    package com.ls.ggt.model;
    /**
     * PopdemId generated by MyEclipse - Hibernate Tools
     */public class PopdemId  implements java.io.Serializable {
        // Fields         private String sequence;
         private String userid;
         private String powerid;
         private String display;
         private String isTask;
         private String url;
         private String isForbid;
         private String parentId;
         private String showSequence;    // Constructors    /** default constructor */
        public PopdemId() {
        } /** minimal constructor */
        public PopdemId(String sequence, String userid, String powerid) {
            this.sequence = sequence;
            this.userid = userid;
            this.powerid = powerid;
        }
        
        /** full constructor */
        public PopdemId(String sequence, String userid, String powerid, String display, String isTask, String url, String isForbid, String parentId, String showSequence) {
            this.sequence = sequence;
            this.userid = userid;
            this.powerid = powerid;
            this.display = display;
            this.isTask = isTask;
            this.url = url;
            this.isForbid = isForbid;
            this.parentId = parentId;
            this.showSequence = showSequence;
        }   
        // Property accessors    public String getSequence() {
            return this.sequence;
        }
        
        public void setSequence(String sequence) {
            this.sequence = sequence;
        }    public String getUserid() {
            return this.userid;
        }
        
        public void setUserid(String userid) {
            this.userid = userid;
        }    public String getPowerid() {
            return this.powerid;
        }
        
        public void setPowerid(String powerid) {
            this.powerid = powerid;
        }    public String getDisplay() {
            return this.display;
        }
        
        public void setDisplay(String display) {
            this.display = display;
        }    public String getIsTask() {
            return this.isTask;
        }
        
        public void setIsTask(String isTask) {
            this.isTask = isTask;
        }    public String getUrl() {
            return this.url;
        }
        
        public void setUrl(String url) {
            this.url = url;
        }    public String getIsForbid() {
            return this.isForbid;
        }
        
        public void setIsForbid(String isForbid) {
            this.isForbid = isForbid;
        }    public String getParentId() {
            return this.parentId;
        }
        
        public void setParentId(String parentId) {
            this.parentId = parentId;
        }    public String getShowSequence() {
            return this.showSequence;
        }
        
        public void setShowSequence(String showSequence) {
            this.showSequence = showSequence;
        }   public boolean equals(Object other) {
    //代码省略
                }
       
       public int hashCode() {
             int result = 17;
             result = 37 * result + ( getSequence() == null ? 0 : this.getSequence().hashCode() );
             result = 37 * result + ( getUserid() == null ? 0 : this.getUserid().hashCode() );
             result = 37 * result + ( getPowerid() == null ? 0 : this.getPowerid().hashCode() );
             result = 37 * result + ( getDisplay() == null ? 0 : this.getDisplay().hashCode() );
             result = 37 * result + ( getIsTask() == null ? 0 : this.getIsTask().hashCode() );
             result = 37 * result + ( getUrl() == null ? 0 : this.getUrl().hashCode() );
             result = 37 * result + ( getIsForbid() == null ? 0 : this.getIsForbid().hashCode() );
             result = 37 * result + ( getParentId() == null ? 0 : this.getParentId().hashCode() );
             result = 37 * result + ( getShowSequence() == null ? 0 : this.getShowSequence().hashCode() );
             return result;
       }   
    }
      

  2.   

    不要太依赖工具生成的,简单的xml配置,多看看就会了把视图直接看作一个表就行了
      

  3.   

    应该写成 from Popdem p where p.id.sequence='"+XXX+"'
      

  4.   

    因为你的视图 或 表 没有定义主键  所以才会生成 三个文件
    <composite-id></composite-id> 复合主键
      

  5.   

    oracle的数据库的视图是可以建主键的