I want to minimize the @Transactional scope?

Not sure if "scope" is here.

I use Spring to manage JPA transactions (with the Hibernate submenu). My database pre-transaction method is confidential, but since you can set @Transactional in a class or on a public method

Since this mechanism is based on proxy servers, only "external" method calls arriving through the proxy server will be intercepted. This means that "self-start", i.e. A method in the target that calls some other method of the target will not result in an actual transaction at run time, even if the called method is marked with @Transactional!

I set the class public entry point as @Transactional.

@Transactional
public void run(parameters) {
    //First non-database method, takes a decent amount of time
    Data data = getData();
    //Call to database
    storeData(data);
}

private storeData(data) {
    em.persist(data);
}

? Spring , ? storeData() DAO , , - .

+1
2

, , , - , , , . , ...!

+1

, -, , storeData(). , getData() , concurrency , storeData().

+1

All Articles