Skip to content

Instantly share code, notes, and snippets.

@SergioDiniz
Last active April 14, 2024 19:32
Show Gist options
  • Star 53 You must be signed in to star a gist
  • Fork 18 You must be signed in to fork a gist
  • Save SergioDiniz/886723272d9fd95dd17ecb79b35b66e1 to your computer and use it in GitHub Desktop.
Save SergioDiniz/886723272d9fd95dd17ecb79b35b66e1 to your computer and use it in GitHub Desktop.
<persistence 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"
version="2.1">
<persistence-unit name="persistenceUnitName" transaction-type="RESOURCE_LOCAL">
<properties>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" /> <!-- DB Driver -->
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost/dbName" /> <!-- BD Mane -->
<property name="javax.persistence.jdbc.user" value="postgres" /> <!-- DB User -->
<property name="javax.persistence.jdbc.password" value="12345" /> <!-- DB Password -->
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/> <!-- DB Dialect -->
<property name="hibernate.hbm2ddl.auto" value="update" /> <!-- create / create-drop / update -->
<property name="hibernate.show_sql" value="true" /> <!-- Show SQL in console -->
<property name="hibernate.format_sql" value="true" /> <!-- Show SQL formatted -->
</properties>
</persistence-unit>
</persistence>
@sebkoller
Copy link

sebkoller commented Oct 16, 2017

PostgreSQLDialect is deprecated, according to the docs.
You can use PostgreSQL95Dialect instead.

@Pomile
Copy link

Pomile commented Dec 15, 2019

Well done! @SergioDiniz

@OliverZulett
Copy link

THANKS

@elhadjindongo
Copy link

elhadjindongo commented Apr 29, 2021

Wonderful bro !
You missed the port number on line 11 :
value="jdbc:postgresql://localhost:5432/dbName" -- This is the correct one with the default postgresql port number

@iyage
Copy link

iyage commented Aug 17, 2021

Thanks, great job

@ArturDiasRibeiro
Copy link

Thanks!

@TyutterinYakov
Copy link

Thanks!!!

@dimermichel
Copy link

Thanks!

@FranckyPapaTango
Copy link

Well done !

@santos3du
Copy link

Thanks a lot!

@MaxxselvaK
Copy link

thank you

@rodrigodiaslima1
Copy link

rodrigodiaslima1 commented Oct 29, 2022

What is the part <persistence-unit name=" ..." >
Should I insert there my project's name?

Thanks

@thiagochirana
Copy link

@rodrigodiaslima1 you can insert anything, but when you use it, you need to use the same name in your project.

@deyvisongdias
Copy link

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment