使用hibernate保存大量实体

使用hibernate保存大量实体,hibernate,save,entity,Hibernate,Save,Entity,我正在使用java和hibernate,我需要一次保存几个实体,只需对它们做一点小小的更改,hibernate只保存第一个实体,deepois更新也一样。请帮帮我 这是我的存储库中的方法! 你能再具体一点吗?深水? public void Salvar(Lancamento lancamento) throws SQLException { //insert repetitions if there is any if (lanc

我正在使用java和hibernate,我需要一次保存几个实体,只需对它们做一点小小的更改,hibernate只保存第一个实体,deepois更新也一样。请帮帮我

这是我的存储库中的方法!
你能再具体一点吗?深水?
 public void Salvar(Lancamento lancamento) throws SQLException {
            //insert repetitions if there is any
                    if (lancamento.isRepetir()) {
                        for (int i = 1; i <= lancamento.getNumRepeticao(); i++) {

                            this.Inserir(lancamento);

                            Calendar data = Calendar.getInstance();
                            data.setTime(lancamento.getData());
                            if (lancamento.getPeriodicidade().getValor() == 0) {
                                data.add(Calendar.DAY_OF_MONTH, 1);
                            }
                            if (lancamento.getPeriodicidade().getValor() == 1) {
                                data.add(Calendar.WEEK_OF_MONTH, 1);
                            }
                            if (lancamento.getPeriodicidade().getValor() == 2) {
                                data.add(Calendar.MONTH, 1);
                            }
                            if (lancamento.getPeriodicidade().getValor() == 3) {
                                data.add(Calendar.YEAR, 1);
                            }

                            lancamento.setData(data.getTime());
                        }

                    }
                    //if no repetitions
                    else{
                        this.Inserir(lancamento);
                    }
        }

        @Override
        @SuppressWarnings("unchecked")
        public void Inserir(Lancamento lancamento) throws SQLException {
            this.getHibernateTemplate().persist(lancamento);
        }
 // I'm sending an entity repeat twice annually

Hibernate: 
    select
        nextval ('SEQ_LANCAMENTO')
Hibernate: 
    insert 
    into
        tb_lancamento
        (cl_lancamento, dt_lancamento, desc_lacamento, fp_lancamento, nr_lancamento, pe_lancamento, rp_lancamento, st_lancamento, vl_lancamento, cd_lancamento) 
    values
        (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: 
    update  // Here he is giving an update
        tb_lancamento 
    set
        cl_lancamento=?,
        dt_lancamento=?,
        desc_lacamento=?,
        fp_lancamento=?,
        nr_lancamento=?,
        pe_lancamento=?,
        rp_lancamento=?,
        st_lancamento=?,
        vl_lancamento=? 
    where
        cd_lancamento=?