Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

winduprule-387 test for the use of TableGenerator #356

Merged
16 changes: 11 additions & 5 deletions rules-reviewed/eap7/eap71/hibernate51-53.windup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,23 @@
</perform>
</rule>
-->
<!--https://issues.jboss.org/browse/WINDUPRULE-387
<!--https://issues.jboss.org/browse/WINDUPRULE-387-->
<rule id="hibernate51-53-01100">
<when>
<and>
jonathanvila marked this conversation as resolved.
Show resolved Hide resolved
<javaclass references="javax.persistence.TableGenerator">
<location>IMPORT</location>
</javaclass>
</and>
jonathanvila marked this conversation as resolved.
Show resolved Hide resolved
</when>
<perform>
<hint title="Hibernate 5.3 - @TableGenerator changes interpretation" effort="1" category-id="potential">
jonathanvila marked this conversation as resolved.
Show resolved Hide resolved
<message>Existing applications migrating to 5.3 and using the `@TableGenerator` have to set the `hibernate.id.generator.stored_last_used` configuration property to `false`.</message>
jonathanvila marked this conversation as resolved.
Show resolved Hide resolved
<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/#migrating_from_hibernate_5_1_to_5_3" />
jonathanvila marked this conversation as resolved.
Show resolved Hide resolved
<tag>hibernate</tag>
</hint>
</perform>
<where param="">
<matches pattern="" />
</where>
</rule>
-->
<!--https://issues.jboss.org/browse/WINDUPRULE-388-->
<rule id="hibernate51-53-01200">
<when>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import org.hibernate.SessionFactory;
import javax.persistence.TableGenerator;
import javax.persistence.Entity;
import javax.persistence.Id;

public class Hibernate515301100 {
private static SessionFactory factory;

public static void main(String[] args) {

try {
factory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
System.err.println("Failed to create sessionFactory object." + ex);
throw new ExceptionInInitializerError(ex);
}

}

@Entity
public class Employee {
@TableGenerator(
name="empGen",
table="ID_GEN",
pkColumnName="GEN_KEY",
valueColumnName="GEN_VALUE",
pkColumnValue="EMP_ID",
allocationSize=1)
@Id
@GeneratedValue(strategy=TABLE, generator="empGen")
int id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,16 @@
</perform>
</rule>
-->
<!--https://issues.jboss.org/browse/WINDUPRULE-387
<rule id="hibernate51-53-01100-test">
<when>
<not>
<iterable-filter size="5">
<hint-exists message="" />
</iterable-filter>
<hint-exists message="Existing applications migrating to 5.3 and using the `@TableGenerator`" />
jonathanvila marked this conversation as resolved.
Show resolved Hide resolved
</not>
</when>
<perform>
<fail message="" />
<fail message="TableGenerator class not found" />
</perform>
</rule>
-->
<!--https://issues.jboss.org/browse/WINDUPRULE-388-->
<rule id="hibernate51-53-01200-test">
<when>
Expand Down