-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-17253 Test circular type variable stack overflow in metamodel gen…
…erator
- Loading branch information
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...st/java/org/hibernate/jpamodelgen/test/circulartypevariable/CircularTypeVariableTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.jpamodelgen.test.circulartypevariable; | ||
|
||
import org.hibernate.jpamodelgen.test.util.CompilationTest; | ||
import org.hibernate.jpamodelgen.test.util.TestForIssue; | ||
import org.hibernate.jpamodelgen.test.util.TestUtil; | ||
import org.hibernate.jpamodelgen.test.util.WithClasses; | ||
|
||
import org.junit.Test; | ||
|
||
import jakarta.persistence.metamodel.SetAttribute; | ||
|
||
@TestForIssue(jiraKey = "HHH-17253") | ||
public class CircularTypeVariableTest extends CompilationTest { | ||
|
||
@Test | ||
@WithClasses({ RoleAccess.class, User.class }) | ||
public void testCircularTypeVariable() { | ||
TestUtil.assertMetamodelClassGeneratedFor( RoleAccess.class ); | ||
TestUtil.assertMetamodelClassGeneratedFor( User.class ); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...nerator/src/test/java/org/hibernate/jpamodelgen/test/circulartypevariable/RoleAccess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.hibernate.jpamodelgen.test.circulartypevariable; | ||
|
||
import org.hibernate.annotations.Immutable; | ||
|
||
import jakarta.persistence.Access; | ||
import jakarta.persistence.AccessType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.MappedSuperclass; | ||
|
||
|
||
@MappedSuperclass | ||
@Access( AccessType.PROPERTY ) | ||
@Immutable | ||
public class RoleAccess< | ||
TRoleAccess extends RoleAccess<TRoleAccess,TUser>, | ||
TUser extends User<TUser,TRoleAccess>> { | ||
|
||
private Long id; | ||
|
||
@Id | ||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...del-generator/src/test/java/org/hibernate/jpamodelgen/test/circulartypevariable/User.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.hibernate.jpamodelgen.test.circulartypevariable; | ||
|
||
import java.util.Set; | ||
|
||
import jakarta.persistence.Access; | ||
import jakarta.persistence.AccessType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.MappedSuperclass; | ||
import jakarta.persistence.OneToMany; | ||
|
||
@MappedSuperclass | ||
@Access( AccessType.PROPERTY ) | ||
public class User< | ||
TUser extends User<TUser,TRoleAccess>, | ||
TRoleAccess extends RoleAccess<TRoleAccess,TUser>> { | ||
private Long id; | ||
private Set<TRoleAccess> roleAccesses; | ||
|
||
@Id | ||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
@OneToMany | ||
public Set<TRoleAccess> getRoleAccesses() { | ||
return roleAccesses; | ||
} | ||
|
||
public void setRoleAccesses(Set<TRoleAccess> roleAccesses) { | ||
this.roleAccesses = roleAccesses; | ||
} | ||
} |