Hibernate / EclipseLink Interview questions
What is persistence.xml used for?
persistence.xml is the standard JPA configuration file, located under META-INF/, that defines one or more persistence units. It tells the JPA runtime which provider to use, how to connect to the database, which entity classes belong to the unit, and any additional provider-specific properties.
<persistence-unit name="myPU" transaction-type="RESOURCE_LOCAL"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <class>com.example.Employee</class> <properties> <property name="jakarta.persistence.jdbc.url" value="jdbc:h2:mem:testdb"/> <property name="eclipselink.ddl-generation" value="create-tables"/> <property name="eclipselink.logging.level" value="FINE"/> </properties> </persistence-unit>
The eclipselink.* properties shown here are provider-specific extensions, not part of the JPA standard; they only take effect because EclipseLink is the configured provider and recognizes those property names.
More Related questions...