0

I'm trying to read all my data from PostgreSQL table and i am troubled to read an string array (in table: text[])

Code:

@Entity
@Table(name = "students")
public class BotUser {

    ...

    @Column(name = "inventory")
    @ElementCollection(targetClass = String.class, fetch = FetchType.EAGER)
    private List<String> inventory;

    ...
}

Exception:

Hibernate: select inventory0_.BotUser_id as BotUser_1_0_0_, inventory0_.inventory as inventor2_0_0_ from BotUser_inventory inventory0_ where inventory0_.BotUser_id=?
org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 0, SQLState: 42P01
org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: ERROR: relation "botuser_inventory" does not exist
  Position: 95

What should I do?

  • Mapping postgres' array in hibernate is a bit more complex. Check out https://stackoverflow.com/a/49968309/7606764 – Andronicus Mar 29 '20 at 15:17
  • @Andronicus, I think this solution is a bit complicated, because I have similar object in another class with similar annotations and it's ok. But, okay, I'll try it, thank you! – Maxim Gaiduchek Mar 29 '20 at 15:31

0 Answers0