3

I implemented the solution of how replace XmlGregorianCalendar by Date? but unfortunately it does not function for Lists of dates. In my XSD I have

<xs:element name="Attribute1" type="xs:date" minOccurs="0"> and

<xs:element name="Attribute2" type="xs:date" minOccurs="0" maxOccurs="5">

Attribute2 is a List of dates. If I load an Entity with this attribute I get an java.lang.ClassCastException: org.hibernate.collection.internal.PersistentList incompatible with java.util.Date

I think the problem is that, Hyperjaxb only creates an Adapter

public class Adapter2 extends XmlAdapter<String, Date>
{
    public Date unmarshal(String value) {
        return (XsdDateTimeConverter.unmarshal(value));
    }

    public String marshal(Date value) {
        return (XsdDateTimeConverter.marshalDate(value));
    }

}

Maybe Hyperjaxb also needs to create an Adapter for the List<Date> like public class Adapter3 extends XmlAdapter<List<String>, List<Date>>

Does anyone have a solution for this?

Regards Erzen

PS: I've already seen the questions Simple conversion between java.util.Date and XMLGregorianCalendar, java.util.Date to XMLGregorianCalendar and JAX-WS and Joda-Time? but those do not apply to my problem.

Community
  • 1
  • 1
Erzen
  • 169
  • 10

0 Answers0