Migrate from Ontimize 1.x.x to 3.x.x
Introduction
In this tutorial we are going to explain how to migrate a project from Ontimize version 1.x.x that works with JDK 8 to Ontimize version 3.x.x that works with JDK 11. For this example we will download a project like the explained in this training course.
Prerequisites
You can follow this tutorial using your own application, although for this example we will use an application created using the archetype that can be found on this page and with a REST service.
There are 2 options to follow this tutorial, clone the repository with the initial state and follow the tutorial step by step, or download the final example and see which files are new and which have been updated.
Initial project
/$ git clone https://github.com/ontimize/ontimize-examples
/ontimize-examples$ cd ontimize-examples
/ontimize-examples$ git checkout boot-migration-3.x.x-initial
Final example
/$ git clone https://github.com/ontimize/ontimize-examples
/ontimize-examples$ cd ontimize-examples
/ontimize-examples$ git checkout boot-migration-3.x.x
To simplify the code being written, three dots (…) may appear in some parts of the code. This indicates that there may be previous code before and after those dots.
Steps
Ontimize version
First of all we need to update the version of Ontimize (ontimize-boot-parent) located in the parent of the project. Use always the latest version:
pom.xml
- ontimize-examples
- hr-api
- src
- main
- java
- com
- ontimize
- hr
- api
- core
- service
- ICandidateService.java
- IMasterService.java
- IOfferService.java
- IUserService.java
- service
- core
- api
- hr
- ontimize
- com
- java
- main
- pom.xml
- src
- hr-boot
- src
- main
- java
- com
- ontimize
- hr
- ServerApplication.java
- hr
- ontimize
- com
- resources
- application.yml
- java
- main
- pom.xml
- src
- hr-model
- src
- main
- db
- templateDB.properties
- templateDB.txt
- java
- com
- ontimize
- hr
- model
- core
- dao
- CandidateDao.java
- EducationDao.java
- ExperienceLevelDao.java
- OfferCandidatesDao.java
- OfferCandidateStatusDao.java
- OfferDao.java
- OfferStatusDao.java
- OriginDao.java
- ProfileDao.java
- StatusDao.java
- UserDao.java
- UserRoleDao.java
- service
- CandidateService.java
- MasterService.java
- OfferService.java
- UserService.java
- dao
- core
- model
- hr
- ontimize
- com
- resources
- dao
- CandidateDao.xml
- EducationDao.xml
- ExperienceLevelDao.xml
- OfferCandidatesDao.xml
- OfferCandidateStatusDao.xml
- OfferDao.xml
- OfferStatusDao.xml
- OriginDao.xml
- placeholders.properties
- ProfileDao.xml
- RoleDao.xml
- RoleServerPermissionDao.xml
- ServerPermissionDao.xml
- StatusDao.xml
- UserDao.xml
- UserRoleDao.xml
- dao
- db
- main
- pom.xml
- src
- hr-ws
- src
- main
- java
- com
- ontimize
- hr
- ws
- core
- rest
- CandidateRestController.java
- MainRestController.java
- MasterRestController.java
- OfferRestController.java
- TestRestController.java
- UserRestController.java
- rest
- core
- ws
- hr
- ontimize
- com
- java
- main
- pom.xml
- src
- .gitignore
- pom.xml
- README.md
- hr-api
Java version
In the project properties we will change the java version from 1.8 to 11, both for the main pom.xml and for the hr-model
module pom.xml.
pom.xml
- ontimize-examples
- hr-api
- src
- main
- java
- com
- ontimize
- hr
- api
- core
- service
- ICandidateService.java
- IMasterService.java
- IOfferService.java
- IUserService.java
- service
- core
- api
- hr
- ontimize
- com
- java
- main
- pom.xml
- src
- hr-boot
- src
- main
- java
- com
- ontimize
- hr
- ServerApplication.java
- hr
- ontimize
- com
- resources
- application.yml
- java
- main
- pom.xml
- src
- hr-model
- src
- main
- db
- templateDB.properties
- templateDB.txt
- java
- com
- ontimize
- hr
- model
- core
- dao
- CandidateDao.java
- EducationDao.java
- ExperienceLevelDao.java
- OfferCandidatesDao.java
- OfferCandidateStatusDao.java
- OfferDao.java
- OfferStatusDao.java
- OriginDao.java
- ProfileDao.java
- StatusDao.java
- UserDao.java
- UserRoleDao.java
- service
- CandidateService.java
- MasterService.java
- OfferService.java
- UserService.java
- dao
- core
- model
- hr
- ontimize
- com
- resources
- dao
- CandidateDao.xml
- EducationDao.xml
- ExperienceLevelDao.xml
- OfferCandidatesDao.xml
- OfferCandidateStatusDao.xml
- OfferDao.xml
- OfferStatusDao.xml
- OriginDao.xml
- placeholders.properties
- ProfileDao.xml
- RoleDao.xml
- RoleServerPermissionDao.xml
- ServerPermissionDao.xml
- StatusDao.xml
- UserDao.xml
- UserRoleDao.xml
- dao
- db
- main
- pom.xml
- src
- hr-ws
- src
- main
- java
- com
- ontimize
- hr
- ws
- core
- rest
- CandidateRestController.java
- MainRestController.java
- MasterRestController.java
- OfferRestController.java
- TestRestController.java
- UserRestController.java
- rest
- core
- ws
- hr
- ontimize
- com
- java
- main
- pom.xml
- src
- .gitignore
- pom.xml
- README.md
- hr-api
Modifying application.yml
In the new version of Ontimize Boot, it has been decided to change the properties from camelCase to kebab-case, so you have to modify the application.yml
.
endpoints:
api:
enabled: true
logging:
level:
root: info
ontimize:
corsfilter:
enabled: true
globalcors:
cors-configurations:
'[/**]':
allowed-origins: "*"
allowed-headers: "*"
exposed-headers: ["X-Auth-Token","Content-disposition","X-Requested-With"]
allowed-methods:
- GET
- POST
- PUT
- OPTIONS
- DELETE
jdbc:
name-convention: upper
sqlhandler: hsqldb
sql-condition-processor:
uppper-string: true
upper-like: true
security:
mode: default
ignore-paths: /app/**
role-information-service:
role-repository: UserRoleDao
role-name-column: ROLENAME
server-permission-query-id: serverPermissions
server-permission-name-column: PERMISSION_NAME
client-permission-query-id: clientPermissions
client-permission-column: XMLCLIENTPERMISSION
user-information-service:
user-repository: UserDao
user-login-column: USER_
user-password-column: PASSWORD
query-id: login
other-data:
- NAME
- SURNAME
- EMAIL
- NIF
- USERBLOCKED
- LASTPASSWORDUPDATE
- FIRSTLOGIN
user-role-information-service:
user-role-repository: UserRoleDao
query-id: userRole
role-login-column: USER_
role-name-column: ROLENAME
server:
port: 33333
tomcat:
uri-encoding: UTF-8
compression:
enabled: true
mime-types: application/json, application/xml
spring:
datasource:
driver-class-name: org.hsqldb.jdbcDriver
jdbc-url: jdbc:hsqldb:hsql://localhost:9013/templateDB
username: SA
password:
initial-size: 10
test-on-borrow: true
main:
banner-mode: 'off'
session:
store-type: none
autoconfigure:
exclude: |
org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration, org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration, org.springframework.boot.autoconfigure.security.FallbackWebSecurityAutoConfiguration
Renaming packages
With the new version, the ontimize-core library has been merged with ontimize-jee, and some classes have changed the name of their package, among them, the EntityResult Interface. To learn more about this class, check the following link.
The package name of EntityResult has been renamed from com.ontimize.db.EntityResult
to com.ontimize.jee.common.dto.EntityResult
.
Api module
In the hr-api
module we need to change the name of the package of this class in all the interfaces that are using it.
ICandidateService.java
IMasterService.java
IOfferService.java
IUserService.java
- ontimize-examples
- hr-api
- src
- main
- java
- com
- ontimize
- hr
- api
- core
- service
- ICandidateService.java
- IMasterService.java
- IOfferService.java
- IUserService.java
- service
- core
- api
- hr
- ontimize
- com
- java
- main
- pom.xml
- src
- hr-boot
- src
- main
- java
- com
- ontimize
- hr
- ServerApplication.java
- hr
- ontimize
- com
- resources
- application.yml
- java
- main
- pom.xml
- src
- hr-model
- src
- main
- db
- templateDB.properties
- templateDB.txt
- java
- com
- ontimize
- hr
- model
- core
- dao
- CandidateDao.java
- EducationDao.java
- ExperienceLevelDao.java
- OfferCandidatesDao.java
- OfferCandidateStatusDao.java
- OfferDao.java
- OfferStatusDao.java
- OriginDao.java
- ProfileDao.java
- StatusDao.java
- UserDao.java
- UserRoleDao.java
- service
- CandidateService.java
- MasterService.java
- OfferService.java
- UserService.java
- dao
- core
- model
- hr
- ontimize
- com
- resources
- dao
- CandidateDao.xml
- EducationDao.xml
- ExperienceLevelDao.xml
- OfferCandidatesDao.xml
- OfferCandidateStatusDao.xml
- OfferDao.xml
- OfferStatusDao.xml
- OriginDao.xml
- placeholders.properties
- ProfileDao.xml
- RoleDao.xml
- RoleServerPermissionDao.xml
- ServerPermissionDao.xml
- StatusDao.xml
- UserDao.xml
- UserRoleDao.xml
- dao
- db
- main
- pom.xml
- src
- hr-ws
- src
- main
- java
- com
- ontimize
- hr
- ws
- core
- rest
- CandidateRestController.java
- MainRestController.java
- MasterRestController.java
- OfferRestController.java
- TestRestController.java
- UserRestController.java
- rest
- core
- ws
- hr
- ontimize
- com
- java
- main
- pom.xml
- src
- .gitignore
- pom.xml
- README.md
- hr-api
Model module
Having changed the class in the interface, we also have to change it in the service. For this we go to the hr-model
module and replace the import of all services.
CandidateService.java
MasterService.java
OfferService.java
UserService.java
- ontimize-examples
- hr-api
- src
- main
- java
- com
- ontimize
- hr
- api
- core
- service
- ICandidateService.java
- IMasterService.java
- IOfferService.java
- IUserService.java
- service
- core
- api
- hr
- ontimize
- com
- java
- main
- pom.xml
- src
- hr-boot
- src
- main
- java
- com
- ontimize
- hr
- ServerApplication.java
- hr
- ontimize
- com
- resources
- application.yml
- java
- main
- pom.xml
- src
- hr-model
- src
- main
- db
- templateDB.properties
- templateDB.txt
- java
- com
- ontimize
- hr
- model
- core
- dao
- CandidateDao.java
- EducationDao.java
- ExperienceLevelDao.java
- OfferCandidatesDao.java
- OfferCandidateStatusDao.java
- OfferDao.java
- OfferStatusDao.java
- OriginDao.java
- ProfileDao.java
- StatusDao.java
- UserDao.java
- UserRoleDao.java
- service
- CandidateService.java
- MasterService.java
- OfferService.java
- UserService.java
- dao
- core
- model
- hr
- ontimize
- com
- resources
- dao
- CandidateDao.xml
- EducationDao.xml
- ExperienceLevelDao.xml
- OfferCandidatesDao.xml
- OfferCandidateStatusDao.xml
- OfferDao.xml
- OfferStatusDao.xml
- OriginDao.xml
- placeholders.properties
- ProfileDao.xml
- RoleDao.xml
- RoleServerPermissionDao.xml
- ServerPermissionDao.xml
- StatusDao.xml
- UserDao.xml
- UserRoleDao.xml
- dao
- db
- main
- pom.xml
- src
- hr-ws
- src
- main
- java
- com
- ontimize
- hr
- ws
- core
- rest
- CandidateRestController.java
- MainRestController.java
- MasterRestController.java
- OfferRestController.java
- TestRestController.java
- UserRestController.java
- rest
- core
- ws
- hr
- ontimize
- com
- java
- main
- pom.xml
- src
- .gitignore
- pom.xml
- README.md
- hr-api
Ws module
In this case it is not just about changing the name of the package, it must also be taken into account that the EntityResult
class is now an Interface, so an object cannot be instantiated from it. To do this, we will use the EntityResultMapImpl
class.
Go to the hr-ws
module and replace the import of the EntityResult class in the rest controllers and make the following changes:
OfferRestController.java
UserRestController.java
- ontimize-examples
- hr-api
- src
- main
- java
- com
- ontimize
- hr
- api
- core
- service
- ICandidateService.java
- IMasterService.java
- IOfferService.java
- IUserService.java
- service
- core
- api
- hr
- ontimize
- com
- java
- main
- pom.xml
- src
- hr-boot
- src
- main
- java
- com
- ontimize
- hr
- ServerApplication.java
- hr
- ontimize
- com
- resources
- application.yml
- java
- main
- pom.xml
- src
- hr-model
- src
- main
- db
- templateDB.properties
- templateDB.txt
- java
- com
- ontimize
- hr
- model
- core
- dao
- CandidateDao.java
- EducationDao.java
- ExperienceLevelDao.java
- OfferCandidatesDao.java
- OfferCandidateStatusDao.java
- OfferDao.java
- OfferStatusDao.java
- OriginDao.java
- ProfileDao.java
- StatusDao.java
- UserDao.java
- UserRoleDao.java
- service
- CandidateService.java
- MasterService.java
- OfferService.java
- UserService.java
- dao
- core
- model
- hr
- ontimize
- com
- resources
- dao
- CandidateDao.xml
- EducationDao.xml
- ExperienceLevelDao.xml
- OfferCandidatesDao.xml
- OfferCandidateStatusDao.xml
- OfferDao.xml
- OfferStatusDao.xml
- OriginDao.xml
- placeholders.properties
- ProfileDao.xml
- RoleDao.xml
- RoleServerPermissionDao.xml
- ServerPermissionDao.xml
- StatusDao.xml
- UserDao.xml
- UserRoleDao.xml
- dao
- db
- main
- pom.xml
- src
- hr-ws
- src
- main
- java
- com
- ontimize
- hr
- ws
- core
- rest
- CandidateRestController.java
- MainRestController.java
- MasterRestController.java
- OfferRestController.java
- TestRestController.java
- UserRestController.java
- rest
- core
- ws
- hr
- ontimize
- com
- java
- main
- pom.xml
- src
- .gitignore
- pom.xml
- README.md
- hr-api