Hello All:

I have an attribute that is using the javaEnum prototype. This works awesome - 
until some value comes trouncing through from the source DB (not under my 
control) that is, in some circumstances an empty string instead of one of the 
enum values. This yields an error like this which is understandable:

IllegalArgumentException: No enum constant 
edu.ucla.gseis.core.enums.PaySchedule.  
  at java.lang.Enum.valueOf(Enum.java:238)
  at edu.ucla.gseis.core.enums.PaySchedule.valueOf(PaySchedule.java:1)

So, I tried to change the factory method (from ‘valueOf') in the model to use 
my custom fromString method in my enum. The method should call valueOf just 
like the original factory method.

public PaySchedule fromString(String aString) {
    
    if (S.isEmpty(aString)) {
      log.info("trying to convert the value of an empty string to PaySchedule. 
Switching to UN forced.");
      return valueOf("UN");
    }
    return valueOf(aString);
}

However, now I get a new error like below. Notice this is happening when 
fetching EO’s that use this attribute. Does anyone have some kung-fu to help me 
here? Or do I have to abandon use of the javaEnum prototype here?

IllegalArgumentException: object is not an instance of declaring class
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     ... skipped 5 stack elements
  at 
com.webobjects.eoaccess.EOAttribute.newValueForString(EOAttribute.java:1039)
  at 
com.webobjects.jdbcadaptor.JDBCColumn._newValueForString(JDBCColumn.java:675)
  at 
com.webobjects.jdbcadaptor.JDBCColumn._fetchCorrectObject(JDBCColumn.java:334)
  at com.webobjects.jdbcadaptor.JDBCColumn._fetchValue(JDBCColumn.java:384)
  at com.webobjects.jdbcadaptor.ERXJDBCColumn._fetchValue(ERXJDBCColumn.java:81)
  at 
com.webobjects.jdbcadaptor.DateJDBCColumn._fetchValue(DateJDBCColumn.java:63)
  at com.webobjects.jdbcadaptor.JDBCColumn.fetchValue(JDBCColumn.java:372)
  at com.webobjects.jdbcadaptor.ERXJDBCColumn.fetchValue(ERXJDBCColumn.java:1)
  at com.webobjects.jdbcadaptor.DateJDBCColumn.fetchValue(DateJDBCColumn.java:1)
     ... skipped 4 stack elements
  at 
com.webobjects.eocontrol.EOObjectStoreCoordinator.objectsWithFetchSpecification(EOObjectStoreCoordinator.java:488)
  at 
com.webobjects.eocontrol.EOEditingContext.objectsWithFetchSpecification(EOEditingContext.java:4069)
  at er.extensions.eof.ERXEC.objectsWithFetchSpecification(ERXEC.java:1308)
  at 
com.webobjects.eocontrol.EOEditingContext.objectsWithFetchSpecification(EOEditingContext.java:4444)
  at 
er.extensions.eof.ERXFetchSpecification.fetchObjects(ERXFetchSpecification.java:155)
  at 
edu.ucla.qdb.employee.entities._QDBEmployeeAppt.fetchQDBEmployeeAppts(_QDBEmployeeAppt.java:645)
  at 
edu.ucla.qdb.sync.QDBSyncUtil.getQdbAppointmentsWithDeptCodesForSyncing(QDBSyncUtil.java:826)

Tim
UCLA GSE&IS
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to