Class DurationToIntervalConverter

  • All Implemented Interfaces:
    javax.persistence.AttributeConverter<Duration,​String>

    public class DurationToIntervalConverter
    extends Object
    implements javax.persistence.AttributeConverter<Duration,​String>
    Postgresql has a dedicated Interval type. I tried to get it working with something like this. It didn't work, I couldn't get hibernate to not report: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Wrong column type in public.subtitles for column offset. Found: interval, expected: varchar(255)
    Since:
    0.47
    Author:
    Michiel Meeuwissen
    • Constructor Detail

      • DurationToIntervalConverter

        public DurationToIntervalConverter()
    • Method Detail

      • convertToDatabaseColumn

        public String convertToDatabaseColumn​(Duration duration)
        Specified by:
        convertToDatabaseColumn in interface javax.persistence.AttributeConverter<Duration,​String>
      • convertToEntityAttribute

        public Duration convertToEntityAttribute​(String timestamp)
        Specified by:
        convertToEntityAttribute in interface javax.persistence.AttributeConverter<Duration,​String>