Hibernate SVN: r14190 - in branches/Branch_3_2/HibernateExt/tools/doc/reference/en: images and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-11-08 12:13:00 -0500 (Thu, 08 Nov 2007)
New Revision: 14190
Added:
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegenexporters.png
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegenmaintab.png
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgwizard.png
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consoleoutline-before-reveng.png
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/entitymodel.png
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/hibernatecfgwizard.png
Removed:
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegenexporters.gif
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegenmaintab.gif
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegenselectseam.gif
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgwizard.gif
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consoleoutline-before-reveng.gif
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/dynamictranslation.png
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/entitymodel.gif
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/hbmxmlcompletion.gif
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/hibernate_logo_a.gif
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/hibernatecfgwizard.jpg
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/queryconsole.gif
Modified:
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgclasspath.png
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgmappings.png
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/dynamicquerytranslation.png
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/queryconsole.png
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/master.xml
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/ant.xml
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/plugins.xml
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/setup.xml
Log:
update CR1 docs
Deleted: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegenexporters.gif
===================================================================
(Binary files differ)
Added: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegenexporters.png
===================================================================
(Binary files differ)
Property changes on: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegenexporters.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegenmaintab.gif
===================================================================
(Binary files differ)
Added: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegenmaintab.png
===================================================================
(Binary files differ)
Property changes on: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegenmaintab.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegenselectseam.gif
===================================================================
(Binary files differ)
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgclasspath.png
===================================================================
(Binary files differ)
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgmappings.png
===================================================================
(Binary files differ)
Deleted: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgwizard.gif
===================================================================
(Binary files differ)
Added: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgwizard.png
===================================================================
(Binary files differ)
Property changes on: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgwizard.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consoleoutline-before-reveng.gif
===================================================================
(Binary files differ)
Added: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consoleoutline-before-reveng.png
===================================================================
(Binary files differ)
Property changes on: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consoleoutline-before-reveng.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/dynamicquerytranslation.png
===================================================================
(Binary files differ)
Deleted: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/dynamictranslation.png
===================================================================
(Binary files differ)
Deleted: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/entitymodel.gif
===================================================================
(Binary files differ)
Added: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/entitymodel.png
===================================================================
(Binary files differ)
Property changes on: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/entitymodel.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/hbmxmlcompletion.gif
===================================================================
(Binary files differ)
Deleted: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/hibernate_logo_a.gif
===================================================================
(Binary files differ)
Deleted: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/hibernatecfgwizard.jpg
===================================================================
(Binary files differ)
Added: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/hibernatecfgwizard.png
===================================================================
(Binary files differ)
Property changes on: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/hibernatecfgwizard.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/queryconsole.gif
===================================================================
(Binary files differ)
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/queryconsole.png
===================================================================
(Binary files differ)
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/master.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/doc/reference/en/master.xml 2007-11-06 02:09:45 UTC (rev 14189)
+++ branches/Branch_3_2/HibernateExt/tools/doc/reference/en/master.xml 2007-11-08 17:13:00 UTC (rev 14190)
@@ -14,7 +14,7 @@
<subtitle>Reference Guide</subtitle>
- <releaseinfo>3.2.0.beta10</releaseinfo>
+ <releaseinfo>3.2.0.CR1</releaseinfo>
<mediaobject>
<imageobject>
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/ant.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/ant.xml 2007-11-06 02:09:45 UTC (rev 14189)
+++ branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/ant.xml 2007-11-08 17:13:00 UTC (rev 14190)
@@ -14,8 +14,7 @@
used independently of eclipse.</para>
<para>
- Note: until Hibernate 3.2 and related libraries are finally
- released there might be incompabilities with respect to the tools.
+ Note: There might be incompabilities with respect to the Hibernate3.jar bundled with the tools and your own jar.
Thus to avoid any confusion it is recommended to use the
hibernate3.jar & hibernate-annotations.jar bundled with the
tools when you want to use the Ant tasks. Do not worry about using
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/plugins.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/plugins.xml 2007-11-06 02:09:45 UTC (rev 14189)
+++ branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/plugins.xml 2007-11-08 17:13:00 UTC (rev 14190)
@@ -58,14 +58,14 @@
<mediaobject>
<imageobject role="fo">
- <imagedata contentwidth="5cm" fileref="images/hibernatecfgwizard.gif"
- format="GIF" />
+ <imagedata contentwidth="5cm" fileref="images/hibernatecfgwizard.png"
+ format="PNG" />
</imageobject>
<imageobject role="html">
<imagedata align="center"
- fileref="../shared/images/hibernatecfgwizard.gif"
- format="GIF" />
+ fileref="../shared/images/hibernatecfgwizard.png"
+ format="PNG" />
</imageobject>
</mediaobject>
@@ -109,13 +109,13 @@
<mediaobject>
<imageobject role="fo">
- <imagedata fileref="images/consolecfgwizard.gif" format="GIF" />
+ <imagedata fileref="images/consolecfgwizard.png" format="PNG" />
</imageobject>
<imageobject role="html">
<imagedata align="center"
- fileref="../shared/images/consolecfgwizard.gif"
- format="GIF" />
+ fileref="../shared/images/consolecfgwizard.png"
+ format="PNG" />
</imageobject>
<caption>Creating a Hibernate Console configuration</caption>
@@ -232,14 +232,14 @@
<mediaobject>
<imageobject role="fo">
- <imagedata align="center" fileref="images/consolecfgclasspath.gif"
- format="GIF" />
+ <imagedata align="center" fileref="images/consolecfgclasspath.png"
+ format="PNG" />
</imageobject>
<imageobject role="html">
<imagedata align="center"
- fileref="../shared/images/consolecfgclasspath.gif"
- format="GIF" />
+ fileref="../shared/images/consolecfgclasspath.png"
+ format="PNG" />
</imageobject>
<caption>Specifying classpath in a Hibernate Console
@@ -295,14 +295,14 @@
<para><mediaobject>
<imageobject role="fo">
- <imagedata align="center" fileref="images/consolecfgmappings.gif"
- format="GIF" />
+ <imagedata align="center" fileref="images/consolecfgmappings.png"
+ format="PNG" />
</imageobject>
<imageobject role="html">
<imagedata align="center"
- fileref="../shared/images/consolecfgmappings.gif"
- format="GIF" />
+ fileref="../shared/images/consolecfgmappings.png"
+ format="PNG" />
</imageobject>
<caption>Specifying additional mappings in a Hibernate console
@@ -349,14 +349,14 @@
<mediaobject>
<imageobject role="fo">
<imagedata align="center"
- fileref="images/consoleoutline-before-reveng.gif"
- format="GIF" />
+ fileref="images/consoleoutline-before-reveng.png"
+ format="PNG" />
</imageobject>
<imageobject role="html">
<imagedata align="center"
- fileref="../shared/images/consoleoutline-before-reveng.gif"
- format="GIF" />
+ fileref="../shared/images/consoleoutline-before-reveng.png"
+ format="PNG" />
</imageobject>
<caption>Console overview</caption>
@@ -400,13 +400,13 @@
<mediaobject>
<imageobject role="fo">
- <imagedata fileref="images/codegenmaintab.gif" format="GIF" />
+ <imagedata fileref="images/codegenmaintab.png" format="PNG" />
</imageobject>
<imageobject role="html">
<imagedata align="center"
- fileref="../shared/images/codegenmaintab.gif"
- format="GIF" />
+ fileref="../shared/images/codegenmaintab.png"
+ format="PNG" />
</imageobject>
</mediaobject>
@@ -561,18 +561,18 @@
<mediaobject>
<imageobject role="fo">
- <imagedata fileref="images/codegenexporters.gif" format="GIF" />
+ <imagedata fileref="images/codegenexporters.png" format="PNG" />
</imageobject>
<imageobject role="html">
<imagedata align="center"
- fileref="../shared/images/codegenexporters.gif"
- format="GIF" />
+ fileref="../shared/images/codegenexporters.png"
+ format="PNG" />
</imageobject>
</mediaobject>
<para>The following table describes in short the various
- exporters.</para>
+ exporters. Remember you can Add and Remove any exporters depending on your needs.</para>
<table>
<title>Code generation "Exporter" tab fields</title>
@@ -628,6 +628,12 @@
database schema and some of the mappings.</para></entry>
</row>
+ <row>
+ <entry><para>Generic Exporter (hbmtemplate)</para></entry>
+
+ <entry><para>Fully customizable exporter which can be used to perform custom generation.</para></entry>
+ </row>
+
</tbody>
</tgroup>
</table>
@@ -666,7 +672,39 @@
<entry><para>Generate EJB 3 annotations</para></entry>
</row>
+ <row>
+ <entry><para>for_each</para></entry>
+
+ <entry><para>Specifies which type of model elements the exporter should create a file and run through the templates. Possible values are: entity, component, configuration</para></entry>
+ </row>
+
<row>
+ <entry><para>template_path</para></entry>
+
+ <entry><para>Custom template directory for this specific exporter. You can use Eclipse variables.</para></entry>
+ </row>
+
+ <row>
+ <entry><para>template_name</para></entry>
+
+ <entry><para>Name for template relative to the template path</para></entry>
+ </row>
+
+ <row>
+ <entry><para>outputdir</para></entry>
+
+ <entry><para>Custom output directory for this specific exporter. You can use Eclipse variables.</para></entry>
+ </row>
+
+ <row>
+ <entry><para>file_pattern</para></entry>
+
+ <entry><para>Pattern to use for the generated files, relatively for the output dir. Example: {package-name}/{class-name}.java</para></entry>
+ </row>
+
+
+
+ <row>
<entry><para>dot.executable</para></entry>
<entry><para>executable to run GraphViz (only relevant, but
@@ -909,40 +947,35 @@
</mediaobject> Hibernate Console perspective showing entity structure,
query editor and result</para>
+ <para>The console configuration does not dynamically adjust to changes done in mappings and java code; to reload the configuration select the configuration and click the 'Reload' button in the view toolbar or in the context menu.</para>
<section>
- <title>Class Diagram</title>
+ <title>Mapping Diagram</title>
- <para>A class diagram is available in the view named "Hibernate Entity
- Model". It will show the model when the Configuration node in a
- Hibernate Console Configuration is selected.</para>
+ <para>A mapping diagram for entities are available by right clicking on the entity you want an mapping diagram for and then choose "Open Mapping Diagram"</para>
<mediaobject>
<imageobject role="fo">
- <imagedata fileref="images/entitymodel.gif" />
+ <imagedata fileref="images/entitymodel.png" />
</imageobject>
<imageobject role="html">
<imagedata align="center"
- fileref="../shared/images/entitymodel.gif" />
+ fileref="../shared/images/entitymodel.png" />
</imageobject>
</mediaobject>
- <para>This view supports zoom in/out and can also be printed. Zooming
- is done via the toolbar buttons in the view and printing is done by
- selecting the view and choose File/Print or use the Print Icon.</para>
</section>
</section>
<section>
<title>Prototyping Queries</title>
- <para>Queries can be prototyped by entering them in the HQL editor. The
- HQL Editor is opened by right-clicking the Console configuration and
- select "HQL Scratchpad".</para>
-
+ <para>Queries can be prototyped by entering them in the HQL or Criteria editor. The
+ query editors are opened by right-clicking the Console configuration and
+ selecting either "HQL Editor" or "Criteria Editor".</para>
+
<para>If the menu item is disabled then you need to first create an
- SessionFactory. That is done by right clicking the configuration and
- select "Create Session Factory" or by simpy expanding the Session
+ SessionFactory. That is done by simply expanding the Session
Factory node.</para>
<para>Executing the query is done by clicking the green run button in
@@ -958,10 +991,9 @@
details of possible errors (syntax errors, database errors, etc.) can be
seen in the Error Log view.</para>
- <para>Tip: HQL queries are executed using <literal>list()</literal> and
- without any limit of the size of the output. Be careful if you execute a
- query on a large result set. You might run out of memory. This will be
- improved in a future version.</para>
+ <para>Tip: HQL queries are executed by default using <literal>list()</literal> thus
+ without any limit of the size of the output the query could return a large result set.
+ You might run out of memory. To avoid this you can put a value in the Max results field to reduce the number of elements returned.</para>
<section>
<title>Dynamic Query Translator</title>
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/setup.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/setup.xml 2007-11-06 02:09:45 UTC (rev 14189)
+++ branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/setup.xml 2007-11-08 17:13:00 UTC (rev 14190)
@@ -3,15 +3,15 @@
<title>Download and install Hibernate Tools</title>
<para>Hibernate tools can be used "standalone" via Ant 1.6.x or fully
- integrated into a Eclipse 3.2.x based IDE, such as JBoss Eclipse IDE or a
- default Eclipse 3.2.x installation. The following describes the install
+ integrated into a Eclipse 3.3.x + WTP 2.x based IDE, such as JBoss Tools or an
+ default Eclipse 3.3.x + WTP 2.x installation. The following describes the install
steps in these environments.</para>
<section>
- <title>JBoss Eclipse IDE</title>
+ <title>JBoss Tools</title>
- <para>JBoss Eclipse IDE 2.x includes Hibernate Tools and thus nothing is
- required besides downloading and installing JBoss Eclipse IDE. If you need
+ <para>JBoss Tools 2.x includes Hibernate Tools and thus nothing is
+ required besides downloading and installing JBoss Tools. If you need
to update to a newer version of the Hibernate Tools just follow the
instructions in the Eclipse IDE section.</para>
</section>
@@ -19,9 +19,9 @@
<section>
<title>Eclipse IDE</title>
- <para>To install into any Eclipse 3.2.x based Eclipse IDE you can either
+ <para>To install into any Eclipse 3.3.x based Eclipse IDE you can either
download the Hibernate Tools distribution from the Hibernate website or
- use the JBoss IDE Eclipse update site (see http://tools.hibernate.org for
+ use the JBoss Tools update site (see http://tools.hibernate.org for
links to the update site).</para>
<para>If you download the Hibernate Tools distribution you need to place
@@ -41,7 +41,7 @@
<section>
<title>Usage of Eclipse WTP</title>
- <para>The Hibernate tools plugins currently uses WTP 1.5.x which at this
+ <para>The Hibernate tools plugins currently uses WTP 2.x which at this
time is the latest stable release from the Eclipse Webtools
project.</para>
@@ -51,11 +51,8 @@
has either the same version number or higher. It is thus recommended
that if you have issues with WTP provided features to try and install
the plugins on a clean install of eclipse to ensure there are no
- version-collisions.</para>
-
- <para>The tools only include a subset of the WTP 1.5.x plugins, thus if
- you want full access to the WTP functionallity the full WTP 1.5.x SDK should
- be able to instal on top of the plugins without any problems.</para>
+ version collisions.</para>
+
</section>
</section>
17 years
Hibernate SVN: r14189 - in core: trunk/core/src/main/java/org/hibernate/dialect and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: d.plentz
Date: 2007-11-05 21:09:45 -0500 (Mon, 05 Nov 2007)
New Revision: 14189
Modified:
core/branches/Branch_3_2/src/org/hibernate/dialect/Oracle8iDialect.java
core/branches/Branch_3_2/src/org/hibernate/dialect/Oracle9Dialect.java
core/trunk/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java
core/trunk/core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java
Log:
[HHH-2016] Oracle9Dialect registers last_day() function as "lastday"
Modified: core/branches/Branch_3_2/src/org/hibernate/dialect/Oracle8iDialect.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/dialect/Oracle8iDialect.java 2007-11-04 15:40:50 UTC (rev 14188)
+++ core/branches/Branch_3_2/src/org/hibernate/dialect/Oracle8iDialect.java 2007-11-06 02:09:45 UTC (rev 14189)
@@ -121,7 +121,7 @@
registerFunction( "current_time", new NoArgSQLFunction("current_timestamp", Hibernate.TIME, false) );
registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) );
- registerFunction( "lastday", new StandardSQLFunction("lastday", Hibernate.DATE) );
+ registerFunction( "last_day", new StandardSQLFunction("last_day", Hibernate.DATE) );
registerFunction( "sysdate", new NoArgSQLFunction("sysdate", Hibernate.DATE, false) );
registerFunction( "systimestamp", new NoArgSQLFunction("systimestamp", Hibernate.TIMESTAMP, false) );
registerFunction( "uid", new NoArgSQLFunction("uid", Hibernate.INTEGER, false) );
Modified: core/branches/Branch_3_2/src/org/hibernate/dialect/Oracle9Dialect.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/dialect/Oracle9Dialect.java 2007-11-04 15:40:50 UTC (rev 14188)
+++ core/branches/Branch_3_2/src/org/hibernate/dialect/Oracle9Dialect.java 2007-11-06 02:09:45 UTC (rev 14189)
@@ -103,7 +103,7 @@
registerFunction( "current_time", new NoArgSQLFunction("current_timestamp", Hibernate.TIME, false) );
registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) );
- registerFunction( "lastday", new StandardSQLFunction("lastday", Hibernate.DATE) );
+ registerFunction( "last_day", new StandardSQLFunction("last_day", Hibernate.DATE) );
registerFunction( "sysdate", new NoArgSQLFunction("sysdate", Hibernate.DATE, false) );
registerFunction( "systimestamp", new NoArgSQLFunction("systimestamp", Hibernate.TIMESTAMP, false) );
registerFunction( "uid", new NoArgSQLFunction("uid", Hibernate.INTEGER, false) );
Modified: core/trunk/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java 2007-11-04 15:40:50 UTC (rev 14188)
+++ core/trunk/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java 2007-11-06 02:09:45 UTC (rev 14189)
@@ -121,7 +121,7 @@
registerFunction( "current_time", new NoArgSQLFunction("current_timestamp", Hibernate.TIME, false) );
registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) );
- registerFunction( "lastday", new StandardSQLFunction("lastday", Hibernate.DATE) );
+ registerFunction( "last_day", new StandardSQLFunction("last_day", Hibernate.DATE) );
registerFunction( "sysdate", new NoArgSQLFunction("sysdate", Hibernate.DATE, false) );
registerFunction( "systimestamp", new NoArgSQLFunction("systimestamp", Hibernate.TIMESTAMP, false) );
registerFunction( "uid", new NoArgSQLFunction("uid", Hibernate.INTEGER, false) );
Modified: core/trunk/core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java 2007-11-04 15:40:50 UTC (rev 14188)
+++ core/trunk/core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java 2007-11-06 02:09:45 UTC (rev 14189)
@@ -103,7 +103,7 @@
registerFunction( "current_time", new NoArgSQLFunction("current_timestamp", Hibernate.TIME, false) );
registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) );
- registerFunction( "lastday", new StandardSQLFunction("lastday", Hibernate.DATE) );
+ registerFunction( "last_day", new StandardSQLFunction("last_day", Hibernate.DATE) );
registerFunction( "sysdate", new NoArgSQLFunction("sysdate", Hibernate.DATE, false) );
registerFunction( "systimestamp", new NoArgSQLFunction("systimestamp", Hibernate.TIMESTAMP, false) );
registerFunction( "uid", new NoArgSQLFunction("uid", Hibernate.INTEGER, false) );
17 years
Hibernate SVN: r14188 - in branches/Branch_3_2/HibernateExt/tools/src: java/org/hibernate/cfg/reveng and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-11-04 10:40:50 -0500 (Sun, 04 Nov 2007)
New Revision: 14188
Added:
branches/Branch_3_2/HibernateExt/tools/src/test5.0/org/hibernate/tool/test/jdbc2cfg/CompositeIdJPATest.java
branches/Branch_3_2/HibernateExt/tools/src/test5.0/org/hibernate/tool/test/jdbc2cfg/ManyToManyJDK50Test.java
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCBinder.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCMetaDataConfiguration.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCReader.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/BaseTestCase.java
Log:
HBX-755 incorrect genreated code for many-to-many relationship
+ referencecolumns for existing foreignkeys are now also collected (before just user provided fk's had that)
HBX-846 Needed a method that finds Table by TableIdentifier (via runtimeInfo.getTable())
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCBinder.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCBinder.java 2007-11-04 08:54:31 UTC (rev 14187)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCBinder.java 2007-11-04 15:40:50 UTC (rev 14188)
@@ -303,6 +303,7 @@
}
SimpleValue keyValue = new DependantValue( collectionTable, referencedKeyValue );
+ //keyValue.setForeignKeyName("none"); // Avoid creating the foreignkey
//key.setCascadeDeleteEnabled( "cascade".equals( subnode.attributeValue("on-delete") ) );
Iterator columnIterator = foreignKey.getColumnIterator();
while ( columnIterator.hasNext() ) {
@@ -932,6 +933,22 @@
public void secondPass(Map persistentClasses, Map inheritedMetas) throws MappingException {
JDBCBinder.bindCollectionSecondPass(collection, persistentClasses, mappings, inheritedMetas);
}
+
+ public void doSecondPass(Map persistentClasses) throws MappingException {
+ Value element = collection.getElement();
+ DependantValue dep = null;
+ String oldFkName = null;
+ if(element instanceof DependantValue) {
+ dep = (DependantValue)element;
+ oldFkName = dep.getForeignKeyName();
+ dep.setForeignKeyName("none"); // Workaround to avoid DependantValue to create foreignkey just because reference columns are not the same + no need to create keys already in the db!
+ }
+ super.doSecondPass(persistentClasses);
+ if(dep!=null) {
+ dep.setForeignKeyName(oldFkName);
+ }
+
+ }
}
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCMetaDataConfiguration.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCMetaDataConfiguration.java 2007-11-04 08:54:31 UTC (rev 14187)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/JDBCMetaDataConfiguration.java 2007-11-04 15:40:50 UTC (rev 14188)
@@ -30,10 +30,12 @@
protected void secondPassCompileForeignKeys(Table table, Set done)
throws MappingException {
- //super.secondPassCompileForeignKeys(table, done);
+ super.secondPassCompileForeignKeys(table, done);
// TODO: doing nothing to avoid creating foreignkeys which is NOT actually in the database.
}
+
+
public void readFromJDBC() {
JDBCBinder binder = new JDBCBinder(this, buildSettings(), createMappings(),revEngStrategy);
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java 2007-11-04 08:54:31 UTC (rev 14187)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java 2007-11-04 15:40:50 UTC (rev 14188)
@@ -164,7 +164,7 @@
}
public void close() {
- runtimeInfo = null;
+
}
@@ -203,6 +203,21 @@
}
public boolean isForeignKeyCollectionInverse(String name, TableIdentifier foreignKeyTable, List columns, TableIdentifier foreignKeyReferencedTable, List referencedColumns) {
+ Table fkTable = getRuntimeInfo().getTable(foreignKeyTable);
+ if(fkTable==null) {
+ return true; // we don't know better
+ }
+
+ if(isManyToManyTable(fkTable)) {
+ // if the reference column is the first one then we are inverse.
+ Column column = fkTable.getColumn(0);
+ Column fkColumn = (Column) referencedColumns.get(0);
+ if(fkColumn.equals(column)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
return true;
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCReader.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCReader.java 2007-11-04 08:54:31 UTC (rev 14187)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCReader.java 2007-11-04 15:40:50 UTC (rev 14188)
@@ -190,7 +190,7 @@
String fkSchema = getSchemaForModel((String) exportedKeyRs.get("FKTABLE_SCHEM"));
String fkTableName = (String) exportedKeyRs.get("FKTABLE_NAME");
String fkColumnName = (String) exportedKeyRs.get("FKCOLUMN_NAME");
- //String pkColumnName = (String) exportedKeyRs.get("PKCOLUMN_NAME");
+ String pkColumnName = (String) exportedKeyRs.get("PKCOLUMN_NAME");
String fkName = (String) exportedKeyRs.get("FK_NAME");
short keySeq = ((Short)exportedKeyRs.get("KEY_SEQ")).shortValue();
@@ -235,6 +235,19 @@
column = existingColumn==null ? column : existingColumn;
depColumns.add(column);
+
+ List primColumns = (List) referencedColumns.get(fkName);
+ if (primColumns == null) {
+ primColumns = new ArrayList();
+ referencedColumns.put(fkName,primColumns);
+ }
+
+ Column refColumn = new Column(pkColumnName);
+ existingColumn = referencedTable.getColumn(refColumn);
+ refColumn = existingColumn==null?refColumn:existingColumn;
+
+ primColumns.add(refColumn);
+
}
}
finally {
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/BaseTestCase.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/BaseTestCase.java 2007-11-04 08:54:31 UTC (rev 14187)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/BaseTestCase.java 2007-11-04 15:40:50 UTC (rev 14188)
@@ -30,7 +30,7 @@
public abstract class BaseTestCase extends TestCase {
- protected static abstract class ExecuteContext {
+ public static abstract class ExecuteContext {
private final File sourceDir;
private final File outputDir;
Added: branches/Branch_3_2/HibernateExt/tools/src/test5.0/org/hibernate/tool/test/jdbc2cfg/CompositeIdJPATest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test5.0/org/hibernate/tool/test/jdbc2cfg/CompositeIdJPATest.java (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test5.0/org/hibernate/tool/test/jdbc2cfg/CompositeIdJPATest.java 2007-11-04 15:40:50 UTC (rev 14188)
@@ -0,0 +1,154 @@
+/*
+ * Created on 13-Jan-2005
+ *
+ */
+package org.hibernate.tool.test.jdbc2cfg;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.cfg.JDBCMetaDataConfiguration;
+import org.hibernate.mapping.ForeignKey;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.Table;
+import org.hibernate.tool.JDBCMetaDataBinderTestCase;
+import org.hibernate.tool.hbm2x.Cfg2JavaTool;
+import org.hibernate.tool.hbm2x.POJOExporter;
+import org.hibernate.tool.hbm2x.pojo.EntityPOJOClass;
+
+/**
+ * @author max
+ *
+ */
+public class CompositeIdJPATest extends JDBCMetaDataBinderTestCase {
+
+
+ protected void configure(JDBCMetaDataConfiguration configuration) {
+ super.configure( configuration );
+ }
+ protected String[] getCreateSQL() {
+
+ return new String[] {
+ "CREATE TABLE Person ( id identity, name varchar(100) NOT NULL, address varchar(255), city varchar(20) default NULL, PRIMARY KEY (id))"
+ ,
+ "create table modelyear ( make varchar(20), model varchar(30), year int, name varchar(30), primary key (make, model, year))",
+ "CREATE TABLE Vehicle ( " +
+ " state varchar(2) NOT NULL, " +
+ " registration varchar(8) NOT NULL, " +
+ " v_make varchar(20) , " +
+ " v_model varchar(30) , " +
+ " v_year int , " +
+ " owner int , " +
+ " PRIMARY KEY (registration), " +
+ //" KEY (make,model,year), " +
+ //" KEY (owner), " +
+ " constraint vehicle_owner FOREIGN KEY (owner) REFERENCES person (id), " +
+ " constraint vehicle_modelyear FOREIGN KEY (v_make, v_model, v_year) REFERENCES modelyear (make, model, year) " +
+ " )" ,
+ };
+ }
+
+ protected String[] getDropSQL() {
+ return new String[] {
+ "drop table Vehicle",
+ "drop table modelyear",
+ "drop table Person",
+
+
+ };
+ }
+
+ public void testMultiColumnForeignKeys() {
+
+ Table vehicleTable = getTable(identifier("Vehicle"));
+
+ Iterator foreignKeyIterator = vehicleTable.getForeignKeyIterator();
+ assertHasNext(2, foreignKeyIterator);
+
+ ForeignKey foreignKey = getForeignKey(vehicleTable, identifier("vehicle_owner"));
+ assertEquals(foreignKey.getColumnSpan(), 1);
+
+ foreignKey = getForeignKey(vehicleTable, identifier("vehicle_modelyear"));
+ assertEquals(foreignKey.getColumnSpan(), 3);
+
+ PersistentClass vehicle = getConfiguration().getClassMapping("Vehicle");
+ EntityPOJOClass vechiclePojo = new EntityPOJOClass(vehicle, new Cfg2JavaTool());
+ assertNotNull(vechiclePojo.getDecoratedObject());
+
+ Property property = vehicle.getProperty("modelyear");
+ assertNotNull(property);
+ String generateJoinColumnsAnnotation = vechiclePojo.generateJoinColumnsAnnotation(property, cfg);
+ assertTrue(generateJoinColumnsAnnotation.indexOf("referencedColumnName=\"MAKE\"")>0);
+
+
+ }
+
+ public void testJPAGeneration() throws Exception {
+ getConfiguration().buildMappings();
+ POJOExporter exporter = new POJOExporter(getConfiguration(), getOutputDir());
+ Properties p = new Properties();
+ p.setProperty("jdk5", "true");
+ p.setProperty("ejb3", "true");
+
+ exporter.setProperties(p);
+ exporter.start();
+
+ File file = new File( "ejb3compilable" );
+ file.mkdir();
+
+ ArrayList list = new ArrayList();
+ List jars = new ArrayList();
+ addAnnotationJars(jars);
+
+ new ExecuteContext(getOutputDir(), file, jars) {
+
+ protected void execute() throws Exception {
+ AnnotationConfiguration configuration = new AnnotationConfiguration();
+ configuration.addAnnotatedClass( getUcl().loadClass( "Vehicle" ) );
+ configuration.addAnnotatedClass( getUcl().loadClass( "Person" ) );
+ configuration.addAnnotatedClass( getUcl().loadClass( "Modelyear" ) );
+
+ SessionFactory sf = configuration.buildSessionFactory();
+ Session s = sf.openSession();
+ Query createQuery = s.createQuery("from java.lang.Object");
+ createQuery.list();
+ s.close();
+ sf.close();
+
+ }
+
+ }.run();
+ }
+
+ private void addAnnotationJars(List jars) {
+ jars.add( "ejb3-persistence.jar" );
+ jars.add( "hibernate-annotations.jar" );
+ jars.add( "hibernate-commons-annotations.jar" );
+ jars.add( "hibernate3.jar" );
+ jars.add( "dom4j-1.6.1.jar" );
+ jars.add( "commons-logging-1.0.4.jar" );
+
+ }
+
+
+ protected void tearDown() throws Exception {
+ // TODO Auto-generated method stub
+ super.tearDown();
+ }
+ public static Test suite() {
+ return new TestSuite(CompositeIdJPATest.class);
+ }
+}
+
+
Added: branches/Branch_3_2/HibernateExt/tools/src/test5.0/org/hibernate/tool/test/jdbc2cfg/ManyToManyJDK50Test.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test5.0/org/hibernate/tool/test/jdbc2cfg/ManyToManyJDK50Test.java (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test5.0/org/hibernate/tool/test/jdbc2cfg/ManyToManyJDK50Test.java 2007-11-04 15:40:50 UTC (rev 14188)
@@ -0,0 +1,202 @@
+/*
+ * Created on 2004-12-01
+ *
+ */
+package org.hibernate.tool.test.jdbc2cfg;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.MappingException;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.cfg.JDBCMetaDataConfiguration;
+import org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy;
+import org.hibernate.cfg.reveng.ReverseEngineeringSettings;
+import org.hibernate.mapping.Collection;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Property;
+import org.hibernate.tool.JDBCMetaDataBinderTestCase;
+import org.hibernate.tool.hbm2x.HibernateMappingExporter;
+import org.hibernate.tool.hbm2x.POJOExporter;
+
+/**
+ * @author max
+ *
+ */
+public class ManyToManyJDK50Test extends JDBCMetaDataBinderTestCase {
+
+ public static Test suite() {
+ return new TestSuite(ManyToManyJDK50Test.class);
+ }
+
+ private JDBCMetaDataConfiguration localCfg;
+
+ protected void configure(JDBCMetaDataConfiguration configuration) {
+ super.configure( configuration );
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ localCfg = new JDBCMetaDataConfiguration();
+
+ DefaultReverseEngineeringStrategy c = new DefaultReverseEngineeringStrategy();
+ c.setSettings(new ReverseEngineeringSettings(c).setDetectManyToMany(false));
+ localCfg.setReverseEngineeringStrategy(c);
+ localCfg.readFromJDBC();
+ }
+ protected void tearDown() throws Exception {
+ localCfg = null;
+
+ super.tearDown();
+ }
+
+ public void testNoManyToManyBiDirectional() {
+
+ PersistentClass project = localCfg.getClassMapping("Project");
+
+ assertNotNull(project.getProperty("worksOns"));
+ //assertNotNull(project.getProperty("employee"));
+ assertEquals(3, project.getPropertyClosureSpan());
+ assertEquals("projectId", project.getIdentifierProperty().getName());
+
+ PersistentClass employee = localCfg.getClassMapping("Employee");
+
+ assertNotNull(employee.getProperty("worksOns"));
+ assertNotNull(employee.getProperty("employees"));
+ assertNotNull(employee.getProperty("employee"));
+ //assertNotNull(employee.getProperty("projects"));
+ assertEquals(6, employee.getPropertyClosureSpan());
+ assertEquals("id", employee.getIdentifierProperty().getName());
+
+ PersistentClass worksOn = localCfg.getClassMapping("WorksOn");
+
+ assertNotNull(worksOn.getProperty("project"));
+ assertNotNull(worksOn.getProperty("employee"));
+ assertEquals(2, worksOn.getPropertyClosureSpan());
+ assertEquals("id", worksOn.getIdentifierProperty().getName());
+ }
+
+ public void testAutoCreation() {
+
+ assertNull("No middle class should be generated.", cfg.getClassMapping( "WorksOn" ));
+
+ assertNotNull("Should create worksontext since one of the foreign keys is not part of pk", cfg.getClassMapping( "WorksOnContext" ));
+
+ PersistentClass projectClass = cfg.getClassMapping("Project");
+ assertNotNull( projectClass );
+
+ PersistentClass employeeClass = cfg.getClassMapping("Employee");
+ assertNotNull( employeeClass );
+
+ assertPropertyNotExist( projectClass, "worksOns" );
+ assertPropertyNotExist( employeeClass, "worksOns" );
+
+ Property property = employeeClass.getProperty( "projects" );
+ assertNotNull( property);
+ Property property2 = projectClass.getProperty( "employees" );
+ assertNotNull( property2);
+
+ assertTrue(((Collection)property.getValue()).isInverse());
+ assertFalse(((Collection)property2.getValue()).isInverse());
+
+ }
+
+ public void testBuildMappings() {
+
+ localCfg.buildMappings();
+ }
+
+ public void testGenerateAndReadable() throws Exception {
+
+ cfg.buildMappings();
+
+ HibernateMappingExporter hme = new HibernateMappingExporter(cfg, getOutputDir());
+ hme.start();
+
+ getConfiguration().buildMappings();
+ POJOExporter exporter = new POJOExporter(getConfiguration(), getOutputDir());
+ Properties p = new Properties();
+ p.setProperty("jdk5", "true");
+ p.setProperty("ejb3", "true");
+
+ exporter.setProperties(p);
+ exporter.start();
+
+ File file = new File( "ejb3compilable" );
+ file.mkdir();
+
+ ArrayList list = new ArrayList();
+ List jars = new ArrayList();
+ addAnnotationJars(jars);
+
+ new ExecuteContext(getOutputDir(), file, jars) {
+
+ protected void execute() throws Exception {
+ AnnotationConfiguration configuration = new AnnotationConfiguration();
+ configuration.addAnnotatedClass( getUcl().loadClass( "Project" ) );
+ configuration.addAnnotatedClass( getUcl().loadClass( "Employee" ) );
+ configuration.addAnnotatedClass( getUcl().loadClass( "WorksOnContext" ) );
+
+ SessionFactory sf = configuration.buildSessionFactory();
+ Session s = sf.openSession();
+ Query createQuery = s.createQuery("from java.lang.Object");
+ createQuery.list();
+ s.close();
+ sf.close();
+
+ }
+
+ }.run();
+
+ }
+
+ private void addAnnotationJars(List jars) {
+ jars.add( "ejb3-persistence.jar" );
+ jars.add( "hibernate-annotations.jar" );
+ jars.add( "hibernate-commons-annotations.jar" );
+ jars.add( "hibernate3.jar" );
+ jars.add( "dom4j-1.6.1.jar" );
+ jars.add( "commons-logging-1.0.4.jar" );
+
+ }
+
+ private void assertPropertyNotExist(PersistentClass projectClass, String prop) {
+ try {
+ projectClass.getProperty(prop);
+ fail("property " + prop + " should not exist on " + projectClass);
+ } catch(MappingException e) {
+ // expected
+ }
+ }
+
+ protected String[] getCreateSQL() {
+ return new String[] {
+ "create table PROJECT ( project_id integer not null, name varchar(50), primary key (project_id) )",
+ "create table EMPLOYEE ( id integer not null, name varchar(50), manager_id integer, primary key (id), constraint employee_manager foreign key (manager_id) references EMPLOYEE)",
+ "create table WORKS_ON ( project_id integer not null, employee_id integer not null, primary key (project_id, employee_id), constraint workson_employee foreign key (employee_id) references EMPLOYEE, foreign key (project_id) references PROJECT )",
+ "create table WORKS_ON_CONTEXT ( project_id integer not null, employee_id integer not null, created_by integer, primary key (project_id, employee_id), constraint workson_ctx_employee foreign key (employee_id) references EMPLOYEE, foreign key (project_id) references PROJECT, foreign key (created_by) references EMPLOYEE )",
+ //"alter table PROJECT add constraint project_manager foreign key (team_lead) references EMPLOYEE"
+ };
+ }
+
+ protected String[] getDropSQL() {
+ return new String[] {
+ //"alter table PROJECT drop constraint project_manager",
+ "drop table WORKS_ON_CONTEXT",
+ "drop table WORKS_ON",
+ "drop table EMPLOYEE",
+ "drop table PROJECT",
+ };
+ }
+
+}
17 years
Hibernate SVN: r14187 - branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-11-04 03:54:31 -0500 (Sun, 04 Nov 2007)
New Revision: 14187
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java
Log:
subclasses can get access to runtimeinfo
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java 2007-11-04 08:51:49 UTC (rev 14186)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java 2007-11-04 08:54:31 UTC (rev 14187)
@@ -166,6 +166,8 @@
public void close() {
runtimeInfo = null;
}
+
+
/** Return explicit which column name should be used for optimistic lock */
public String getOptimisticLockColumnName(TableIdentifier identifier) {
@@ -250,6 +252,10 @@
return settings.getRootStrategy();
}
+ protected ReverseEngineeringRuntimeInfo getRuntimeInfo() {
+ return runtimeInfo;
+ }
+
public String foreignKeyToManyToManyName(ForeignKey fromKey, TableIdentifier middleTable, ForeignKey toKey, boolean uniqueReference) {
String propertyName = Introspector.decapitalize( StringHelper.unqualify( getRoot().tableToClassName(TableIdentifier.create( toKey.getReferencedTable()) )) );
propertyName = pluralize( propertyName );
17 years
Hibernate SVN: r14186 - in branches/Branch_3_2/HibernateExt/tools/src: java/org/hibernate/cfg/reveng/dialect and 5 other directories.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-11-04 03:51:49 -0500 (Sun, 04 Nov 2007)
New Revision: 14186
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCReader.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringRuntimeInfo.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/CachedMetaDataDialect.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/H2MetaDataDialect.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/MetaDataDialect.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/MySQLMetaDataDialect.java
branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/Ejb3PropertyGetAnnotation.ftl
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/BaseTestCase.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/CachedMetaDataTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2XAllTests.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/DriverMetaDataTest.java
branches/Branch_3_2/HibernateExt/tools/src/test5.0/org/hibernate/tool/hbm2x/Hbm2JavaEjb3ForJDK50Test.java
Log:
Fix @JoinColumn
HBX-1002 pass runtimeinfo to metadatadialect
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCReader.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCReader.java 2007-11-04 08:49:09 UTC (rev 14185)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCReader.java 2007-11-04 08:51:49 UTC (rev 14186)
@@ -63,7 +63,7 @@
public List readDatabaseSchema(DatabaseCollector dbs, String catalog, String schema, ProgressListener progress) {
try {
ReverseEngineeringRuntimeInfo info = new ReverseEngineeringRuntimeInfo(provider, sec, dbs);
- getMetaDataDialect().configure(info.getConnectionProvider(), info.getSQLExceptionConverter());
+ getMetaDataDialect().configure(info);
revengStrategy.configure(info);
Set hasIndices = new HashSet();
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringRuntimeInfo.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringRuntimeInfo.java 2007-11-04 08:49:09 UTC (rev 14185)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/ReverseEngineeringRuntimeInfo.java 2007-11-04 08:51:49 UTC (rev 14186)
@@ -2,6 +2,7 @@
import org.hibernate.connection.ConnectionProvider;
import org.hibernate.exception.SQLExceptionConverter;
+import org.hibernate.mapping.Table;
/**
* Provides runtime-only information for reverse engineering process.
@@ -14,10 +15,16 @@
private final ConnectionProvider connectionProvider;
private final SQLExceptionConverter SQLExceptionConverter;
+ private final DatabaseCollector dbs;
+ public static ReverseEngineeringRuntimeInfo createInstance(ConnectionProvider provider, SQLExceptionConverter sec, DatabaseCollector dbs) {
+ return new ReverseEngineeringRuntimeInfo(provider,sec,dbs);
+ }
+
protected ReverseEngineeringRuntimeInfo(ConnectionProvider provider, SQLExceptionConverter sec, DatabaseCollector dbs) {
this.connectionProvider = provider;
- this.SQLExceptionConverter = sec;
+ this.SQLExceptionConverter = sec;
+ this.dbs = dbs;
}
public ConnectionProvider getConnectionProvider() {
@@ -28,6 +35,24 @@
return SQLExceptionConverter;
}
+ /** Shorthand for {@link getTable(String,String,String)} **/
+ public Table getTable(TableIdentifier ti) {
+ return dbs.getTable(ti.getSchema(), ti.getCatalog(), ti.getName());
+ }
+ /**
+ * Look up the table identified by the parameters in the currently found tables.
+ * Warning: The table might not be fully initialized yet.
+ *
+ * @param catalog
+ * @param schema
+ * @param name
+ * @return Table if found in processd tables, null if not
+ */
+ public Table getTable(String catalog, String schema, String name) {
+ return dbs.getTable(schema, catalog, name);
+ }
+
+
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java 2007-11-04 08:49:09 UTC (rev 14185)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java 2007-11-04 08:51:49 UTC (rev 14186)
@@ -13,6 +13,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.cfg.JDBCBinderException;
+import org.hibernate.cfg.reveng.ReverseEngineeringRuntimeInfo;
import org.hibernate.connection.ConnectionProvider;
import org.hibernate.exception.SQLExceptionConverter;
import org.hibernate.util.StringHelper;
@@ -27,25 +28,23 @@
abstract public class AbstractMetaDataDialect implements MetaDataDialect {
protected final Log log = LogFactory.getLog(this.getClass());
-
- private SQLExceptionConverter sec;
- private ConnectionProvider provider;
private Connection connection;
private DatabaseMetaData metaData;
+ private ReverseEngineeringRuntimeInfo info;
- public void configure(ConnectionProvider provider, SQLExceptionConverter sec) {
- this.provider = provider;
- this.sec = sec;
+
+ public void configure(ReverseEngineeringRuntimeInfo info) {
+ this.info = info;
+
}
-
public void close() {
metaData = null;
if(connection != null) {
try {
- provider.closeConnection(connection);
+ info.getConnectionProvider().closeConnection(connection);
}
catch (SQLException e) {
throw getSQLExceptionConverter().convert(e, "Problem while closing connection", null);
@@ -53,8 +52,7 @@
connection = null;
}
}
- provider = null;
- sec = null;
+ info = null;
}
protected DatabaseMetaData getMetaData() throws JDBCBinderException {
@@ -121,11 +119,15 @@
protected Connection getConnection() throws SQLException {
if(connection==null) {
- connection = provider.getConnection();
+ connection = info.getConnectionProvider().getConnection();
}
return connection;
}
+ public ReverseEngineeringRuntimeInfo getReverseEngineeringRuntimeInfo() {
+ return info;
+ }
+
public void close(Iterator iterator) {
if(iterator instanceof ResultSetIterator) {
((ResultSetIterator)iterator).close();
@@ -133,7 +135,7 @@
}
protected SQLExceptionConverter getSQLExceptionConverter() {
- return sec;
+ return info.getSQLExceptionConverter();
}
public boolean needQuote(String name) {
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/CachedMetaDataDialect.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/CachedMetaDataDialect.java 2007-11-04 08:49:09 UTC (rev 14185)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/CachedMetaDataDialect.java 2007-11-04 08:51:49 UTC (rev 14186)
@@ -6,6 +6,7 @@
import java.util.List;
import java.util.Map;
+import org.hibernate.cfg.reveng.ReverseEngineeringRuntimeInfo;
import org.hibernate.connection.ConnectionProvider;
import org.hibernate.exception.SQLExceptionConverter;
@@ -27,6 +28,10 @@
delegate.close();
}
+ public void configure(ReverseEngineeringRuntimeInfo info) {
+ delegate.configure(info);
+ }
+
public void close(Iterator iterator) {
if(iterator instanceof CachedIterator) {
CachedIterator ci = (CachedIterator) iterator;
@@ -38,9 +43,7 @@
delegate.close( iterator );
}
- public void configure(ConnectionProvider provider, SQLExceptionConverter sec) {
- delegate.configure( provider, sec );
- }
+
public Iterator getColumns(String catalog, String schema, String table, String column) {
StringKey sk = new StringKey(new String[] { catalog, schema, table, column });
@@ -201,5 +204,7 @@
}
}
+
+
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/H2MetaDataDialect.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/H2MetaDataDialect.java 2007-11-04 08:49:09 UTC (rev 14185)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/H2MetaDataDialect.java 2007-11-04 08:51:49 UTC (rev 14186)
@@ -55,7 +55,7 @@
schema = caseForSearch( schema );
table = caseForSearch( table );
- log.debug("getTables(" + catalog + "." + schema + "." + table + ")");
+ log.debug("geSuggestedPrimaryKeyStrategyName(" + catalog + "." + schema + "." + table + ")");
String sql = "SELECT idx.TABLE_CATALOG TABLE_CAT, idx.TABLE_SCHEMA TABLE_SCHEM, idx.TABLE_NAME, idx.COLUMN_NAME, cols.COLUMN_DEFAULT COLUMN_DEFAULT FROM " +
"INFORMATION_SCHEMA.INDEXES idx, INFORMATION_SCHEMA.COLUMNS cols " +
@@ -95,7 +95,7 @@
}
};
} catch (SQLException e) {
- throw getSQLExceptionConverter().convert(e, "Could not get list of tables from database. Probably a JDBC driver problem.", null);
+ throw getSQLExceptionConverter().convert(e, "Could not get list of suggested identity strategies from database. Probably a JDBC driver problem.", null);
}
}
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/MetaDataDialect.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/MetaDataDialect.java 2007-11-04 08:49:09 UTC (rev 14185)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/MetaDataDialect.java 2007-11-04 08:51:49 UTC (rev 14186)
@@ -2,6 +2,7 @@
import java.util.Iterator;
+import org.hibernate.cfg.reveng.ReverseEngineeringRuntimeInfo;
import org.hibernate.connection.ConnectionProvider;
import org.hibernate.exception.SQLExceptionConverter;
@@ -20,10 +21,9 @@
/**
* Configure the metadatadialect.
- * @param provider a connectionprovider. It is the responsibility of the metadatadialect to open/close any used connections via this provider.
- * @param sec sqlexceptionConverter, use to convert any possible SQLExceptionsConverter.
+ * @param info a {@link ReverseEngineeringRuntimeInfo} to extract Connection and SQLExceptionConverter and other runtime info
*/
- public void configure(ConnectionProvider provider, SQLExceptionConverter sec);
+ public void configure(ReverseEngineeringRuntimeInfo info);
/**
* Return iterator over the tables that mathces catalog, schema and table
@@ -105,4 +105,6 @@
* @return iterator with map elements that has "TABLE_NAME", "TABLE_SCHEMA", "TABLE_CAT", "HIBERNATE_STRATEGY" (null if no possible to determine strategy, otherwise return hibernate identifier strategy name/classname)
*/
public Iterator getSuggestedPrimaryKeyStrategyName(String catalog, String schema, String table);
+
+
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/MySQLMetaDataDialect.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/MySQLMetaDataDialect.java 2007-11-04 08:49:09 UTC (rev 14185)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/MySQLMetaDataDialect.java 2007-11-04 08:51:49 UTC (rev 14186)
@@ -20,7 +20,7 @@
schema = caseForSearch( schema );
table = caseForSearch( table );
- log.debug("getTables(" + catalog + "." + schema + "." + table + ")");
+ log.debug("geSuggestedPrimaryKeyStrategyName(" + catalog + "." + schema + "." + table + ")");
sql = "show table status " + (schema==null?"":" from " + schema + " ") + (table==null?"":" like '" + table + "' ");
PreparedStatement statement = getConnection().prepareStatement( sql );
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/Ejb3PropertyGetAnnotation.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/Ejb3PropertyGetAnnotation.ftl 2007-11-04 08:49:09 UTC (rev 14185)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/Ejb3PropertyGetAnnotation.ftl 2007-11-04 08:51:49 UTC (rev 14186)
@@ -10,7 +10,7 @@
<#--TODO support @OneToOne true and false-->
${pojo.generateManyToOneAnnotation(property)}
<#--TODO support optional and targetEntity-->
-${pojo.generateJoinColumnsAnnotation(property)}
+${pojo.generateJoinColumnsAnnotation(property, cfg)}
<#elseif c2h.isCollection(property)>
${pojo.generateCollectionAnnotation(property, cfg)}
<#else>
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/BaseTestCase.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/BaseTestCase.java 2007-11-04 08:49:09 UTC (rev 14185)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/BaseTestCase.java 2007-11-04 08:51:49 UTC (rev 14186)
@@ -4,9 +4,13 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
+import java.net.URL;
+import java.net.URLClassLoader;
import java.sql.Connection;
import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import junit.framework.ComparisonFailure;
import junit.framework.TestCase;
@@ -18,12 +22,69 @@
import org.dom4j.io.SAXReader;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Settings;
+import org.hibernate.cfg.reveng.DefaultDatabaseCollector;
+import org.hibernate.cfg.reveng.ReverseEngineeringRuntimeInfo;
import org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.tool.test.TestHelper;
public abstract class BaseTestCase extends TestCase {
+ protected static abstract class ExecuteContext {
+
+ private final File sourceDir;
+ private final File outputDir;
+ private final List jars;
+ private URLClassLoader ucl;
+
+ public ExecuteContext(File sourceDir, File outputDir, List jars) {
+ this.sourceDir = sourceDir;
+ this.outputDir = outputDir;
+ this.jars = jars;
+ }
+
+ public void run() throws Exception {
+
+ TestHelper.compile(
+ sourceDir, outputDir, TestHelper.visitAllFiles( sourceDir, new ArrayList() ), "1.5",
+ TestHelper.buildClasspath( jars )
+ );
+ URL[] urls = TestHelper.buildClasspathURLS(jars, outputDir);
+
+ Thread currentThread = null;
+ ClassLoader contextClassLoader = null;
+
+ try {
+ currentThread = Thread.currentThread();
+ contextClassLoader = currentThread.getContextClassLoader();
+ ucl = new URLClassLoader( urls, contextClassLoader ) {
+
+ public Class loadClass(String name)
+ throws ClassNotFoundException {
+ // TODO Auto-generated method stub
+ return super.loadClass(name);
+ }
+
+
+ };
+ currentThread.setContextClassLoader( ucl );
+
+ execute();
+
+ } finally {
+ currentThread.setContextClassLoader( contextClassLoader );
+ TestHelper.deleteDir( outputDir );
+ }
+ }
+
+ public URLClassLoader getUcl() {
+ return ucl;
+ }
+
+ abstract protected void execute() throws Exception;
+
+ }
+
protected static final Log SKIP_LOG = LogFactory.getLog("org.hibernate.tool.test.SKIPPED");
private File outputdir;
@@ -87,7 +148,8 @@
con = testSettings.getConnectionProvider().getConnection();
JDBCMetaDataDialect dialect = new JDBCMetaDataDialect();
- dialect.configure( testSettings.getConnectionProvider(), testSettings.getSQLExceptionConverter() );
+
+ dialect.configure( ReverseEngineeringRuntimeInfo.createInstance(testSettings.getConnectionProvider(), testSettings.getSQLExceptionConverter(), new DefaultDatabaseCollector()));
Iterator tables = dialect.getTables( testSettings.getDefaultCatalogName(), testSettings.getDefaultSchemaName(), null );
assertHasNext( 0, tables );
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java 2007-11-04 08:49:09 UTC (rev 14185)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java 2007-11-04 08:51:49 UTC (rev 14186)
@@ -1,6 +1,7 @@
//$Id$
package org.hibernate.tool;
+
import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
import org.hibernate.SessionFactory;
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/CachedMetaDataTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/CachedMetaDataTest.java 2007-11-04 08:49:09 UTC (rev 14185)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/CachedMetaDataTest.java 2007-11-04 08:51:49 UTC (rev 14186)
@@ -13,6 +13,7 @@
import org.hibernate.cfg.reveng.DefaultDatabaseCollector;
import org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.JDBCReader;
+import org.hibernate.cfg.reveng.ReverseEngineeringRuntimeInfo;
import org.hibernate.cfg.reveng.dialect.CachedMetaDataDialect;
import org.hibernate.cfg.reveng.dialect.MetaDataDialect;
import org.hibernate.connection.ConnectionProvider;
@@ -49,10 +50,10 @@
delegate.close( iterator );
}
- public void configure(ConnectionProvider provider, SQLExceptionConverter sec) {
- delegate.configure( provider, sec );
+ public void configure(ReverseEngineeringRuntimeInfo info) {
+ delegate.configure(info);
}
-
+
public Iterator getColumns(String catalog, String schema, String table, String column) {
if(failOnDelegateAccess) {
throw new IllegalStateException("delegate not accessible");
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2XAllTests.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2XAllTests.java 2007-11-04 08:49:09 UTC (rev 14185)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2XAllTests.java 2007-11-04 08:51:49 UTC (rev 14186)
@@ -1,5 +1,8 @@
package org.hibernate.tool.hbm2x;
+import org.hibernate.tool.test.jdbc2cfg.identity.H2IdentityTest;
+import org.hibernate.tool.test.jdbc2cfg.identity.MySQLIdentityTest;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -28,8 +31,11 @@
suite.addTestSuite(Hbm2JavaEjb3Test.class);
suite.addTestSuite(XMLPrettyPrinterTest.class);
suite.addTestSuite(GenericExporterTest.class);
- suite.addTestSuite(Hbm2JavaTest.class);
+ suite.addTestSuite(Hbm2JavaTest.class);
//$JUnit-END$
+
+ suite.addTestSuite(H2IdentityTest.class);
+ suite.addTestSuite(MySQLIdentityTest.class);
return suite;
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/DriverMetaDataTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/DriverMetaDataTest.java 2007-11-04 08:49:09 UTC (rev 14185)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/DriverMetaDataTest.java 2007-11-04 08:51:49 UTC (rev 14186)
@@ -4,6 +4,8 @@
import java.util.Map;
import org.hibernate.cfg.Settings;
+import org.hibernate.cfg.reveng.DefaultDatabaseCollector;
+import org.hibernate.cfg.reveng.ReverseEngineeringRuntimeInfo;
import org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect;
import org.hibernate.cfg.reveng.dialect.MetaDataDialect;
import org.hibernate.tool.JDBCMetaDataBinderTestCase;
@@ -39,7 +41,7 @@
Settings settings = cfg.buildSettings();
- dialect.configure( settings.getConnectionProvider(), settings.getSQLExceptionConverter() );
+ dialect.configure( ReverseEngineeringRuntimeInfo.createInstance(settings.getConnectionProvider(), settings.getSQLExceptionConverter(), new DefaultDatabaseCollector()));
Iterator tables = dialect.getTables( settings.getDefaultCatalogName(), settings.getDefaultSchemaName(), identifier("tab_master") );
@@ -74,7 +76,7 @@
Settings settings = cfg.buildSettings();
- dialect.configure( settings.getConnectionProvider(), settings.getSQLExceptionConverter() );
+ dialect.configure( ReverseEngineeringRuntimeInfo.createInstance(settings.getConnectionProvider(), settings.getSQLExceptionConverter(), new DefaultDatabaseCollector()));
Iterator tables = dialect.getColumns( settings.getDefaultCatalogName(), settings.getDefaultSchemaName(), "test", null );
@@ -94,7 +96,7 @@
Settings settings = cfg.buildSettings();
- dialect.configure( settings.getConnectionProvider(), settings.getSQLExceptionConverter() );
+ dialect.configure( ReverseEngineeringRuntimeInfo.createInstance(settings.getConnectionProvider(), settings.getSQLExceptionConverter(), new DefaultDatabaseCollector()));
Iterator tables = dialect.getTables( settings.getDefaultCatalogName(), settings.getDefaultSchemaName(), identifier( "TAB_MASTER"));
Modified: branches/Branch_3_2/HibernateExt/tools/src/test5.0/org/hibernate/tool/hbm2x/Hbm2JavaEjb3ForJDK50Test.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test5.0/org/hibernate/tool/hbm2x/Hbm2JavaEjb3ForJDK50Test.java 2007-11-04 08:49:09 UTC (rev 14185)
+++ branches/Branch_3_2/HibernateExt/tools/src/test5.0/org/hibernate/tool/hbm2x/Hbm2JavaEjb3ForJDK50Test.java 2007-11-04 08:51:49 UTC (rev 14186)
@@ -205,61 +205,6 @@
}.run();
}
- static abstract class ExecuteContext {
-
- private final File sourceDir;
- private final File outputDir;
- private final List jars;
- private URLClassLoader ucl;
-
- public ExecuteContext(File sourceDir, File outputDir, List jars) {
- this.sourceDir = sourceDir;
- this.outputDir = outputDir;
- this.jars = jars;
- }
-
- public void run() throws Exception {
-
- TestHelper.compile(
- sourceDir, outputDir, TestHelper.visitAllFiles( sourceDir, new ArrayList() ), "1.5",
- TestHelper.buildClasspath( jars )
- );
- URL[] urls = TestHelper.buildClasspathURLS(jars, outputDir);
-
- Thread currentThread = null;
- ClassLoader contextClassLoader = null;
-
- try {
- currentThread = Thread.currentThread();
- contextClassLoader = currentThread.getContextClassLoader();
- ucl = new URLClassLoader( urls, contextClassLoader ) {
-
- public Class loadClass(String name)
- throws ClassNotFoundException {
- // TODO Auto-generated method stub
- return super.loadClass(name);
- }
-
-
- };
- currentThread.setContextClassLoader( ucl );
-
- execute();
-
- } finally {
- currentThread.setContextClassLoader( contextClassLoader );
- TestHelper.deleteDir( outputDir );
- }
- }
-
- public URLClassLoader getUcl() {
- return ucl;
- }
-
- abstract protected void execute() throws Exception;
-
- }
-
private void testGenerator(final String className) throws Exception {
File file = new File( "ejb3compilable" );
17 years
Hibernate SVN: r14185 - branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-11-04 03:49:09 -0500 (Sun, 04 Nov 2007)
New Revision: 14185
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java
Log:
fixed @JoinColumn
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java 2007-11-04 08:48:14 UTC (rev 14184)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java 2007-11-04 08:49:09 UTC (rev 14185)
@@ -329,12 +329,13 @@
return propertyValue != null && propertyValue.equals( defaultValue );
}
- public String generateJoinColumnsAnnotation(Property property) {
+ public String generateJoinColumnsAnnotation(Property property, Configuration cfg) {
boolean insertable = property.isInsertable();
boolean updatable = property.isUpdateable();
Value value = property.getValue();
int span;
Iterator columnIterator;
+ Iterator referencedColumnsIterator = null;
if (value != null && value instanceof Collection) {
Collection collection = (Collection) value;
span = collection.getKey().getColumnSpan();
@@ -344,35 +345,47 @@
span = property.getColumnSpan();
columnIterator = property.getColumnIterator();
}
+
+ if(property.getValue() instanceof ToOne) {
+ String referencedEntityName = ((ToOne)property.getValue()).getReferencedEntityName();
+ PersistentClass target = cfg.getClassMapping(referencedEntityName);
+ if(target!=null) {
+ referencedColumnsIterator = target.getKey().getColumnIterator();
+ }
+ }
StringBuffer annotations = new StringBuffer( " " );
if ( span == 1 ) {
Selectable selectable = (Selectable) columnIterator.next();
- buildJoinColumnAnnotation( selectable, annotations, insertable, updatable );
+ buildJoinColumnAnnotation( selectable, null, annotations, insertable, updatable );
}
else {
Iterator columns = columnIterator;
annotations.append("@").append( importType("javax.persistence.JoinColumns") ).append("( { " );
- buildArrayOfJoinColumnAnnotation( columns, annotations, insertable, updatable );
+ buildArrayOfJoinColumnAnnotation( columns, referencedColumnsIterator, annotations, insertable, updatable );
annotations.append( " } )" );
}
return annotations.toString();
}
private void buildArrayOfJoinColumnAnnotation(
- Iterator columns, StringBuffer annotations, boolean insertable,
+ Iterator columns, Iterator referencedColumnsIterator, StringBuffer annotations, boolean insertable,
boolean updatable
) {
while ( columns.hasNext() ) {
Selectable selectable = (Selectable) columns.next();
-
+ Selectable referencedColumn = null;
+ if(referencedColumnsIterator!=null) {
+ referencedColumn = (Selectable) referencedColumnsIterator.next();
+ }
+
if ( selectable.isFormula() ) {
//TODO formula in multicolumns not supported by annotations
//annotations.append("/* TODO formula in multicolumns not supported by annotations */");
}
else {
annotations.append( "\n " );
- buildJoinColumnAnnotation( selectable, annotations, insertable, updatable );
+ buildJoinColumnAnnotation( selectable, referencedColumn, annotations, insertable, updatable );
annotations.append( ", " );
}
}
@@ -380,7 +393,7 @@
}
private void buildJoinColumnAnnotation(
- Selectable selectable, StringBuffer annotations, boolean insertable, boolean updatable
+ Selectable selectable, Selectable referencedColumn, StringBuffer annotations, boolean insertable, boolean updatable
) {
if ( selectable.isFormula() ) {
//TODO not supported by HA
@@ -390,7 +403,10 @@
annotations.append("@").append( importType("javax.persistence.JoinColumn") )
.append("(name=\"" ).append( column.getName() ).append( "\"" );
//TODO handle referenced column name, this is a hard one
- //.append(", referencedColumnName=")
+ if(referencedColumn!=null) {
+ annotations.append(", referencedColumnName=\"" ).append( referencedColumn.getText() ).append( "\"" );
+ }
+
appendCommonColumnInfo(annotations, column, insertable, updatable);
//TODO support secondary table
annotations.append( ")" );
@@ -513,7 +529,7 @@
}
annotation.append( ab.getResult() );
- if (mappedBy == null) annotation.append("\n").append( generateJoinColumnsAnnotation(property) );
+ if (mappedBy == null) annotation.append("\n").append( generateJoinColumnsAnnotation(property, cfg) );
}
else {
//TODO do the @OneToMany @JoinTable
@@ -548,6 +564,7 @@
annotation.append( ", joinColumns = { ");
buildArrayOfJoinColumnAnnotation(
collection.getKey().getColumnIterator(),
+ null,
annotation,
property.isInsertable(),
property.isUpdateable()
@@ -556,6 +573,7 @@
annotation.append( ", inverseJoinColumns = { ");
buildArrayOfJoinColumnAnnotation(
collection.getElement().getColumnIterator(),
+ null,
annotation,
property.isInsertable(),
property.isUpdateable()
17 years
Hibernate SVN: r14184 - branches/Branch_3_2/HibernateExt/tools/lib/testlibs.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-11-04 03:48:14 -0500 (Sun, 04 Nov 2007)
New Revision: 14184
Added:
branches/Branch_3_2/HibernateExt/tools/lib/testlibs/hibernate-commons-annotations.jar
Log:
added commons annotations for unittests to pass
Added: branches/Branch_3_2/HibernateExt/tools/lib/testlibs/hibernate-commons-annotations.jar
===================================================================
(Binary files differ)
Property changes on: branches/Branch_3_2/HibernateExt/tools/lib/testlibs/hibernate-commons-annotations.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
17 years
Hibernate SVN: r14183 - core/trunk/core/src/main/java/org/hibernate/id/enhanced.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-11-02 12:18:14 -0400 (Fri, 02 Nov 2007)
New Revision: 14183
Modified:
core/trunk/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java
Log:
HHH-2928 : synchronize enhanced id gen optimizers
Modified: core/trunk/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java 2007-11-02 16:17:07 UTC (rev 14182)
+++ core/trunk/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java 2007-11-02 16:18:14 UTC (rev 14183)
@@ -120,7 +120,7 @@
}
}
- public Serializable generate(AccessCallback callback) {
+ public synchronized Serializable generate(AccessCallback callback) {
if ( lastSourceValue < 0 ) {
lastSourceValue = callback.getNextValue();
while ( lastSourceValue <= 0 ) {
@@ -168,7 +168,7 @@
}
}
- public Serializable generate(AccessCallback callback) {
+ public synchronized Serializable generate(AccessCallback callback) {
if ( hiValue < 0 ) {
value = callback.getNextValue();
if ( value < 1 ) {
17 years
Hibernate SVN: r14182 - core/branches/Branch_3_2/src/org/hibernate/id/enhanced.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-11-02 12:17:07 -0400 (Fri, 02 Nov 2007)
New Revision: 14182
Modified:
core/branches/Branch_3_2/src/org/hibernate/id/enhanced/OptimizerFactory.java
Log:
HHH-2928 : synchronize enhanced id gen optimizers
Modified: core/branches/Branch_3_2/src/org/hibernate/id/enhanced/OptimizerFactory.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/id/enhanced/OptimizerFactory.java 2007-11-02 16:11:43 UTC (rev 14181)
+++ core/branches/Branch_3_2/src/org/hibernate/id/enhanced/OptimizerFactory.java 2007-11-02 16:17:07 UTC (rev 14182)
@@ -120,7 +120,7 @@
}
}
- public Serializable generate(AccessCallback callback) {
+ public synchronized Serializable generate(AccessCallback callback) {
if ( lastSourceValue < 0 ) {
lastSourceValue = callback.getNextValue();
while ( lastSourceValue <= 0 ) {
@@ -168,7 +168,7 @@
}
}
- public Serializable generate(AccessCallback callback) {
+ public synchronized Serializable generate(AccessCallback callback) {
if ( hiValue < 0 ) {
value = callback.getNextValue();
if ( value < 1 ) {
17 years
Hibernate SVN: r14181 - core/branches/Branch_3_2/test/org/hibernate/test/ops.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-11-02 12:11:43 -0400 (Fri, 02 Nov 2007)
New Revision: 14181
Modified:
core/branches/Branch_3_2/test/org/hibernate/test/ops/MergeTest.java
Log:
added test for stale merging
Modified: core/branches/Branch_3_2/test/org/hibernate/test/ops/MergeTest.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/ops/MergeTest.java 2007-11-02 16:11:05 UTC (rev 14180)
+++ core/branches/Branch_3_2/test/org/hibernate/test/ops/MergeTest.java 2007-11-02 16:11:43 UTC (rev 14181)
@@ -8,11 +8,12 @@
import junit.framework.Test;
import org.hibernate.Hibernate;
+import org.hibernate.NonUniqueObjectException;
import org.hibernate.Session;
+import org.hibernate.StaleObjectStateException;
import org.hibernate.Transaction;
-import org.hibernate.NonUniqueObjectException;
+import org.hibernate.criterion.Projections;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import org.hibernate.criterion.Projections;
/**
* @author Gavin King
@@ -27,6 +28,39 @@
return new FunctionalTestClassTestSuite( MergeTest.class );
}
+ public void testMergeStaleVersionFails() throws Exception {
+ Session s = openSession();
+ s.beginTransaction();
+ VersionedEntity entity = new VersionedEntity( "entity", "entity" );
+ s.persist( entity );
+ s.getTransaction().commit();
+ s.close();
+
+ // make the detached 'entity' reference stale...
+ s = openSession();
+ s.beginTransaction();
+ VersionedEntity entity2 = ( VersionedEntity ) s.get( VersionedEntity.class, entity.getId() );
+ entity2.setName( "entity-name" );
+ s.getTransaction().commit();
+ s.close();
+
+ // now try to reattch it
+ s = openSession();
+ s.beginTransaction();
+ try {
+ s.merge( entity );
+ s.getTransaction().commit();
+ fail( "was expecting staleness error" );
+ }
+ catch ( StaleObjectStateException expected ) {
+ // expected outcome...
+ }
+ finally {
+ s.getTransaction().rollback();
+ s.close();
+ }
+ }
+
public void testMergeBidiPrimayKeyOneToOne() throws Exception {
Session s = openSession();
s.beginTransaction();
@@ -121,7 +155,7 @@
assertInsertCount( 0 );
///////////////////////////////////////////////////////////////////////
- cleanup();
+// cleanup();
}
public void testNoExtraUpdatesOnMergeWithCollection() throws Exception {
@@ -162,7 +196,7 @@
assertInsertCount( 1 );
///////////////////////////////////////////////////////////////////////
- cleanup();
+// cleanup();
}
public void testNoExtraUpdatesOnMergeVersioned() throws Exception {
@@ -201,7 +235,7 @@
assertInsertCount( 0 );
///////////////////////////////////////////////////////////////////////
- cleanup();
+// cleanup();
}
public void testNoExtraUpdatesOnMergeVersionedWithCollection() throws Exception {
@@ -245,7 +279,7 @@
assertInsertCount( 1 );
///////////////////////////////////////////////////////////////////////
- cleanup();
+// cleanup();
}
public void testPersistThenMergeInSameTxnWithVersion() {
@@ -267,7 +301,7 @@
tx.commit();
s.close();
- cleanup();
+// cleanup();
}
public void testPersistThenMergeInSameTxnWithTimestamp() {
@@ -289,7 +323,7 @@
tx.commit();
s.close();
- cleanup();
+// cleanup();
}
public void testMergeDeepTree() {
@@ -447,7 +481,7 @@
assertInsertCount(1);
assertUpdateCount(2);
- cleanup();
+// cleanup();
}
public void testMergeTreeWithGeneratedId() {
@@ -482,7 +516,7 @@
assertInsertCount(1);
assertUpdateCount(2);
- cleanup();
+// cleanup();
}
public void testMergeManaged() {
@@ -524,7 +558,7 @@
s.close();
- cleanup();
+// cleanup();
}
public void testRecursiveMergeTransient() {
@@ -544,7 +578,7 @@
tx.commit();
s.close();
- cleanup();
+// cleanup();
}
public void testDeleteAndMerge() throws Exception {
@@ -567,7 +601,7 @@
s.getTransaction().commit();
s.close();
- cleanup();
+// cleanup();
}
public void testMergeManyToManyWithCollectionDeference() throws Exception {
@@ -610,11 +644,16 @@
tx.commit();
s.close();
+// cleanup();
+ }
+
+ protected void cleanupTest() throws Exception {
cleanup();
+ super.cleanupTest();
}
private void cleanup() {
- Session s = openSession();
+ Session s = sfi().openSession();
s.beginTransaction();
s.createQuery( "delete from NumberedNode where parent is not null" ).executeUpdate();
s.createQuery( "delete from NumberedNode" ).executeUpdate();
17 years