javadoc about properties in Configuration

This commit is contained in:
Gavin King 2024-12-16 09:15:22 +01:00
parent af679e1d96
commit edb3c335b2
2 changed files with 19 additions and 6 deletions

View File

@ -74,15 +74,28 @@ import jakarta.persistence.SharedCacheMode;
* <li>{@linkplain #setProperty(String, String) configuration properties} * <li>{@linkplain #setProperty(String, String) configuration properties}
* from various sources, and * from various sources, and
* <li>entity O/R mappings, defined in either {@linkplain #addAnnotatedClass * <li>entity O/R mappings, defined in either {@linkplain #addAnnotatedClass
* annotated classes}, or {@linkplain #addFile XML mapping documents}. * annotated classes}, or {@linkplain #addFile XML mapping documents}.
* </ul> * </ul>
* <p> * <p>
* Note that XML mappings may be expressed using the JPA {@code orm.xml} * Note that XML mappings may be expressed using the JPA {@code orm.xml}
* format, or in Hibernate's legacy {@code .hbm.xml} format. * format, or in Hibernate's legacy {@code .hbm.xml} format.
* <p> * <p>
* Configuration properties are enumerated by {@link AvailableSettings}. * Configuration properties are enumerated by {@link AvailableSettings}.
* <p>
* When instantiated, an instance of {@code Configuration} has its properties
* initially populated from the {@linkplain Environment#getProperties()
* environment}, including:
* <ul>
* <li>JVM {@linkplain System#getProperties() system properties}, and
* <li>properties specified in {@code hibernate.properties}.
* </ul>
* <p>
* These initial properties may be completely discarded by calling
* {@link #setProperties(Properties)}, or they may be overridden
* individually by calling {@link #setProperty(String, String)}.
* <p>
* <pre> * <pre>
* SessionFactory factory = new Configuration() * SessionFactory factory = new Configuration()
* // scan classes for mapping annotations * // scan classes for mapping annotations
* .addAnnotatedClass(Item.class) * .addAnnotatedClass(Item.class)
* .addAnnotatedClass(Bid.class) * .addAnnotatedClass(Bid.class)

View File

@ -163,7 +163,7 @@ public final class Environment implements AvailableSettings {
} }
try { try {
Properties systemProperties = System.getProperties(); final Properties systemProperties = System.getProperties();
// Must be thread-safe in case an application changes System properties during Hibernate initialization. // Must be thread-safe in case an application changes System properties during Hibernate initialization.
// See HHH-8383. // See HHH-8383.
synchronized (systemProperties) { synchronized (systemProperties) {
@ -183,11 +183,11 @@ public final class Environment implements AvailableSettings {
} }
/** /**
* The {@link System#getProperties() system properties}, extended with all * The {@linkplain System#getProperties() system properties}, extended
* additional properties specified in {@code hibernate.properties}. * with all additional properties specified in {@code hibernate.properties}.
*/ */
public static Properties getProperties() { public static Properties getProperties() {
Properties copy = new Properties(); final Properties copy = new Properties();
copy.putAll(GLOBAL_PROPERTIES); copy.putAll(GLOBAL_PROPERTIES);
return copy; return copy;
} }