获取错误---无法对PLSQL语句执行获取:下一步

时间:2017-03-14 06:40:05

标签: java spring hibernate

我已经编写了一个存储过程,在spring中使用hibernate在oracle中的表中插入。当我从hibernate调用该过程时插入的数据但是我得到了以下错误

Cannot perform fetch on a PLSQL statement: next

程序

create or replace PROCEDURE INSERT_ITEM_TYPE(
   ITEM_TYPE_ID IN number ,
   TYPE_NAME         IN VARCHAR2 ,
    BN_NAME      IN VARCHAR2 ,
    CREATED_BY   IN NUMBER ,
    CREATED_ON   IN DATE ,
    UPDATED_BY   IN NUMBER ,
    UPDATED_ON   IN DATE ,
    IS_DELETED   IN NUMBER  )
AS
BEGIN
  INSERT
  INTO pg_item_type 
    (
      ITEM_TYPE_ID,
      ITEM_TYPE_NAME,
      BN_ITEM_TYPE_NAME,
      CREATED_BY,
      CREATED_ON,
      UPDATED_BY,
      UPDATED_ON,
      IS_DELETED
    )
    VALUES 

    (
    ITEM_TYPE_ID,
    TYPE_NAME,
    BN_NAME,
    CREATED_BY,
    CREATED_ON,
    UPDATED_BY,
    UPDATED_ON,
    IS_DELETED
    );


    commit;
END INSERT_ITEM_TYPE;

模型类

@Entity
@Table(name = "PG_ITEM_TYPE")
@NamedNativeQueries({
    @NamedNativeQuery(
    name = "insertyItemType",
    query = "CALL     INSERT_ITEM_TYPE(:id,:name,:bnName,:cretedBy,:createdOn,:updatedBy,:updatedOn,:isDeletd)",
    resultClass = GdItemType.class
    )
})

public class GdItemType {
.....
}

** DAO **

    @Override
        public void saveGdItemType(GdItemType gdItemType) {
            Session session = this.sessionFactory.getCurrentSession();
            //session.saveOrUpdate(gdItemType);
            Query query =  session.getNamedQuery("insertyItemType")
                    .setParameter("id", gdItemType.getItemTypeId())
                    .setParameter("name", gdItemType.getItemTypeName())
                    .setParameter("bnName", gdItemType.getBnItemTypeName())
                    .setParameter("cretedBy", gdItemType.getCreatedBy())
                    .setParameter("createdOn", gdItemType.getCreatedOn())
                    .setParameter("updatedBy", gdItemType.getUpdatedBy())
                    .setParameter("updatedOn", gdItemType.getUpdatedOn() )
                    .setParameter("isDeletd", gdItemType.getIsDeleted());
                    query.list();


        }

我卡在这里。任何人都可以帮助我....

1 个答案:

答案 0 :(得分:1)

query.list() 

想要将查询结果作为List返回。您的程序没有任何" out" - 参数,因此查询不会将结果返回到列表中。因此错误。