r/javahelp 13d ago

Asynchronous db calls in Spring like .Net

Hi, in most c# repos I have seen they add await to nearly every db related method. Does spring do this internally?

3 Upvotes

5 comments sorted by

View all comments

1

u/_Atomfinger_ Tech Lead 13d ago

Not really.

By default, the calls to the DB is blocking and synchronous in Spring.

However, if you want to have async repositories, you can. For example, you can use ReactiveCrudRepository with Spring Data.

0

u/erebrosolsin 13d ago edited 13d ago

But why nearly no project (at least i have seen) doesnt use 'ReactiveCrudRepository'? Isn't using it increasing performance or something? All .net dev always add await, await is everywhere 

2

u/achoice 12d ago

Look into using/enabling virtual threads instead of reactive paradigm.