Home JPA abstract generics UNION error in PostgreSQL while querying
Reply: 0

JPA abstract generics UNION error in PostgreSQL while querying

Mikołaj Sieniawski
1#
Mikołaj Sieniawski Published in 2017-09-13 20:11:15Z

I have an abstract class:

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class FieldValue<T> {

    @Id @GeneratedValue(strategy = GenerationType.TABLE)
    @Getter @Setter
    private int id;

    @Transient
    @Getter @Setter
    private T value;
}

And the following extensions of this class:

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class DateFieldValue extends FieldValue<Date> {

    @Access(AccessType.PROPERTY)
    @Override
    public Date getValue() {
        return super.getValue();
    }
}

and:

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class IntegerFieldValue extends FieldValue<Integer> {

    @Access(AccessType.PROPERTY)
    @Override
    public Integer getValue() {
        return super.getValue();
    }

}

The creation of the whole database schema runs correctly, there is a table created for each extension class of the abstract class. I can also save and update entities. However, when querying for a list of FieldValue objects:

List<FieldValue> values = fieldValueRepository.findAll();

the following error occurs:

Caused by: org.postgresql.util.PSQLException: UNION types date and character varying cannot be matched

Any ideas how to reseolve this issue?
I'm using JpaRepository from Spring Data JPA for CRUD operations.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.299239 second(s) , Gzip On .

© 2016 Powered by cudou.com design MATCHINFO