santiageitorx
santiageitorx

Reputation: 103

Spring-Data projections. The correct way?

In my attempt of using JPA with a legacy database, I've came to the conclusion I need to obtain a subset of my huge 50-60 column tables columns, since the queries generated by one single select sentence can be around 4 or 5 sheets of paper long with a endless number of joins.

I am wondering, how you experts, face this problem related mainly to performance and efficency, but also with the application's design and how you do structure your project, entities, pojos etc in a reasonable way.

Upvotes: 0

Views: 1379

Answers (2)

Sankar
Sankar

Reputation: 101

I would use @Query and custom code the query with a DTO representing the model needed, saves memory, also prefer Spring-Data-JDBC over JPA

Upvotes: 1

Griff
Griff

Reputation: 1816

I'd use Spring's JDBC template: https://spring.io/guides/gs/relational-data-access/

Upvotes: 0

Related Questions