09-03-2012 04:06 AM
public class MyTaskListener extends TaskListener {
@Override
public void notify(DelegateTask delegeteTask) {
MyClass myClass = myService.findMyClassById(1L);
//throw lazy initialize exception
String myClassProperty = myClass.getMySecondClass().toString();
}
}
@Entity
public class MyClass {
@Id
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
private MySecondClass mySecondClass;
(get set etc …)
}
@Entity
public class MySecondClass {
private String name;
@Override
public String toString() {
return this.name;
}
}
//Test class in Test suit
@Transactional
@RunWith(SpringJUnit4ClassRunner.class)
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
@ContextConfiguration("classpath:applicationcontext-servicetest.xml")
public class BaseIntegration extends AbstractTransactionalJUnit4SpringContextTests {
@Test
public void test() {
ProcessService.startProcessInstanceByKey(1L, "test", null);
}
}
//Spring service in core project
@Service
public class ProcessService {
@Transactional(rollbackFor = Exception.class)
public ProcessInstance startProcessInstanceByKey(Long processDefinitionId, String businessKey, Map<String, Object> variables) {
return ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinitionId, businessKey, variables);
}
}
//Form class in ui project
public class UiFormClass {
@Transactional
public void startProcess() {
ProcessService.startProcessInstanceByKey(1L, "test", null);
}
}
09-05-2012 03:56 AM
09-05-2012 04:45 PM
09-10-2012 01:41 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.