Giter Site home page Giter Site logo

The custom repository implementation should inherit the entity-manager-ref and transaction-manager-ref config [DATAJPA-18] about spring-data-jpa HOT 6 CLOSED

spring-projects avatar spring-projects commented on May 27, 2024
The custom repository implementation should inherit the entity-manager-ref and transaction-manager-ref config [DATAJPA-18]

from spring-data-jpa.

Comments (6)

spring-projects-issues avatar spring-projects-issues commented on May 27, 2024

Oliver Drotbohm commented

It's all about annotating your custom implementation with @Transactional("yourTransactionManager") (see Spring reference documentation for details. Same applies to @PersistenceContext

from spring-data-jpa.

spring-projects-issues avatar spring-projects-issues commented on May 27, 2024

jokeway commented

Yes, I know that Spring treatment, so I make the report as type 'Improvement'.
The Respository custom implementation bean registed by 'spring-data', and implemented as part of RepositoryInterface, I think 'spring-data' should handle the Transactional and PersistenceContext automatically by the <jpa:repositories /> setting.

Do not know whether this is a popular demand, but I think that allows me not to modify the code or the base class when switch entity manager factory.

from spring-data-jpa.

spring-projects-issues avatar spring-projects-issues commented on May 27, 2024

wims.tijd commented

annotating custom implementation with @PersistenceContext(unitName="2nd-pu") did not work.
since i have 2 persistenceunits i had to set its dependecy in the config file and call emf.getEntityManger
where i lost the @Transactional config

it think it is not an improvement since the custom methods where querying the wrong database

from spring-data-jpa.

spring-projects-issues avatar spring-projects-issues commented on May 27, 2024

jokeway commented

Has no plan to fix it?

from spring-data-jpa.

spring-projects-issues avatar spring-projects-issues commented on May 27, 2024

Oliver Drotbohm commented

To be honest, no. The main reason I am hesitant to activate this is the fact that this would lead to a gap between what's annotated in the code and what actually is happening. Assume you have a configuration of

<jpa:repositories base-package="…" transaction-manager-ref="myTransactionManager" />

if you now annotate the repository interface as follows:

@Transactional
interface CustomerRepository extends Repository<Customer, Long> { … }

This is highly misleading as - if we follow the suggestion - we would need to trigger a transaction with myTransactionManager which is not in line what @Transactional requires (using the default PlatformTransactionManager if no value attribute is defined). Consider implementing a custom @MyTransactional annotation and equip that with @Transactional("myTransactionManager") to avoid scattering the name al over the repositories.

Beyond that, we have exactly 2 votes for this so far, so I think most users value the alignment with @Transactional semantics

from spring-data-jpa.

spring-projects-issues avatar spring-projects-issues commented on May 27, 2024

Jens Schauder commented

Batch closing resolved issue without a fix version and a resolution indicating that there is nothing to release (Won't fix, Invalid ...)

from spring-data-jpa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.