mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-02 19:27:57 +08:00
EclipseLink ORM (fixed unfetched attribute exception handler). #PL-5412
This commit is contained in:
parent
b667015e8f
commit
3d581cfac9
@ -23,25 +23,9 @@ public class CubaEntityFetchGroup extends EntityFetchGroup {
|
||||
|
||||
@Override
|
||||
public String onUnfetchedAttribute(FetchGroupTracker entity, String attributeName) {
|
||||
if (entity._persistence_getSession() == null) {
|
||||
throw new IllegalEntityStateException(ExceptionLocalization.buildMessage("cannot_get_unfetched_attribute", new Object[]{entity, attributeName}));
|
||||
}
|
||||
if (attributeName == null) { // occurs on merge
|
||||
if (attributeName == null && entity._persistence_getSession() != null) { // occurs on merge
|
||||
return super.onUnfetchedAttribute(entity, null);
|
||||
}
|
||||
throw new IllegalEntityStateException("Attribute '" + entity.getClass().getSimpleName() + "." + attributeName +
|
||||
"' is not included into view");
|
||||
throw new IllegalEntityStateException(ExceptionLocalization.buildMessage("cannot_get_unfetched_attribute", new Object[]{entity, attributeName}));
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public String onUnfetchedAttributeForSet(FetchGroupTracker entity, String attributeName) {
|
||||
// if (entity instanceof ChangeTracker) {
|
||||
// AttributeChangeListener changeListener =
|
||||
// (AttributeChangeListener) ((ChangeTracker) entity)._persistence_getPropertyChangeListener();
|
||||
// if (changeListener != null && changeListener.hasChanges())
|
||||
// throw new IllegalStateException("Attribute '" + entity.getClass().getSimpleName() + "." + attributeName +
|
||||
// "' is unfetched. Unable to refresh the instance because its state has already been changed");
|
||||
// }
|
||||
// return super.onUnfetchedAttributeForSet(entity, attributeName);
|
||||
// }
|
||||
}
|
@ -24,12 +24,15 @@ public class UnfetchedAttributeAccessExceptionHandler extends AbstractGenericExc
|
||||
private static final Pattern PATTERN = Pattern.compile("at (.+)\\._persistence_get_(.+)\\(");
|
||||
|
||||
public UnfetchedAttributeAccessExceptionHandler() {
|
||||
super("org.eclipse.persistence.exceptions.ValidationException");
|
||||
super("com.haulmont.cuba.core.global.IllegalEntityStateException",
|
||||
"org.eclipse.persistence.exceptions.ValidationException");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canHandle(String className, String message, @Nullable Throwable throwable) {
|
||||
return message.contains("An attempt was made to traverse a relationship using indirection that had a null Session");
|
||||
return className.equals("com.haulmont.cuba.core.global.IllegalEntityStateException")
|
||||
|| (className.equals("org.eclipse.persistence.exceptions.ValidationException")
|
||||
&& message.contains("An attempt was made to traverse a relationship using indirection that had a null Session"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user