Skip to content
Advertisement

How to solve Error when save Entity with List

I have next Entity(List was added with last update):

@Entity
@Table(name = "settings", schema = "notpublic")
public class Settings {

    @Id
    @GeneratedValue(generator = "settings_seq", strategy = GenerationType.SEQUENCE)
    @SequenceGenerator(name = "settings_seq", sequenceName = "notpublic.settings_seq", schema = "notpublic", allocationSize = 1)
    private Long id;
    
    @Column
    private String code;
    
    @ElementCollection
    @CollectionTable(name = "settings_bank", joinColumns = { @JoinColumn(name = "id") })
    @Column(name = "bank_id")
    private List<Long> bankIds;

And liquibase update:

<createTable tableName="settings_bank" schemaName="notpublic">
            <column name="id" type="BIGINT">
                <constraints nullable="false"/>
            </column>
            <column name="bank_id" type="BIGINT">
                <constraints nullable="false"/>
            </column>
        </createTable>

Well, when I try to save entity I get rg.postgresql.util.PSQLException: ERROR: relation “settings_bank” does not exist. I connect to DB by pgAdmin and- table was created.. List bankIds- just Long, its not connect to another Entity. What I missed and how to fix it?

Advertisement

Answer

I solve it, forget schema in @CollectionTable

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement