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?

2
  • Mapping postgres' array in hibernate is a bit more complex. Check out stackoverflow.com/a/49968309/7606764 Commented Mar 29, 2020 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! Commented Mar 29, 2020 at 15:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.