0

where to put @Transactional (Hibernate Spring)

asked 2013-02-28 04:48:01 +0800

arivwd gravatar image arivwd
6 1

Is it legal to place @Transactional in View Model?

And where is the best location to place that annotation?

Thx

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2013-02-28 05:14:09 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2615 3 8
http://emrpms.blogspot.in...

You can check here

link publish delete flag offensive edit
0

answered 2013-02-28 09:18:32 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2013-02-28 09:21:14 +0800

For a clean separation of the application layers you should separate the backend from the frontend. In my eyes the ViewModel is a special 'model' in the frontend and interacts with the the backend methods.

@Transactional should be placed on the 'service' methods who calls one or more 'DAO methods'. In that case the transaction is wrapped around all your several needed dao methods which is often common for more complex crud handling. So it's ensured that all is saved or nothing if an error occurs.

@Transactional
public void saveMyWholeBusinessStuff(){
     getDAO1().save(myFirstBeanToSave);
     getDAO2().save(mySecondBeanToSave);
     getDAO3().update(myThirdStatisticBean);
   }

best Stephan

link publish delete flag offensive edit
0

answered 2013-02-28 11:12:29 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2615 3 8
http://emrpms.blogspot.in...

Yes i agree with Stephan

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2013-02-28 04:48:01 +0800

Seen: 30 times

Last updated: Feb 28 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More