[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Problem with Java Custom Type
I am having difficulty getting the custom type feature in EOF/WebObject 4.0
to work in java (no problems with Obj-C).
The problem is as follows:
I have an entity called Bond which inherits from EOCustomObject and an
attribute called dayCountBasis of type DayCountBasis. In the database this
attribute is stored as a String, but when I fetch in the Bond EO I want this
dayCountBasis attribute to be instantiated as a DayCountBasis object. So my
code looks something like this:
public class Bond extends EOCustomObject {
DayCountBasis dayCountBasis;
public DayCountBasis dayCountBasis() {
willRead();
return dayCountBasis;
}
public void setDayCountBasis(DayCountBasis value) {
willChange();
dayCountBasis = value;
}
// lots of other stuff ....
}
public class DayCountBasis extends java.lang.Object
{
public static DayCountBasis getDayCountBasisFromString(String stringRep)
{
// instantiates the correct subclass of DayCountBasis using the String
stored in the DB
.....
}
public String toString()
{
// returns the string representation of the class for DB storage
......
}
}
Now the attribute is set using the attribute inspector as follows:
Class: customdatatype.DayCountBasis
Factory Method: getDayCountBasisFromString
Conversion Method: toString
Now, I have absolutely no problem doing this in Obj-C, but in java the
attribute keeps getting set with the String stored in the database. It also
seems the factory method is never called.
Any help would be appreciated.
Stephen Gibbs