Skip to content

Commit

Permalink
winduprule-386 hibernate default props (#358)
Browse files Browse the repository at this point in the history
* winduprule-386 check hibernate.default_schema and hibernate.default_catalog

* winduprule-386 fixed the namespace used in the file

* winduprule-386 simplified the rule using params

* winduprule-386 redefined rule and added test files

* winduprule-386 add 2 spaces, again

* winduprule-386 add trailing spaces

* Update rules-reviewed/eap7/eap71/hibernate51-53.windup.xml

Co-Authored-By: jonathanvila <jonathan.vila@gmail.com>

* Update rules-reviewed/eap7/eap71/tests/hibernate51-53.windup.test.xml

Co-Authored-By: jonathanvila <jonathan.vila@gmail.com>

* Update rules-reviewed/eap7/eap71/hibernate51-53.windup.xml

Co-Authored-By: jonathanvila <jonathan.vila@gmail.com>

* winduprule-386 fixed comment

* Update rules-reviewed/eap7/eap71/hibernate51-53.windup.xml

Co-Authored-By: jonathanvila <jonathan.vila@gmail.com>
  • Loading branch information
jonathanvila authored and mrizzi committed Mar 7, 2019
1 parent 9d1826c commit 4bd7b9f
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 17 deletions.
29 changes: 16 additions & 13 deletions rules-reviewed/eap7/eap71/hibernate51-53.windup.xml
Expand Up @@ -396,25 +396,28 @@
<matches pattern="(persister|tuple)"/>
</where>
</rule>
<!--https://issues.jboss.org/browse/WINDUPRULE-385
<rule id="hibernate51-53-00900">
<when>
</when>
<perform>
</perform>
<where param="">
<matches pattern="" />
</where>
</rule>
-->
<!--https://issues.jboss.org/browse/WINDUPRULE-386
<!--https://issues.jboss.org/browse/WINDUPRULE-386-->
<rule id="hibernate51-53-01000">
<when>
<and>
<xmlfile matches="//s:persistence-unit" as="persistence_files">
<namespace prefix="s" uri="http://java.sun.com/xml/ns/persistence"/>
</xmlfile>
<xmlfile matches="//s:properties[count(s:property[@name='hibernate.default_schema'])=0 and count(s:property[@name='hibernate.default_catalog'])=0]" from="persistence_files" as="wrong_files">
<namespace prefix="s" uri="http://java.sun.com/xml/ns/persistence"/>
</xmlfile>
</and>
</when>
<perform>
<iteration over="wrong_files">
<hint title="Hibernate 5.3 - default_schema or default_catalog must be defined or set jdbc_metadata_extraction_strategy" category-id="mandatory" effort="1">
<message>Define `hibernate.default_schema` or `hibernate.default_catalog` (whichever is used by the selected dialect), or, alternatively, set `hibernate.hbm2ddl.jdbc_metadata_extraction_strategy=individually`.</message>
<link title="Red Hat JBoss EAP 7.2: Migrating from Hibernate ORM 5.1 to Hibernate ORM 5.3" href="https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.2/html-single/migration_guide/#schema_management_tooling_changes_71"/>
<tag>hibernate</tag>
</hint>
</iteration>
</perform>
</rule>
-->
<!--https://issues.jboss.org/browse/WINDUPRULE-387-->
<rule id="hibernate51-53-01100">
<when>
Expand Down
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="testPU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/testdb</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.connection.autocommit" value="true"/>
<property name="hibernate.default_catalog" value="mycatalog"/>
</properties>
</persistence-unit>
</persistence>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="testPU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/testdb</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.connection.autocommit" value="true"/>
<property name="hibernate.default_schema" value="myschema"/>
</properties>
</persistence-unit>
</persistence>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="testPU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/testdb</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.connection.autocommit" value="true"/>
</properties>
</persistence-unit>
</persistence>
Expand Up @@ -235,20 +235,20 @@
</perform>
</rule>
-->
<!--https://issues.jboss.org/browse/WINDUPRULE-386
<!--https://issues.jboss.org/browse/WINDUPRULE-386-->
<rule id="hibernate51-53-01000-test">
<when>
<not>
<iterable-filter size="1">
<hint-exists message="" />
<hint-exists message="Define `hibernate.default_schema` or `hibernate.default_catalog`"/>
</iterable-filter>
</not>
</when>
<perform>
<fail message="" />
<fail message="No default_schema or default_catalog found"/>
</perform>
</rule>
-->
<!--https://issues.jboss.org/browse/WINDUPRULE-387-->
<rule id="hibernate51-53-01100-test">
<when>
<not>
Expand Down

0 comments on commit 4bd7b9f

Please sign in to comment.