
|
If you were logged in you would be able to see more operations.
|
|
|
Time Tracking:
Issue & Sub-Tasks
Issue Only
Issue & Sub-Tasks
Issue Only
|
|
|
| Resolution Date: |
02/Feb/07 09:17 PM
|
|
No sub-tasks match this view.
|
|
|
|
From the dev mailing list...
=======================================
We've noticed that when EntityManager.clear() is invoked, an implicit flush() is performed. Although the spec is cloudy in this area, I don't think this processing is correct. The javadoc is as follows for clear():
/**
* Clear the persistence context, causing all managed
* entities to become detached. Changes made to entities that
* have not been flushed to the database will not be
* persisted.
*/
public void clear();
This indicates that Entities that have not been flushed will not be persisted. Thus, I would say this implies that we should not be doing an implicit flush. If the application wanted their Entities to be flushed before the clear, then they can call the flush() method before calling clear(). We shouldn't be doing this for them because then they have no choice.
The Pro EJB3 Java Persistence API book has similar wording on pages 138-139:
"..In many respects [clear] is semantically equivalent to a transaction rollback. All entity instances managed by the persistence context become detached with their state left exactly as it was when the clear() operation was invoked..."
Our current processing for clear() eventually gets to this code:
public void detachAll(OpCallbacks call) {
beginOperation(true);
try {
if ((_flags & FLAG_FLUSH_REQUIRED) != 0)
flush();
detachAllInternal(call);
} catch (OpenJPAException ke) {
throw ke;
} catch (RuntimeException re) {
throw new GeneralException(re);
} finally {
endOperation();
}
}
Basically, if we have dirtied the Persistence Context, then do a flush() followed by the detachAllInternal(). I don't think the clear() should be doing this flush() operation. Any disagreement?
=======================================
There was no disagreement, thus this JIRA issue.
|
|
Description
|
From the dev mailing list...
=======================================
We've noticed that when EntityManager.clear() is invoked, an implicit flush() is performed. Although the spec is cloudy in this area, I don't think this processing is correct. The javadoc is as follows for clear():
/**
* Clear the persistence context, causing all managed
* entities to become detached. Changes made to entities that
* have not been flushed to the database will not be
* persisted.
*/
public void clear();
This indicates that Entities that have not been flushed will not be persisted. Thus, I would say this implies that we should not be doing an implicit flush. If the application wanted their Entities to be flushed before the clear, then they can call the flush() method before calling clear(). We shouldn't be doing this for them because then they have no choice.
The Pro EJB3 Java Persistence API book has similar wording on pages 138-139:
"..In many respects [clear] is semantically equivalent to a transaction rollback. All entity instances managed by the persistence context become detached with their state left exactly as it was when the clear() operation was invoked..."
Our current processing for clear() eventually gets to this code:
public void detachAll(OpCallbacks call) {
beginOperation(true);
try {
if ((_flags & FLAG_FLUSH_REQUIRED) != 0)
flush();
detachAllInternal(call);
} catch (OpenJPAException ke) {
throw ke;
} catch (RuntimeException re) {
throw new GeneralException(re);
} finally {
endOperation();
}
}
Basically, if we have dirtied the Persistence Context, then do a flush() followed by the detachAllInternal(). I don't think the clear() should be doing this flush() operation. Any disagreement?
=======================================
There was no disagreement, thus this JIRA issue. |
Show » |
made changes - 01/Feb/07 09:06 PM
| Field |
Original Value |
New Value |
|
Description
|
From the dev mailing list...
=======================================
We've noticed that when EntityManager.clear() is invoked, an implicit flush() is performed. Although the spec is cloudy in this area, I don't think this processing is correct. The javadoc is as follows for clear():
/**
* Clear the persistence context, causing all managed
* entities to become detached. Changes made to entities that
* have not been flushed to the database will not be
* persisted.
*/
public void clear();
This indicates that Entities that have not been flushed will not be persisted. Thus, I would say this implies that we should not be doing an implicit flush. If the application wanted their Entities to be flushed before the clear, then they can call the flush() method before calling clear(). We shouldn't be doing this for them because then they have no choice.
The Pro EJB3 Java Persistence API book has similar wording on pages 138-139:
"..In many respects [clear] is semantically equivalent to a transaction rollback. All entity instances managed by the persistence context become detached with their state left exactly as it was when the clear() operation was invoked..."
Our current processing for clear() eventually gets to this code:
public void detachAll(OpCallbacks call) {
beginOperation(true);
try {
if ((_flags & FLAG_FLUSH_REQUIRED) != 0)
flush();
detachAllInternal(call);
} catch (OpenJPAException ke) {
throw ke;
} catch (RuntimeException re) {
throw new GeneralException(re);
} finally {
endOperation();
}
}
Basically, if we have dirtied the Persistence Context, then do a flush() followed by the detachAllInternal(). I don't think the clear() should be doing this flush() operation. Any disagreement?
=======================================
There was no disagreement, thus this JIRA issue.
|
From the dev mailing list...
=======================================
We've noticed that when EntityManager.clear() is invoked, an implicit flush() is performed. Although the spec is cloudy in this area, I don't think this processing is correct. The javadoc is as follows for clear():
/**
* Clear the persistence context, causing all managed
* entities to become detached. Changes made to entities that
* have not been flushed to the database will not be
* persisted.
*/
public void clear();
This indicates that Entities that have not been flushed will not be persisted. Thus, I would say this implies that we should not be doing an implicit flush. If the application wanted their Entities to be flushed before the clear, then they can call the flush() method before calling clear(). We shouldn't be doing this for them because then they have no choice.
The Pro EJB3 Java Persistence API book has similar wording on pages 138-139:
"..In many respects [clear] is semantically equivalent to a transaction rollback. All entity instances managed by the persistence context become detached with their state left exactly as it was when the clear() operation was invoked..."
Our current processing for clear() eventually gets to this code:
public void detachAll(OpCallbacks call) {
beginOperation(true);
try {
if ((_flags & FLAG_FLUSH_REQUIRED) != 0)
flush();
detachAllInternal(call);
} catch (OpenJPAException ke) {
throw ke;
} catch (RuntimeException re) {
throw new GeneralException(re);
} finally {
endOperation();
}
}
Basically, if we have dirtied the Persistence Context, then do a flush() followed by the detachAllInternal(). I don't think the clear() should be doing this flush() operation. Any disagreement?
=======================================
There was no disagreement, thus this JIRA issue.
|
made changes - 02/Feb/07 09:17 PM
|
Resolution
|
|
Fixed
[ 1
]
|
|
Status
|
Open
[ 1
]
|
Resolved
[ 5
]
|
made changes - 01/Mar/07 02:13 AM
|
Fix Version/s
|
|
0.9.7
[ 12312340
]
|
made changes - 31/Jul/07 07:01 PM
|
Status
|
Resolved
[ 5
]
|
Closed
[ 6
]
|
|
After analyzing this further, the detachAllInternal() invocation eventually creates a DetachManager passing in "true" as the second parameter on the constructor. This "true" parameter indicates that any flushing has already been processed, as the following javadoc indicates:
* @param full whether the entire broker cache is being detached; if
* this is the case, we assume the broker has already
* flushed if needed, and that we're detaching in-place
Thus, when we get to the detachInternal method on the DetachManager, the _flushed flag is already set to true and no more flushing is performed.
So, by removing the flush() processing in the detachAll() method on BrokerImpl, it seems to resolve the problem.
Abe had indicated that we still might need this flush processing for JDO. But, since I don't know how JDO is using the kernel, it's kind of difficult for me to determine how to make this work for both cases -- since I don't know the code paths that JDO follows. So, my take is that I will fix the problem for the JPA clear() processing. If this causes a problem with other usages of the kernel, then somebody more familiar with that usage may need to further adjust the code.
Fair? Or, am I missing something?
Kevin