java - Obtaining a Hibernate transaction within a Spring class -


I am working on a program that uses spring and the hibernate transaction transparently uses a TransactionInterceptor . It is very convenient to say, "When this method is brought from any other category, it wraps in the transaction if it is not already in one."

However, I have a class that has to try to write and should know immediately whether it has been successful or not. Whenever I wanted two ways, I was hoping that there was a way to put them in the same class without the need to make the transaction process clearly, in fact, I want something like this:

  Public Zero Method One () {//... try some stuff {transactionalMethod (); // What I want, it will not do} cache (optical filiur e) {transcriptical mass}} {transcriptical public wired transactional math}} {// some stuff to database}}  

Unfortunately, as I think, this will not work because I am only calling in a transactional way. Is there any way to call me a local method to ask me from spring and if there is any way of wrapping it in the transaction, or should it be in another class that I wardle it?

Define an interface that implements the class which is transactionalMethod () Does; Use dependency injection to determine the value of the square for your own implementation; In your Bean factory, allow Spring to insert an aspect around that interface implementation. This should work for your needs.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -