Skip to content

Commit bd2be3f

Browse files
committed
write jdoc for HibernatePersistenceConfiguration
1 parent edb3c33 commit bd2be3f

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

hibernate-core/src/main/java/org/hibernate/jpa/HibernatePersistenceConfiguration.java

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.hibernate.cache.spi.access.AccessType;
1414
import org.hibernate.cfg.AvailableSettings;
1515
import org.hibernate.cfg.CacheSettings;
16+
import org.hibernate.cfg.Environment;
1617
import org.hibernate.cfg.JdbcSettings;
1718
import org.hibernate.cfg.JpaComplianceSettings;
1819
import org.hibernate.cfg.MappingSettings;
@@ -29,8 +30,42 @@
2930
import jakarta.persistence.ValidationMode;
3031

3132
/**
32-
* Hibernate extension to the Jakarta Persistence {@link PersistenceConfiguration}
33-
* contract.
33+
* Extends the Jakarta Persistence-defined {@link PersistenceConfiguration}
34+
* with operations specific to Hibernate.
35+
* <p>
36+
* An instance of {@code Configuration} may be obtained simply by
37+
* {@linkplain #HibernatePersistenceConfiguration(String) instantiation},
38+
* and may be used to aggregate:
39+
* <ul>
40+
* <li>{@linkplain #property(String, Object) configuration properties}
41+
* from various sources, and
42+
* <li>entity O/R mappings, defined in either
43+
* {@linkplain #managedClasses(Class...) annotated classes}, or
44+
* {@linkplain #mappingFiles(Collection) XML mapping documents}.
45+
* </ul>
46+
* <p>
47+
* Standard JPA configuration properties are enumerated by the supertype
48+
* {@link PersistenceConfiguration}. All configuration properties understood
49+
* by Hibernate are enumerated by {@link AvailableSettings}.
50+
* <p>
51+
* <pre>
52+
* SessionFactory factory = new HibernatePersistenceConfiguration()
53+
* // scan classes for mapping annotations
54+
* .managedClasses(Item.class, Bid.class, User.class)
55+
* // set a configuration property
56+
* .setProperty(PersistenceConfiguration.JDBC_DATASOURCE,
57+
* "java:comp/env/jdbc/test")
58+
* .buildSessionFactory();
59+
* </pre>
60+
* <p>
61+
* When instantiated, an instance of
62+
* {@code HibernatePersistenceConfiguration} has its properties initially
63+
* populated from the {@linkplain Environment#getProperties() environment},
64+
* including:
65+
* <ul>
66+
* <li>JVM {@linkplain System#getProperties() system properties}, and
67+
* <li>properties specified in {@code hibernate.properties}.
68+
* </ul>
3469
*
3570
* @apiNote The specification explicitly encourages implementors to extend
3671
* {@link PersistenceConfiguration} to accommodate vendor-specific

0 commit comments

Comments
 (0)