Connection error when using Hibernate logs

0

I'm trying to see the sqls generated by Hibernate in my JAVA application but I'm having problems because adding the two commands below throws some exceptions.

Commands I'm inserting in persistence.xml:

  <property name="hibernate.show_sql">true</property> <!-- Show SQL in console -->
  <property name="hibernate.format_sql">true</property> <!-- Show SQL formatted -->

My complete persistence.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="XXXXXX" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <properties>
      <property name="hibernate.connection.username" value="postgres"/>
      <property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
      <property name="hibernate.connection.password" value="root"/>
      <property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/xxxx_new"/>
      <property name="hibernate.connection.autocommit" value="true"/>
      <property name="hibernate.cache.use_query_cache" value="false"/>
      <property name="hibernate.cache.use_second_level_cache" value="false"/>
      <property name="hibernate.hbm2ddl.auto" value="update"/>
      <property name="javax.persistence.sql-load-script-source" value="&lt;property name=&quot;hibernate.show_sql&quot;&gt;true&lt;/property&gt;"/>                         
        <property name="hibernate.show_sql">true</property> <!-- sem essas duas linhs funciona -->
        <property name="hibernate.format_sql">true</property> <!-- sem essas duas linhs funciona -->
    </properties>
  </persistence-unit>
</persistence>

When I add the 2 lines to see the log I have the following Exception:

javax.persistence.PersistenceException: Invalid persistence.xml.
Error parsing XML [line : -1, column : -1] : cvc-complex-type.4: O atributo 'value' deve aparecer no elemento 'property'.
Error parsing XML [line : -1, column : -1] : cvc-complex-type.2.1: O elemento 'property' não deve ter um caractere ou um item com informações do elemento [children] porque o tipo de conteúdo do tipo é vazio.
Error parsing XML [line : -1, column : -1] : cvc-complex-type.4: O atributo 'value' deve aparecer no elemento 'property'.
Error parsing XML [line : -1, column : -1] : cvc-complex-type.2.1: O elemento 'property' não deve ter um caractere ou um item com informações do elemento [children] porque o tipo de conteúdo do tipo é vazio.
    
asked by anonymous 09.03.2018 / 14:55

1 answer

1

Change the commands to these:

<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />

Using the value property to set value.

    
09.03.2018 / 15:01