要看你具体的数据库是什么啊!比如sqlserver,hibernate提供的identity与之对应,oracle则是sequence对应,根据具体情况选择!
hibernate建议使用uuid.hex

解决方案 »

  1.   

    identity 试了一下
    还是不行,显示不能插入空值.
    用uuid.hex
    显示
    org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.et.hibernate.AbstractBill.billId
      

  2.   

    请检查你的pojo id类型,影射文件id类型 ,setId()方法参数中的id类型是否一致。
      

  3.   

    POJO中的定义 
       private java.lang.Integer billId;
        public java.lang.Integer getBillId()
        {
            return billId;
        }
        public void setBillId(java.lang.Integer billId)
        {
            this.billId = billId;
        }
    映射文件
            <id name="billId" column="bill_id" type="java.lang.Integer" >
                <generator class="native"/>
            </id>
    调用POJO        Bill bill = new Bill();
            bill.setBillName(name);
             ss.save(bill);   
    JSP页面抛出异常
    org.hibernate.exception.GenericJDBCException: could not insert: [com.et.hibernate.Bill]
    控制台抛出异常org.hibernate.exception.GenericJDBCException: could not insert: [com.et.hibernate.Bill]
      

  4.   

    留QQ号,方便讨论
    我QQ23395832