arminw 2005/02/15 07:38:18
Modified: src/java/org/apache/ojb/broker Identity.java
Log:
add more detailed log msg
Revision Changes Path
1.39 +24 -10 db-ojb/src/java/org/apache/ojb/broker/Identity.java
Index: Identity.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/Identity.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- Identity.java 20 Sep 2004 13:43:00 -0000 1.38
+++ Identity.java 15 Feb 2005 15:38:18 -0000 1.39
@@ -22,6 +22,8 @@
import org.apache.ojb.broker.core.proxy.ProxyHelper;
import org.apache.ojb.broker.util.BrokerHelper;
import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.SystemUtils;
+import org.apache.commons.lang.ArrayUtils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -154,8 +156,19 @@
}
catch (Exception e)
{
- throw new ClassNotPersistenceCapableException("Can not init
Identity for given object " +
- objectToIdentify, e);
+ if(e instanceof ClassNotPersistenceCapableException)
+ {
+ throw (ClassNotPersistenceCapableException) e;
+ }
+ else
+ {
+ String eol = SystemUtils.LINE_SEPARATOR;
+ throw new ClassNotPersistenceCapableException("Can not init
Identity for given object." + eol +
+ "objectTopLevelClass=" + (m_objectsTopLevelClass != null
? m_objectsTopLevelClass.getName() : null) + eol +
+ "objectRealClass=" + (m_objectsRealClass != null ?
m_objectsRealClass.getName() : null) + eol +
+ "pkValues=" + (m_pkValues != null ?
ArrayUtils.toString(m_pkValues) : null) + eol +
+ "object to identify: " + objectToIdentify, e);
+ }
}
}
@@ -272,12 +285,13 @@
protected void checkForPrimaryKeys() throws
ClassNotPersistenceCapableException
{
// if no PKs are specified OJB can't handle this class !
- if (m_pkValues.length == 0)
+ if (m_pkValues == null || m_pkValues.length == 0)
{
- throw new ClassNotPersistenceCapableException(
- "OJB needs at least one primary key attribute for class "
- + " objectsRealClass=" + m_objectsRealClass
- + ", objectTopLevelClass=" + m_objectsTopLevelClass);
+ String eol = SystemUtils.LINE_SEPARATOR;
+ throw new ClassNotPersistenceCapableException("OJB needs at
least one primary key attribute for class: " + eol +
+ "objectTopLevelClass=" + (m_objectsTopLevelClass != null
? m_objectsTopLevelClass.getName() : null) + eol +
+ "objectRealClass=" + (m_objectsRealClass != null ?
m_objectsRealClass.getName() : null) + eol +
+ "pkValues=" + (m_pkValues != null ?
ArrayUtils.toString(m_pkValues) : null) + eol);
}
if(m_pkValues[0] instanceof ValueContainer)
@@ -329,8 +343,8 @@
* equal for Identities where Identity.equals() returns true. Therefore
* all primary key values that return a hashcode depending on its content
* (this is assumed for String and Number) are taken into account.
Additionally
- * the hashCode() of the Class this Identity is representing is taken
into
- * account.
+ * the hashCode() of the top-level class name of this Identity is
representing
+ * is taken into account.
*/
public int hashCode()
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]