Spring Data JPA allows to extract jpql or sql queries to orm.xml as described in Spring Data Jpa Reference.
In such scenario multiple queries would end up in single orm.xml file. In our scenario this would lead to huge orm.xml as we have couple of huge queries.
I would like to achieve that each query would be stored in separate file, e.g. query for UserRepository findByLastname would be stored in META-INF/User/findByLastname.jpql or META-INF/User/findByLastname.sql if it is native query.
Is it possible to achieve such query-per-file extraction in Spring Data JPA?
PS: I am aware that query can be stored directly in Repository using @Query annotation but our maintenance team wants to have them extracted.
Thank you :-)
I think in your case you could use multiple orm.xml files with different name/locations:
<persistence-unit name="app-unit" transaction-type="JTA">
...
<mapping-file>mapping/orm-user.xml</mapping-file>
<mapping-file>mapping/orm-settings.xml</mapping-file>
<mapping-file>mapping/orm-data.xml</mapping-file>
...
</persistence-unit>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With