Why @Transactional is not prolonged to repository method? The Next CEO of Stack OverflowWhat is reflection and why is it useful?What is a serialVersionUID and why should I use it?What's the difference between @Component, @Repository & @Service annotations in Spring?Why is subtracting these two times (in 1927) giving a strange result?Why don't Java's +=, -=, *=, /= compound assignment operators require casting?Why is char[] preferred over String for passwords?Why is it faster to process a sorted array than an unsorted array?Why is printing “B” dramatically slower than printing “#”?@Transactional take old values on not committed transactionChanging values with query Spring Data methods

How easy is it to start Magic from scratch?

Is a stroke of luck acceptable after a series of unfavorable events?

What does this shorthand mean?

How to get regions to plot as graphics

Should I tutor a student who I know has cheated on their homework?

Anatomically Correct Mesopelagic Aves

Is HostGator storing my password in plaintext?

WOW air has ceased operation, can I get my tickets refunded?

India just shot down a satellite from the ground. At what altitude range is the resulting debris field?

Where to find order of arguments for default functions

When airplanes disconnect from a tanker during air to air refueling, why do they bank so sharply to the right?

What is the purpose of the Evocation wizard's Potent Cantrip feature?

How to use tikz in fbox?

Does it take more energy to get to Venus or to Mars?

Horror movie/show or scene where a horse creature opens its mouth really wide and devours a man in a stables

% symbol leads to superlong (forever?) compilations

Implement the Thanos sorting algorithm

Opposite of a diet

If the heap is initialized for security, then why is the stack uninitialized?

Is it safe to use c_str() on a temporary string?

Why didn't Khan get resurrected in the Genesis Explosion?

Can a caster that cast Polymorph on themselves stop concentrating at any point even if their Int is low?

How to write the block matrix in LaTex?

Why were Madagascar and New Zealand discovered so late?



Why @Transactional is not prolonged to repository method?



The Next CEO of Stack OverflowWhat is reflection and why is it useful?What is a serialVersionUID and why should I use it?What's the difference between @Component, @Repository & @Service annotations in Spring?Why is subtracting these two times (in 1927) giving a strange result?Why don't Java's +=, -=, *=, /= compound assignment operators require casting?Why is char[] preferred over String for passwords?Why is it faster to process a sorted array than an unsorted array?Why is printing “B” dramatically slower than printing “#”?@Transactional take old values on not committed transactionChanging values with query Spring Data methods










0















I need to perform several operations in one transaction.



I use org.springframework.transaction.annotation.Transactional



One service (with @Transactional) calls another (without @Transactional) and this service calls repository



I have next service



 @Transactional
public void performBatchOperations( List<String> ids)
service1.doAction(ids);
service2.doAction(ids);



service2



@Component
public class Service2 {
@Autowired
private Repo repo;

public void doAction(List<String> ids)
repo.delete(ids);



Repository



@Component
public class Repo extends
JpaRepository<Entity, Long>, JpaSpecificationExecutor<Entity>


@Modifying
@Query("DELETE FROM Entity a WHERE a.jobId IN :ids")
void deleteByJobIdIn(@Param("ids") List<String> ids);



I got next error



Caused by: javax.persistence.TransactionRequiredException: Executing an update/delete query
liberty-debug | at org.hibernate.ejb.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:99)


But i have @Transactional on my service method. Why it wasn't prolonged to Repository?



Is there way to use @Modifying as part of complex transaction?










share|improve this question
























  • Is the rest of spring properly set up?

    – XtremeBaumer
    Mar 7 at 14:29











  • which transactional are you using? (what are you importing)?

    – Andronicus
    Mar 7 at 14:29











  • Check that you're always using @org.springframework.transaction.annotation.Transactional and not mixing it with @javax.transaction.Transactional

    – noiaverbale
    Mar 7 at 14:44











  • This may not be documented clearly, but it is expected that @Modifying methods are also annotated with @Transactional. Doing so will propagate the running transaction to the repository method, as expected. In fact, the official documentation recommends annotating all repository interfaces as @Transactional(readOnly = true). The exception is seen because the proxy generated by Spring Data has no way of knowing if a repository method will always be invoked within a transaction, since the method can as well be called from a non-transactional context (after all, it is a public method).

    – manish
    Mar 8 at 5:13












  • Can I use @Modifying as part of complex transaction?

    – Artyom Karnov
    Mar 8 at 11:00















0















I need to perform several operations in one transaction.



I use org.springframework.transaction.annotation.Transactional



One service (with @Transactional) calls another (without @Transactional) and this service calls repository



I have next service



 @Transactional
public void performBatchOperations( List<String> ids)
service1.doAction(ids);
service2.doAction(ids);



service2



@Component
public class Service2 {
@Autowired
private Repo repo;

public void doAction(List<String> ids)
repo.delete(ids);



Repository



@Component
public class Repo extends
JpaRepository<Entity, Long>, JpaSpecificationExecutor<Entity>


@Modifying
@Query("DELETE FROM Entity a WHERE a.jobId IN :ids")
void deleteByJobIdIn(@Param("ids") List<String> ids);



I got next error



Caused by: javax.persistence.TransactionRequiredException: Executing an update/delete query
liberty-debug | at org.hibernate.ejb.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:99)


But i have @Transactional on my service method. Why it wasn't prolonged to Repository?



Is there way to use @Modifying as part of complex transaction?










share|improve this question
























  • Is the rest of spring properly set up?

    – XtremeBaumer
    Mar 7 at 14:29











  • which transactional are you using? (what are you importing)?

    – Andronicus
    Mar 7 at 14:29











  • Check that you're always using @org.springframework.transaction.annotation.Transactional and not mixing it with @javax.transaction.Transactional

    – noiaverbale
    Mar 7 at 14:44











  • This may not be documented clearly, but it is expected that @Modifying methods are also annotated with @Transactional. Doing so will propagate the running transaction to the repository method, as expected. In fact, the official documentation recommends annotating all repository interfaces as @Transactional(readOnly = true). The exception is seen because the proxy generated by Spring Data has no way of knowing if a repository method will always be invoked within a transaction, since the method can as well be called from a non-transactional context (after all, it is a public method).

    – manish
    Mar 8 at 5:13












  • Can I use @Modifying as part of complex transaction?

    – Artyom Karnov
    Mar 8 at 11:00













0












0








0








I need to perform several operations in one transaction.



I use org.springframework.transaction.annotation.Transactional



One service (with @Transactional) calls another (without @Transactional) and this service calls repository



I have next service



 @Transactional
public void performBatchOperations( List<String> ids)
service1.doAction(ids);
service2.doAction(ids);



service2



@Component
public class Service2 {
@Autowired
private Repo repo;

public void doAction(List<String> ids)
repo.delete(ids);



Repository



@Component
public class Repo extends
JpaRepository<Entity, Long>, JpaSpecificationExecutor<Entity>


@Modifying
@Query("DELETE FROM Entity a WHERE a.jobId IN :ids")
void deleteByJobIdIn(@Param("ids") List<String> ids);



I got next error



Caused by: javax.persistence.TransactionRequiredException: Executing an update/delete query
liberty-debug | at org.hibernate.ejb.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:99)


But i have @Transactional on my service method. Why it wasn't prolonged to Repository?



Is there way to use @Modifying as part of complex transaction?










share|improve this question
















I need to perform several operations in one transaction.



I use org.springframework.transaction.annotation.Transactional



One service (with @Transactional) calls another (without @Transactional) and this service calls repository



I have next service



 @Transactional
public void performBatchOperations( List<String> ids)
service1.doAction(ids);
service2.doAction(ids);



service2



@Component
public class Service2 {
@Autowired
private Repo repo;

public void doAction(List<String> ids)
repo.delete(ids);



Repository



@Component
public class Repo extends
JpaRepository<Entity, Long>, JpaSpecificationExecutor<Entity>


@Modifying
@Query("DELETE FROM Entity a WHERE a.jobId IN :ids")
void deleteByJobIdIn(@Param("ids") List<String> ids);



I got next error



Caused by: javax.persistence.TransactionRequiredException: Executing an update/delete query
liberty-debug | at org.hibernate.ejb.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:99)


But i have @Transactional on my service method. Why it wasn't prolonged to Repository?



Is there way to use @Modifying as part of complex transaction?







java spring hibernate spring-data-jpa spring-data






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 11:01







Artyom Karnov

















asked Mar 7 at 14:25









Artyom KarnovArtyom Karnov

10011




10011












  • Is the rest of spring properly set up?

    – XtremeBaumer
    Mar 7 at 14:29











  • which transactional are you using? (what are you importing)?

    – Andronicus
    Mar 7 at 14:29











  • Check that you're always using @org.springframework.transaction.annotation.Transactional and not mixing it with @javax.transaction.Transactional

    – noiaverbale
    Mar 7 at 14:44











  • This may not be documented clearly, but it is expected that @Modifying methods are also annotated with @Transactional. Doing so will propagate the running transaction to the repository method, as expected. In fact, the official documentation recommends annotating all repository interfaces as @Transactional(readOnly = true). The exception is seen because the proxy generated by Spring Data has no way of knowing if a repository method will always be invoked within a transaction, since the method can as well be called from a non-transactional context (after all, it is a public method).

    – manish
    Mar 8 at 5:13












  • Can I use @Modifying as part of complex transaction?

    – Artyom Karnov
    Mar 8 at 11:00

















  • Is the rest of spring properly set up?

    – XtremeBaumer
    Mar 7 at 14:29











  • which transactional are you using? (what are you importing)?

    – Andronicus
    Mar 7 at 14:29











  • Check that you're always using @org.springframework.transaction.annotation.Transactional and not mixing it with @javax.transaction.Transactional

    – noiaverbale
    Mar 7 at 14:44











  • This may not be documented clearly, but it is expected that @Modifying methods are also annotated with @Transactional. Doing so will propagate the running transaction to the repository method, as expected. In fact, the official documentation recommends annotating all repository interfaces as @Transactional(readOnly = true). The exception is seen because the proxy generated by Spring Data has no way of knowing if a repository method will always be invoked within a transaction, since the method can as well be called from a non-transactional context (after all, it is a public method).

    – manish
    Mar 8 at 5:13












  • Can I use @Modifying as part of complex transaction?

    – Artyom Karnov
    Mar 8 at 11:00
















Is the rest of spring properly set up?

– XtremeBaumer
Mar 7 at 14:29





Is the rest of spring properly set up?

– XtremeBaumer
Mar 7 at 14:29













which transactional are you using? (what are you importing)?

– Andronicus
Mar 7 at 14:29





which transactional are you using? (what are you importing)?

– Andronicus
Mar 7 at 14:29













Check that you're always using @org.springframework.transaction.annotation.Transactional and not mixing it with @javax.transaction.Transactional

– noiaverbale
Mar 7 at 14:44





Check that you're always using @org.springframework.transaction.annotation.Transactional and not mixing it with @javax.transaction.Transactional

– noiaverbale
Mar 7 at 14:44













This may not be documented clearly, but it is expected that @Modifying methods are also annotated with @Transactional. Doing so will propagate the running transaction to the repository method, as expected. In fact, the official documentation recommends annotating all repository interfaces as @Transactional(readOnly = true). The exception is seen because the proxy generated by Spring Data has no way of knowing if a repository method will always be invoked within a transaction, since the method can as well be called from a non-transactional context (after all, it is a public method).

– manish
Mar 8 at 5:13






This may not be documented clearly, but it is expected that @Modifying methods are also annotated with @Transactional. Doing so will propagate the running transaction to the repository method, as expected. In fact, the official documentation recommends annotating all repository interfaces as @Transactional(readOnly = true). The exception is seen because the proxy generated by Spring Data has no way of knowing if a repository method will always be invoked within a transaction, since the method can as well be called from a non-transactional context (after all, it is a public method).

– manish
Mar 8 at 5:13














Can I use @Modifying as part of complex transaction?

– Artyom Karnov
Mar 8 at 11:00





Can I use @Modifying as part of complex transaction?

– Artyom Karnov
Mar 8 at 11:00












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55046130%2fwhy-transactional-is-not-prolonged-to-repository-method%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55046130%2fwhy-transactional-is-not-prolonged-to-repository-method%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved