Skip to content

Instantly share code, notes, and snippets.

@vitorgonzaga
Last active March 11, 2023 00:51
Show Gist options
  • Select an option

  • Save vitorgonzaga/5cd0996019cd978ae42e5881617dde9d to your computer and use it in GitHub Desktop.

Select an option

Save vitorgonzaga/5cd0996019cd978ae42e5881617dde9d to your computer and use it in GitHub Desktop.
persistence.xml MySQL settings
<?xml version="1.0" encoding="UTF-8" ?>
<persistence
version="2.2"
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_2.xsd"
>
<persistence-unit name="loja" transaction-type="RESOURCE_LOCAL" >
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/loja?sessionVariables=sql_mode=''"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="root"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL8Dialect" /> <!-- Just "MySQLDialect" doesn't work for me, was necessary add version 8 into string so, "MySQL8Dialect" -->
<property name="hibernate.show_sql" value="true"/> <!-- to show logs sql in terminal -->
<property name="hibernate.format_sql" value="true"/> <!-- to break lines improving the display of queries -->
<property name="hibernate.hbm2ddl.auto" value="update" /> <!-- to create tables, databases automatically. Values = [create, create-drop, update, validate] -->
</properties>
</persistence-unit>
</persistence>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment