spring和hibernate不允许写操作

时间:2017-05-13 16:03:10

标签: spring hibernate

当我尝试保存对象时,我不允许写入操作。 这是代码。 事务管理器的配置

public class Monthread1 implements Runnable {

    int[][][] permut;
    int benchmark;
    double w; 
    double y;
    Map<Object, int [][][]> Setmatrix=new HashMap<Object, int [][][]>();

    public Monthread1( Map<Object, int [][][]>Setmatrix,double w, double y, int benchmark) {
        this.permut = permut;

        this.benchmark=benchmark;
        this.w=w;
        this.y=y;
    }

    public void run() {
        for(int ii=0; ii< 1000;ii++){

            for(int i=0; i<3;i++){
                //////////////////////////////////////////////////////////
                Slavethread1 mth1 = new Slavethread1 (pemut,,w,y,benchmark);
                Slavethread2 mth2 = new Slavethread2 (permut, w,y,benchmark);
                SLSthread3 mth3 = new SLSthread3 (permut,, w,y,benchmark);
                Slavethread4 mth5 = new Slavethread4(permut,w,y,benchmark);

                Thread thead1 = new Thread(mth1);
                Thread thread2 = new Thread(mth2);
                Thread thread3 = new Thread(mth3);
                Thread thread4 = new Thread(mth4);

                thead1.start();
                thead2.start();
                thead3.start();
                thead4.start();

                try {
                    thead1.join();
                    thead2.join();
                    thead3.join();
                    thead4.join();
                } catch (InterruptedException e2) {
                    e2.printStackTrace();
                }

                //put the output of the previous slaves in the map Setmatrix
                Setmatrix.put(1, mth1.getMatrix());
                Setmatrix.put(2, mth2.getMatrix());
                Setmatrix.put(3, mth3.getMatrix());
                Setmatrix.put(4, mth4.getMatrix());

                // bestMtrixInPOPULA to shoose the best matrix from Setmatrix
                permut=MthodsNeedForThreds. bestMtrixInPOPULA(Setmatrix,benchmark);
                /////////////////////////////////////////////////////////////////////////////

            }


            System.out.println(" NOW i AM HERE ");
            // the SLaveGLL to traite the result again 

            SLaveGLL mth6 = new SLaveGLL (permut, w,y,benchmark);
            Thread thrSLAllNehg = new Thread(mth6);
            thrSLAllNehg.start();

            try {
                thrSLAllNehg.join();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            //put the results again to the map in order to treat it again
            Setmatrix.put(1, permut);
            Setmatrix.put(2, permut);
            Setmatrix.put(3, permut);
            Setmatrix.put(4, permut);
        }      

    }

    public Map<Object, int [][][]> getMatrix() {
        return this.permut;
    }
}

服务类

    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate" >
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
            <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> 
      <property name="sessionFactory" ref="sessionFactory"/>
    </bean> 

<tx:annotation-driven />

@Service
public class MemberDetailServiceImpl implements MemberDetailService {

@Autowired
private MemberDetailsDao memberDetailsDao; 

@Transactional(readOnly = false)
public String saveExtraInfoMember(MemberActivity activity){
    return memberDetailsDao.saveExtraInfoMember(activity);
        }

0 个答案:

没有答案