D
D
Denis Kuznetsov2019-04-13 18:36:39
PostgreSQL
Denis Kuznetsov, 2019-04-13 18:36:39

How to write the config for Hibernate correctly?

I came across such a hefty error text, the essence of which, if I understood correctly, is that I incorrectly indicated the properties in xml
5cb2005d53488324455512.jpeg5cb2011bb0072741930908.png
, yeah, and I wanted to ask how it is correct to register this config, for me it looks like this

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

and here is the postgres itself (it seems that the database is written correctly and the login and password too)
5cb201b87b916757940943.png
I hope for your wisdom,
thanks in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2019-04-13
@DennisKingsman

Java is such a special language for generating kilometer backtrace...
Why did you get null value in column violates not-null constraint and think that you have a problem with connecting to the DBMS? You are trying to insert NULL into a field marked NOT NULL. Judging by the text of the request, you did not specify the default value for this field.

S
sergey, 2019-04-13
kuzmin @sergueik

hibernare.cfg.xml seems to be missing <mapping class="..."/>
- in your picture with an error there is a SQL schema non null constraint violation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question