@@ -932,6 +932,44 @@ hibernate.dialect = org.hibernate.dialect.PostgreSQL82Dialect</programlisting>
932
932
<entry ><para >At the moment, <literal >javassist</literal > is the only supported bytecode provider.</para ><para > <emphasis
933
933
role =" strong" >e.g.</emphasis > <literal >javassist</literal ></para ></entry >
934
934
</row >
935
+ <row >
936
+ <entry ><literal >hibernate.ejb.naming_strategy</literal ></entry >
937
+
938
+ <entry >
939
+ <para >Chooses the <interfacename >org.hibernate.cfg.NamingStrategy</interfacename > implementation
940
+ when using Hibernate Entity Manager. <interfacename >org.hibernate.cfg.NamingStrategy</interfacename >
941
+ is deprecated and this property is provided for backward-compatibity.
942
+ See <xref linkend =" configuration-namingstrategy" /> </para >
943
+
944
+ <para >This property should not be used at the same time as
945
+ <literal >hibernate.ejb.naming_strategy_delegator</literal ></para >
946
+ </entry >
947
+ </row >
948
+ <row >
949
+ <entry ><literal >hibernate.ejb.naming_strategy_delegator</literal ></entry >
950
+
951
+ <entry >
952
+ <para >Chooses the <interfacename >org.hibernate.cfg.naming.NamingStrategyDelegator</interfacename >
953
+ implementation when using Hibernate Entity Manager.
954
+ See <xref linkend =" configuration-namingstrategy" /> </para >
955
+
956
+ <para >Hibernate provides 2 implementations</para >:
957
+
958
+ <para ><classname >org.hibernate.cfg.naming.LegacyNamingStrategyDelegator</classname >:
959
+ This is the default value. This class is deprecated and is provided for backward compatibility.</para >
960
+
961
+ <para ><classname >org.hibernate.cfg.naming.ImprovedNamingStrategyDelegator</classname >:
962
+ This is the preferred value and generates default table and column names that comply with the
963
+ JPA specification.</para >
964
+
965
+ <para >A different class that implements
966
+ <interfacename >org.hibernate.cfg.naming.ImprovedNamingStrategyDelegator</interfacename >
967
+ may be specified.</para >
968
+
969
+ <para >This property should not be used at the same time as
970
+ <literal >hibernate.ejb.naming_strategy_delegator</literal >.</para >
971
+ </entry >
972
+ </row >
935
973
</tbody >
936
974
</tgroup >
937
975
</table >
@@ -1522,9 +1560,9 @@ hibernate.dialect = org.hibernate.dialect.PostgreSQL82Dialect</programlisting>
1522
1560
<section xml : id =" configuration-namingstrategy" revision =" 1" >
1523
1561
<title >Implementing a Naming Strategy</title >
1524
1562
1525
- <para >The interfaces, <interfacename >org.hibernate.cfg.NamingStrategy</interfacename >
1526
- and <interfacename >org.hibernate.cfg.naming.NamingStrategyDelegator</interfacename >,
1527
- allow you to specify a "naming standard" for database objects and schema
1563
+ <para ><interfacename >org.hibernate.cfg.NamingStrategy</interfacename >
1564
+ and <interfacename >org.hibernate.cfg.naming.NamingStrategyDelegator</interfacename >
1565
+ interfaces allow you to specify a "naming standard" for database objects and schema
1528
1566
elements.</para >
1529
1567
1530
1568
<para >You can provide rules for automatically generating database
@@ -1544,16 +1582,61 @@ hibernate.dialect = org.hibernate.dialect.PostgreSQL82Dialect</programlisting>
1544
1582
<interfacename >org.hibernate.cfg.NamingStrategy</interfacename > has
1545
1583
been deprecated.</para >
1546
1584
1547
- <para ><interfacename >org.hibernate.cfg.naming.NamingStrategyDelegator</interfacename >,
1548
- is a temporary replacement intended to provide more flexibility in a more-or-less
1549
- compatible way.</para >
1585
+ <important >
1586
+ <para ><interfacename >org.hibernate.cfg.naming.NamingStrategyDelegator</interfacename >
1587
+ is a temporary replacement for <interfacename >org.hibernate.cfg.NamingStrategy</interfacename >
1588
+ that addresses limitations and provides more flexibility
1589
+ in a more-or-less compatible way. A more comprehensive solution will be introduced in Hibernate 5.0
1590
+ that will replace both <interfacename >org.hibernate.cfg.NamingStrategy</interfacename > and
1591
+ <interfacename >org.hibernate.cfg.naming.NamingStrategyDelegator</interfacename >.</para >
1592
+ </important >
1593
+
1594
+ <para >For backward compatibility, the default
1595
+ <interfacename >org.hibernate.cfg.naming.NamingStrategyDelegator</interfacename >
1596
+ simply delegates table and column name generation to the default
1597
+ <interfacename >org.hibernate.cfg.NamingStrategy</interfacename >.
1598
+ This default <interfacename >org.hibernate.cfg.naming.NamingStrategyDelegator</interfacename >
1599
+ has also been deprecated and should be considered "legacy" code because it has the same
1600
+ limitations as <interfacename >org.hibernate.cfg.NamingStrategy</interfacename >.</para >
1601
+
1602
+ <para >Hibernate provides <classname >org.hibernate.cfg.naming.ImprovedNamingStrategyDelegator</classname >
1603
+ as an alternative that generates default table and column names that comply with the
1604
+ JPA specification when annotations or JPA XML descriptors are used to map an entity.
1605
+ Table and column names generated for entities mapped using Hibernate Core hbm.xml
1606
+ are unaffected. This implementation must be explicitly configured in order to override the
1607
+ the default.</para >
1608
+
1609
+ <note ><para >Hibernate allows an implementation of either
1610
+ <interfacename >org.hibernate.cfg.naming.NamingStrategyDelegator</interfacename > or
1611
+ <interfacename >org.hibernate.cfg.NamingStrategy</interfacename > to be configured.
1612
+ Both should not be configured at the same time.</para ></note >
1550
1613
1551
- <para >For backward compatibility, the default implementation,
1552
- <classname >org.hibernate.cfg.naming.LegacyNamingStrategyDelegator</classname >
1553
- delegates table and column name generation to an instance
1554
- of <classname >org.hibernate.cfg.EJB3NamingStrategy</classname >.
1555
- You can specify a different <interfacename >org.hibernate.cfg.NamingStrategy</interfacename >
1556
- by calling <literal >Configuration.setNamingStrategy()</literal > before adding mappings:</para >
1614
+ <para >To configure Hibernate Core to use <classname >org.hibernate.cfg.naming.ImprovedNamingStrategyDelegator</classname >,
1615
+ call <literal >Configuration.setNamingStrategyDelegator()</literal > before adding mappings:</para >
1616
+
1617
+ <programlisting role =" JAVA" >SessionFactory sf = new Configuration()
1618
+ .setNamingStrategyDelegator(ImprovedNamingStrategyDelegator.DEFAULT_INSTANCE)
1619
+ .addFile("Item.hbm.xml")
1620
+ .addFile("Bid.hbm.xml")
1621
+ .buildSessionFactory();</programlisting >
1622
+
1623
+ <para >You can configure a custom implementation of
1624
+ <interfacename >org.hibernate.cfg.naming.NamingStrategyDelegator</interfacename >
1625
+ by replacing <literal >ImprovedNamingStrategyDelegator.DEFAULT_INSTANCE</literal >
1626
+ with the implementation class name.</para >
1627
+
1628
+ <para >To configure Hibernate Entity Manager to use
1629
+ <classname >org.hibernate.cfg.naming.ImprovedNamingStrategyDelegator</classname > or a custom
1630
+ implementation, set the Hibernate configuration property <literal >hibernate.ejb.naming_strategy_delegator</literal >
1631
+ to the implementation class name</para >.
1632
+
1633
+ <para >When using the default (legacy) implementation of
1634
+ <interfacename >org.hibernate.cfg.naming.NamingStrategyDelegator</interfacename >, Hibernate
1635
+ allows you to delegate to a different <interfacename >org.hibernate.cfg.NamingStrategy</interfacename >.</para >
1636
+
1637
+ <para >To configure Hibernate Core to delegate to a different
1638
+ <interfacename >org.hibernate.cfg.NamingStrategy</interfacename >,
1639
+ call <literal >Configuration.setNamingStrategy()</literal > before adding mappings:</para >
1557
1640
1558
1641
<programlisting role =" JAVA" >SessionFactory sf = new Configuration()
1559
1642
.setNamingStrategy(ImprovedNamingStrategy.INSTANCE)
@@ -1565,25 +1648,10 @@ hibernate.dialect = org.hibernate.dialect.PostgreSQL82Dialect</programlisting>
1565
1648
built-in strategy that might be a useful starting point for some
1566
1649
applications.</para >
1567
1650
1568
- <para >Hibernate provides <classname >org.hibernate.cfg.naming.ImprovedNamingStrategyDelegator</classname >
1569
- as an alternative that generates default table and column names that comply with the
1570
- JPA specification when annotations or JPA XML descriptors are used to map an entity;
1571
- table and column names generated for entities mapped using Hibernate-specific hbm.xml
1572
- are unaffected. You can specify <interfacename >org.hibernate.cfg.naming.NamingStrategyDelegator</interfacename >
1573
- by calling <literal >Configuration.setNamingStrategyDelegator()</literal > before adding mappings:</para >
1574
-
1575
- <programlisting role =" JAVA" >SessionFactory sf = new Configuration()
1576
- .setNamingStrategyDelegator(ImprovedNamingStrategyDelegator.DEFAULT_INSTANCE)
1577
- .addFile("Item.hbm.xml")
1578
- .addFile("Bid.hbm.xml")
1579
- .buildSessionFactory();</programlisting >
1580
-
1581
- <note ><literal >Configuration.setNamingStrategy()</literal > and
1582
- <literal >setNamingStrategyDelegator()</literal > should not be used together.</note >
1583
-
1584
- <para >A more comprehensive solution will be introduced in 5.0 that will replace both
1585
- <interfacename >org.hibernate.cfg.NamingStrategy</interfacename > and
1586
- <interfacename >org.hibernate.cfg.naming.NamingStrategyDelegator</interfacename >.</para >
1651
+ <para >To configure Hibernate Entity Manager to delegate to a different
1652
+ <interfacename >org.hibernate.cfg.NamingStrategy</interfacename >,
1653
+ set the Hibernate configuration property <literal >hibernate.ejb.naming_strategy</literal >
1654
+ to the implementation class name.</para >
1587
1655
1588
1656
</section >
1589
1657
0 commit comments