@TomKidelstone

Почему выдает ошибку Caused by: org.postgresql.util.PSQLException: ОШИБКА: отношение «todo.musical_track» не существуетне существует?

64899b71eb134205877528.png

@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "musical_track", schema = "todo",catalog = "music_shop")
public class MusicalTrack {
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Id
    private Integer id;

    @Column(name = "name", nullable = false, length = 32)
    private String name;

    @Column(name = "time", nullable = false)
    private Integer time;

    @Column(name = "genre", nullable = true, length = 16)
    private String genre;

    @Column(name = "album_id", nullable = true)
    private Integer albumId;


import entity.MusicalTrack;
import org.hibernate.Session;

public class Main {
    public static void main(String[] args) {
        Session session = HibernateUtil.getSessionFactory().openSession();
        session.getTransaction().begin();
        MusicalTrack musicalTrack = new MusicalTrack();
        musicalTrack.setName("kasha");
        musicalTrack.setTime(190);
        musicalTrack.setGenre("Rock");
        musicalTrack.setAlbumId(1);
        System.out.println(musicalTrack);

        session.persist(musicalTrack);

        session.getTransaction().commit();
        session.close();
        HibernateUtil.close();
    }
}

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="connection.url">jdbc:postgresql://localhost:5432/postgres</property>
    <property name="connection.driver_class">org.postgresql.Driver</property>
    <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL10Dialect</property>
    <property name="connection.username">postgres</property>
    <property name="connection.password">1905</property>
    <property name="hibernate.show_sql">true</property>




    <mapping class="entity.Performer"/>
    <mapping class="entity.MusicalTrack"/>
    <mapping class="entity.Album"/>
    <mapping class="entity.Playlist"/>
    <mapping class="entity.User"/>


    <!-- DB schema will be updated if needed -->


  </session-factory>
</hibernate-configuration>
  • Вопрос задан
  • 151 просмотр
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы