Yeah, I meant to follow up yesterday and say I fixed that - work blindness. 
That of course redirected me to a an actual error that was easily solvable. The 
custom factory method is working now.

It took me bit to figure out that I wasn’t receiving a null string from the 
source database (SQL Server) - I was receiving a string with two spaces (“  “). 
Just a little annoying.

Tim
UCLA GSE&IS

> On Jan 19, 2016, at 2:00 PM, Chuck Hill <ch...@gevityinc.com> wrote:
> 
> Your method is missing the ‘static’ keyword.  This can’t be an instance 
> method as there is not an instance yet.
> 
> Chuck
> 
> 
> From: <webobjects-dev-bounces+chill=gevityinc....@lists.apple.com 
> <mailto:webobjects-dev-bounces+chill=gevityinc....@lists.apple.com>> on 
> behalf of T Worman <li...@thetimmy.com <mailto:li...@thetimmy.com>>
> Date: Tuesday, January 19, 2016 at 1:27 PM
> To: "webobjects-dev@lists.apple.com <mailto:webobjects-dev@lists.apple.com>" 
> <webobjects-dev@lists.apple.com <mailto:webobjects-dev@lists.apple.com>>
> Subject: enum attribute conundrum
> 
> 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 <http://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