2

I'm having 3 entities- 1. deal 2. tranche 3. order deal is having one to many relationship with tranche and tranche also having one to many relationship with order. i.e. 1 deal can have many tranches and 1 tranche can have many orders.

For this I created 3 entities.

1.Deal

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "deal_id")
private List<Tranche> deals = new ArrayList<Tranche>();

2.Tranche

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "tranche_id")
private List<Order> orders = new ArrayList<Order>();

My frequent operation is insertion into database. I'm using JpaRepositories's save() method for insertion of data.

@Repository
public interface ReportRepo extends JpaRepository<Deal, Long>{

}

Haven't override the save() method, just using as it is.

I'm creating a deal object having details of tranches and orders in it, and then saving that object into database using repository.

As a result , it is creating 3 tables into database and inserting the data.

Everything is working fine, the only concern is performance issue. It's taking too much time to execute the code.

For example: I have 27 deals, 49 tranches and 4000 orders. In order to store this much of data, I'm making 27 DB save calls (each of a Deal object), but it's taking almost 15 min. to execute this code which is too much of time.

Please suggest on this. I'm pretty much open to change the database tables as well, if performance gets better significantly. In future, there might be select/update operation requirement also come. Using Oracle server at the backend.

Punit
  • 324
  • 1
  • 4
  • 17
  • you can check my answer with some options for you problem: https://stackoverflow.com/questions/42325166/jpa-entitymanager-is-taking-too-long-to-save-the-data/42325688#42325688 – Maciej Kowalski Jun 05 '18 at 13:07

0 Answers0