1
I have these two properties in eclipselink :
<property name="eclipselink.logging.level.sql" value="FINE"/>
<property name="eclipselink.logging.parameters" value="true"/>
but I’d like to see the same using the Hibernate.
Here is my persistence file:
<?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="TestePstgresqlJPA-PU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>br.com.k19.modelos.Autor</class>
<class>br.com.k19.modelos.Editora</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5433/EJB3_Banco"/>
<property name="javax.persistence.jdbc.user" value="postgres"/>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
<property name="javax.persistence.jdbc.password" value="123456"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
I’m using the Maven and below is the POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TestelJPA</groupId>
<artifactId>TestelJPA</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1207</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.10.Final</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<name>TestelJPA</name>
</project>
I’ve been working with the eclipse link for a few months but with Hibernate I’m still a layman, this POM is all right?
Strange, I use these properties and works normal, displays the generated and formatted sql in the console. tried to build the project?
– Geferson
Post your persistence.xml file to have a look.
– Geferson
It worked, but another problem arose!!! When I create a Publisher and Author class and persist everything ok! But when after running it, for example I use find Editora , and run the project it returns an exception: Caused by: org.postgresql.util.Psqlexception: ERROR: relation "author" already exists . Can you help me?
– Pena Pintada
Good that it worked :), I think I should open another topic to detail this problem, so it is easier to find a solution for it.
– Geferson