Jakarta persistence.xml Example




Asked on February 06, 2023
How to configure Jakarta persistence.xml in Hibernate.


Replied on February 06, 2023
Find the Jakarta persistence.xml file for Hibernate + MySQL database.

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence
          https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
	version="3.0">
	<persistence-unit name="com.mycomp">
		<description>Hibernate Demo</description>
		<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
		<class>com.mycomp.entity.User</class>
		<properties>
			<property name="hibernate.dialect"
				value="org.hibernate.dialect.MySQLDialect" />
			<property name="jakarta.persistence.jdbc.driver"
				value="com.mysql.cj.jdbc.Driver" />
			<property name="jakarta.persistence.jdbc.url"
				value="jdbc:mysql://localhost/concretepage" />
			<property name="jakarta.persistence.jdbc.user" value="root" />
			<property name="jakarta.persistence.jdbc.password"
				value="pwd" />
		</properties>
	</persistence-unit>
</persistence> 




Write Answer








©2024 concretepage.com | Privacy Policy | Contact Us