|
|
|
Hibernate 3, Транзакции и Session.flush()
|
|||
|---|---|---|---|
|
#18+
Клиент отправляет сервлету данные о товаре (Заказ). Хочется сделать транзакцию, в которой: При удачном исходе заказ ляжет в базу данных. При неудачном - не ляжет. Написал такой код(Session - ThreadLocal): Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. Hibernate вызывает flush() сам, хотя по докам вроде бы не должен. Изменения ложатся в базу. А мне это нежелательно. Хочу чтобы они были только после commit(). 2. Что делает tx.rollback()? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 13.09.2006, 14:59 |
|
||
|
Hibernate 3, Транзакции и Session.flush()
|
|||
|---|---|---|---|
|
#18+
Есть предположение, что проблема в методе Код: plaintext Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 14.09.2006, 06:50 |
|
||
|
Hibernate 3, Транзакции и Session.flush()
|
|||
|---|---|---|---|
|
#18+
2 pretender: попробовал так. Тоже самое. Это та же сессия. Вот мой Hibernate3Support: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. 116. 117. 118. hibernate 3.0 reference The SQL statements are issued in the following order 1. all entity insertions, in the same order the corresponding objects were saved using Session.save() 2. all entity updates 3. all collection deletions 4. all collection element deletions, updates and insertions 5. all collection insertions 6. all entity deletions, in the same order the corresponding objects were deleted using Session.delete() (An exception is that objects using native ID generation are inserted when they are saved.) Except when you explicity flush(), there are absolutely no guarantees about when the Session executes the JDBC calls, only the order in which they are executed. However, Hibernate does guarantee that the Query.list(..) will never return stale data; nor will they return the wrong data. Может из-за этого?: An exception is that objects using native ID generation are inserted when they are saved ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 14.09.2006, 07:28 |
|
||
|
Hibernate 3, Транзакции и Session.flush()
|
|||
|---|---|---|---|
|
#18+
Хм. поэкспериментировал с Вашим примером. Действительно когда переделал Код: plaintext Если же Код: plaintext Код: plaintext то Hibernate не обращает никакого внимания на уставноку FlashMode.NEVER и сохраняет объекты в момент их создания. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 14.09.2006, 09:02 |
|
||
|
|

start [/forum/topic.php?fid=59&msg=33984366&tid=2148136]: |
0ms |
get settings: |
8ms |
get forum list: |
20ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
207ms |
get topic data: |
9ms |
get forum data: |
2ms |
get page messages: |
27ms |
get tp. blocked users: |
1ms |
| others: | 223ms |
| total: | 505ms |

| 0 / 0 |
