0

I am creating javafx desktop application and javaee application. They will be almost same in functionality. Both applications needs to have its own sql database, but the databases will have same structure (same tables).

I am using Eclipse IDE and what i have done so far is this:

  • One project for javafx application
  • One project for javaee application
  • One project for data layer (jpa)

I am also using module-info.java. For javafx and javaee project i have defined required package to be my data layer project.

I have found here: JPA and EJB - When do I need to use transaction?, that i should use transactions when working with Java SE, which my javafx app actually is, but not when my application is javaee. I do not want to write jpa project for each application. How to create/set up projects properly, so that each of my applications will have separate, but same database?

Wortig
  • 963
  • 2
  • 11
  • 37

1 Answers1

1

Have the common code in a separate code repository, release it and add a dependency to this module in both applications. Use Flyway or Liquibase in the common code to manage the database schema.

Consider to use Spring Boot instead of Java EE. Spring, as Java EE, supports declarative transactions (see Spring Data), but Spring is more easy to use with Java SE. AFAIK it's possible to combine JavaFX applications with Spring. This would allow you to use declarative transactions in your JavaFX application as well. This would make it easier to share code between backend and frontend.

Puce
  • 37,247
  • 13
  • 80
  • 152