I am trying to use MySql database to persist the data. I am using Spring boot project. When I first run the application, the database is created and data is inserted fine. When the application is restarted, I get an error as the users and group already exists in the database, and I get error for duplicate insertion.
### SQL: insert into ACT_ID_GROUP (ID_, REV_, NAME_, TYPE_) values ( ?, 1, ?, ? )
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'whamtech' for key 'PRIMARY'
How can I configure the beans as show here,
@Bean
InitializingBean usersAndGroupsInitializer(final IdentityService identityService) {
return new InitializingBean() {
public void afterPropertiesSet() throws Exception {
Group approvers = group("groupName");
User u1 = user("user1", "FirstName1", "LastName1");
User u2 = user("user2", "FirstName2", "LastName2");
identityService.createMembership(u1.getId(), approvers.getId());
identityService.createMembership(u2.getId(), approvers.getId());
}
private User user(String userName, String f, String l) {
User u = identityService.newUser(userName);
u.setFirstName(f);
u.setLastName(l);
u.setPassword("password");
identityService.saveUser(u);
return u;
}
private Group group(String groupName) {
Group group = identityService.newGroup(groupName);
group.setName(groupName);
group.setType("security-role");
identityService.saveGroup(group);
return group;
}
};
}
Can anyone point me to an example code, that uses persistent database to configure an Activiti process.
There is this example which talks about persistent databases (inc mysql) and uses what appears to be the same approach as you are using - GitHub - canchito-dev/integrate-activiti-with-spring: In this post, you will learn how to integrate ... But perhaps it is just not getting into the detail you're encountering. You could try wrapping your code in an if condition that checks whether the data is already present with a call to identityService.findUser. I did find an example of somebody doing a similar existence-check for Activiti users and groups in an InitializingBean (ctsms/SystemService.java at master · liuqingyu/ctsms · GitHub ).
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.