|
|
|
Что делает CascadeType.Detach
|
|||
|---|---|---|---|
|
#18+
Подскажите плз, что делает и для чего нужен CascadeType.Detach. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 31.05.2013, 13:04:24 |
|
||
|
Что делает CascadeType.Detach
|
|||
|---|---|---|---|
|
#18+
А что делает EntityManager.detach вопроса не возникает? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 31.05.2013, 13:07:59 |
|
||
|
Что делает CascadeType.Detach
|
|||
|---|---|---|---|
|
#18+
Возникает. Что делает? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 31.05.2013, 13:29:26 |
|
||
|
Что делает CascadeType.Detach
|
|||
|---|---|---|---|
|
#18+
osonВозникает. Что делает? Отсоединяет persistent сущность от сессии. persistent сущность - та которая уже лежит в базе и у неё есть ID. detach отвязывает её от сессии aka EM. По идее убирает из кэша 1го уровня. соответсвенно если у дочерней сущности стоит CascadeType.Detach, то при детаче родительской, отсоединены от сессии будут обе. http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/objectstate.html 10.1. Hibernate object states Hibernate defines and supports the following object states: Transient - an object is transient if it has just been instantiated using the new operator, and it is not associated with a Hibernate Session. It has no persistent representation in the database and no identifier value has been assigned. Transient instances will be destroyed by the garbage collector if the application does not hold a reference anymore. Use the Hibernate Session to make an object persistent (and let Hibernate take care of the SQL statements that need to be executed for this transition). Persistent - a persistent instance has a representation in the database and an identifier value. It might just have been saved or loaded, however, it is by definition in the scope of a Session. Hibernate will detect any changes made to an object in persistent state and synchronize the state with the database when the unit of work completes. Developers do not execute manual UPDATE statements, or DELETE statements when an object should be made transient. Detached - a detached instance is an object that has been persistent, but its Session has been closed. The reference to the object is still valid, of course, and the detached instance might even be modified in this state. A detached instance can be reattached to a new Session at a later point in time, making it (and all the modifications) persistent again. This feature enables a programming model for long running units of work that require user think-time. We call them application transactions, i.e., a unit of work from the point of view of the user. We will now discuss the states and state transitions (and the Hibernate methods that trigger a transition) in more detail. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 31.05.2013, 13:53:47 |
|
||
|
Что делает CascadeType.Detach
|
|||
|---|---|---|---|
|
#18+
Спасибо. То есть если я ставлю у отношения OneToMany например аннотацию CascadeType.Detach, то она сработает в том случае, если объект моего класса перестает быть managed. В этом случае и связанная сущность (объект) перестает быть persistence context managed Если нетрудно, а как и когда срабатывает аннотация CascadeType.Refresh? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 02.06.2013, 00:03:12 |
|
||
|
Что делает CascadeType.Detach
|
|||
|---|---|---|---|
|
#18+
Читаем доку по em.refresh() http://docs.oracle.com/javaee/6/api/javax/persistence/EntityManager.html#refresh(java.lang.Object) если не понятно, спрашиваем. если понятно, то должно быть очевидно как и работает соответствующий каскад. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 02.06.2013, 10:36:15 |
|
||
|
|

start [/forum/topic.php?fid=59&fpage=226&tid=2129242]: |
0ms |
get settings: |
14ms |
get forum list: |
21ms |
check forum access: |
9ms |
check topic access: |
9ms |
track hit: |
41ms |
get topic data: |
17ms |
get forum data: |
3ms |
get page messages: |
49ms |
get tp. blocked users: |
2ms |
| others: | 281ms |
| total: | 446ms |

| 0 / 0 |
