Spring, Hibernate, MySQL - How Transactions work - Conclusion/Questions** -


i work spring framework 3.0.5, hibernate 3.6 , mysql server 5.1. ive got questions regarding transaction management in general. use declarative transaction management spring. great if answer questions yes/no (or correct/incorrect) , maybe, if necessary, give short explanations. nice if several people answer in case there different opinions. thank :-)

1) sentences correct: dbms responsible implementation of transactions , behaviour.

1) b) maybe better say: dbms responsible implementation of transactions , behaviour of database (for example when transaction rolled back).

2) hibernate uses database connection. needs transactions, doesnt configurate any(!) settings regarding transactions , behaviour.

3) but: work transactions, hibernate needs know, transactions start, commited , need rolled back.

4) hibernate need know in case of roll happens? think no, because should defined in dbms. (that means: tables shall locked, database operations shall made undone, , on, correct?)

5) 3), programmatic or declarative transaction management can used.

6) when using programmativ transaction management, hibernate needs know (3)) can written in source code manually developer.

7) declarative transaction managament additional framework hibernate necessary, example spring.

8) spring manages transactions. frame them. triggers actions, starting , rolling transaction.

9) spring can define exceptions rollback must or must not happen

10) spring additional things when roll happens? think database responsible roll back, spring triggers it, right? make sure....

thank :-)


[edit] answer duffymo, long comment , not allowed answer own question within 8 hours, thats why ive got put here. sorry.

@duffymo

interesting answers, here thoughts it:

  1. so agree, behaviour of database (of course!) in case when transactions rolled or commited implemented or defined directly dbms, correct? know transaction manager, (platformtransactionmanager), think initiates transactions, roll back, , commit. means, not reponsible how transactions handled database, correct? guess verbalization mistakable, updated (1b)

  2. thats little bit abstract me. mean sentences correct or wasnt :-)

  3. how can mark itself? think must done developer? think of "start tx, commit..." can done in source code developer

  4. i agree. thats 1 thing find little bit difficult understand in documentations. tell transactions catched , arent, in case find out how handle them, have find out yourself. confused in beginning, because not sure if surround call of transactional-annotated method try/catch-block in order catch exception , inform user. not enough have transaction rolled back, need user informed. thats why everywhere use try/catch - how handle this?

  5. this 1 point dont understand. spring offers programmatic , declarative transaction management. if spring itselfs manages transactions, of course declarative transman used. programmatic is... in eyes.. programmatic. im not sure if can "hibernate==programmatic", because can use hibernate both, programmatic , declarative transaction management. maybe possible hibernate not offer declarative transaction management.

  6. i didnt know possible "in jdbc" - must admit dont know how works in detail then. somehow funny, while reading thought im against use of declarative transactions (if did not misunderstand you), appreciate declarative transaction management. :-) think easy use , when reading through code understandable.

  7. if want use hibernate declarative transaction management, need additional framework spring. because declarative means, additional framework "does work have programmatically". (like starting tx, commit, roll back). , guess spring might not framework offers declarative transaction management hibernate. main point in question was, not possible use declarative transaction management hibernate without using additional framework. hope verbalized correctly :-)

  8. ok, correct. transaction manager triggers roll back, starting tx, , on

  9. ok..

  10. sorry :-)

i understand how things work. read through documentations again , again, if learning yourself, important understand essential facts. thats why im asking :-) thank help! :-)

here's take:

  1. ultimately commit/rollback behavior done in relational database, it's not accurate give responsibility database. when use spring, jdbc, , relational database there's middle tier piece that's involved, called transaction manager.
  2. hibernate implements transactional logic programmatically in objects.
  3. hibernate mark start , end of transaction programmatically.
  4. hibernate might want know if transaction rolled back; more importantly, application need know can tell users.
  5. hibernate == programmatic; spring == declarative.
  6. can written developer. can of in jdbc if want. there reasons declarative transactions. (you sound you're trying justify not using them. wonder why?)
  7. don't understand - reword it.
  8. the transaction managers take care of transactions.
  9. spring throw appropriate exceptions, yes.
  10. you seem repeating same questions on , over.

what's real point here? i'd curious know.

you can programmatically in jdbc. java solutions use jdbc interact relational databases use, including hibernate , spring. here's template:

// prototypical write operation public void update(connection connection) throws sqlexception {     connection.setautocommit(false);     try     {         // sql logic here         connection.commit();  // if here, success     }      catch (sqlexception e)     {         try { if (connection != null) connection.rollback(); } catch (sqlexception e) {}         // might other things here (logging, etc.)         // sql error codes tell why; spring translates these you.     }         {         // close statements here in individual try/catch blocks.     } } 

Comments

Popular posts from this blog

Cursor error with postgresql, pgpool and php -

delphi - ESC/P programming! -

c++ - error: use of deleted function -