ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 package org.jbpm.pvm.internal.id;
 
 import org.hibernate.Query;
 import org.hibernate.Session;
 import org.jbpm.api.cmd.Command;
 import org.jbpm.api.cmd.Environment;
 
 public class AcquireDbidBlockCmd
   implements Command<Long>
 {
   private static final long serialVersionUID = 1L;
   long blocksize;
 
   public AcquireDbidBlockCmd(long blocksize)
   {
     this.blocksize = blocksize;
   }
 
   public Long execute(Environment environment) throws Exception {
     Session session = (Session)environment.get(Session.class);
      
     Session newsession = session.getSessionFactory().openSession();
     newsession.beginTransaction();
     PropertyImpl property = (PropertyImpl)newsession.createQuery("select property from " + PropertyImpl.class.getName() + " as property " + "where property.key = '" + "next.dbid" + "'").uniqueResult();
 
     String nextIdText = property.getValue();
     Long nextId = new Long(nextIdText);
 
     property.setValue(Long.toString(nextId.longValue() + this.blocksize));
 
     newsession.update(property);
     newsession.flush();
      newsession.getTransaction().commit();
     newsession.close();
     newsession = null;
     
     return nextId;
   }
 }