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

[releases/6.1.z] [WINDUPRULE-966] Add @GeneratedValue rule (#888) #891

Merged
merged 2 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions rules/rules-reviewed/eap8/eap7/hibernate6.windup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@
</metadata>

<rules>
<rule id="hibernate-00005">
<when>
<and>
<javaclass references="javax.persistence.GeneratedValue">
<location>ANNOTATION</location>
</javaclass>
<or>
<dependency groupId="org.hibernate" artifactId="hibernate-core" toVersion="5.6.15.Final"/>
<project>
<artifact groupId="org.hibernate" artifactId="hibernate-core" toVersion="5.6.15.Final"/>
</project>
</or>
</and>
</when>
<perform>
<hint title="Implicit name determination for sequences and tables associated with identifier generation has changed" effort="3" category-id="potential">
<message>
The way in which Hibernate determines implicit names for sequences and tables associated with identifier generation has changed in 6.0 which may affect migrating applications.
As of 6.0, Hibernate by default creates a sequence per entity hierarchy instead of a single sequence hibernate_sequence.
Due to this change, users that previously used `@GeneratedValue(strategy = GenerationStrategy.AUTO)` or simply `@GeneratedValue` (since `AUTO` is the default), need to ensure that the database now contains sequences for every entity, named `&lt;entity name&gt;_seq`. For an entity Person, a sequence person_seq is expected to exist. It’s best to run hbm2ddl (e.g. by temporarily setting `hbm2ddl.auto=create`) to obtain a list of DDL statements for the sequences.
</message>
<link href="https://github.com/hibernate/hibernate-orm/blob/6.0/migration-guide.adoc#implicit-identifier-sequence-and-table-name" title="Hibernate ORM 6 migration guide - Implicit Identifier Sequence and Table Name"/>
</hint>
</perform>
</rule>
<rule id="hibernate-00010">
<when>
<javaclass references="org.hibernate.annotations.{annotation}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
import org.hibernate.jmx.internal.DisabledJmxServiceImpl;

import org.hibernate.criterion.Criterion;
import javax.persistence.GeneratedValue;

@NamedNativeQuery(callable = true, name = "name", query = "query")
public class HibernateOrm6TestClass implements BasicType {
@AnyMetaDef(metaType = "type")
String hey;

@GeneratedValue
@ParamDef(name = "name", type = "type")
String param;

Expand Down
Binary file not shown.
10 changes: 10 additions & 0 deletions rules/rules-reviewed/eap8/eap7/tests/hibernate6.windup.test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
<rulePath>../</rulePath>
<ruleset>
<rules>
<rule id="hibernate6-tests-00005">
<when>
<not>
<hint-exists message="The way in which Hibernate determines implicit names for sequences and tables associated with identifier generation has changed in 6.0 which may affect migrating applications*"/>
</not>
</when>
<perform>
<fail message="[hibernate6-tests-00005] Hint not found!"/>
</perform>
</rule>
<rule id="hibernate6-tests-00010">
<when>
<not>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<rule id="javax-to-jakarta-import-00001-test">
<when>
<not>
<iterable-filter size="41">
<iterable-filter size="42">
<hint-exists message="Replace the `javax."/>
</iterable-filter>
</not>
Expand Down