From b50c73f35711d2d965dfa4fe9918f14504d628b7 Mon Sep 17 00:00:00 2001 From: Patrick Linskey Date: Thu, 25 Oct 2007 22:14:55 +0000 Subject: [PATCH] OPENJPA-413. Some more clarifications in confusing error messages. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@588373 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/openjpa/kernel/AttachStrategy.java | 6 ++---- .../openjpa/kernel/SingleFieldManager.java | 7 +++---- .../openjpa/kernel/localizer.properties | 21 ++++++++++++------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AttachStrategy.java b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AttachStrategy.java index 15da014ca..17dac861b 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AttachStrategy.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AttachStrategy.java @@ -273,10 +273,8 @@ abstract class AttachStrategy if (oid != null) return manager.getBroker().find(oid, false, null); } - throw new UserException(_loc.get("cant-cascade-attach", - Exceptions.toString(toAttach), vmd, - Exceptions.toString(sm.getManagedInstance()))). - setFailedObject(toAttach); + throw new UserException(_loc.get("cant-cascade-attach", vmd)) + .setFailedObject(toAttach); } /** diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java index 31afc40b2..0563ab4fb 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java @@ -747,10 +747,9 @@ class SingleFieldManager sm = _broker.getStateManager(obj); if (sm == null || !sm.isPersistent()) - throw new InvalidStateException(_loc.get("cant-cascade-persist", - Exceptions.toString(obj), vmd, - Exceptions.toString(_sm.getManagedInstance()))). - setFailedObject(obj); + throw new InvalidStateException( + _loc.get("cant-cascade-persist", vmd)) + .setFailedObject(obj); } else { sm = _broker.getStateManager(obj); if (sm == null || !sm.isProvisional()) diff --git a/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties b/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties index 3a0b9af63..206825fd7 100644 --- a/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties +++ b/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties @@ -211,13 +211,20 @@ nontrans-proxied: You cannot make a property access object created with "new" \ nontransactional. no-field: Field "{0}" is not declared in "{1}", or is not managed. no-field-index: "{0}" is not the index of any managed field in "{1}". -cant-cascade-persist: Encountered unmanaged object "{0}" in persistent field \ - "{1}" of managed object "{2}" during flush. However, this field does not \ - allow to be CascadeType.PERSIST. You cannot flush unmanaged objects. -cant-cascade-attach: Encountered new object "{0}" in persistent field \ - "{1}" of managed object "{2}" during attach. However, this field does not \ - allow to cascade during attach. You cannot attach a reference to a new object \ - without cascading. +cant-cascade-persist: Encountered unmanaged object in persistent field \ + "{0}" during flush. However, this field does not \ + allow cascade persist. Set the cascade attribute for this field to \ + CascadeType.PERSIST or CascadeType.ALL (JPA annotations) or \ + "persist" or "all" (JPA orm.xml), or enable cascade-persist globally, \ + or manually persist the related field value prior to flushing. \ + You cannot flush unmanaged objects or graphs that have persistent \ + associations to unmanaged objects. +cant-cascade-attach: Encountered new object in persistent field \ + "{0}" during attach. However, this field does not \ + allow cascade attach. Set the cascade attribute for this field to \ + CascadeType.MERGE or CascadeType.ALL (JPA annotations) or \ + "merge" or "all" (JPA orm.xml). \ + You cannot attach a reference to a new object without cascading. ref-to-deleted: Encountered deleted object "{0}" in persistent field \ "{1}" of managed object "{2}" during flush. no-version-field: Encountered object "{0}" without a version field during \