Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-12579 Use the field description with type variables resolved to c…
…ast the return value of the $$_hibernate_read_<property>() method
- Loading branch information
Showing
2 changed files
with
85 additions
and
9 deletions.
There are no files selected for viewing
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
69 changes: 69 additions & 0 deletions
69
...te/test/bytecode/enhancement/basic/GenericReturnValueMappedSuperclassEnhancementTest.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,69 @@ | ||
/* | ||
* 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.test.bytecode.enhancement.basic; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import javax.persistence.Access; | ||
import javax.persistence.AccessType; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
import javax.persistence.MappedSuperclass; | ||
|
||
import org.hibernate.annotations.Cache; | ||
import org.hibernate.annotations.CacheConcurrencyStrategy; | ||
import org.hibernate.testing.TestForIssue; | ||
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(BytecodeEnhancerRunner.class) | ||
public class GenericReturnValueMappedSuperclassEnhancementTest { | ||
|
||
@Test | ||
@TestForIssue(jiraKey = "HHH-12579") | ||
public void enhanceClassWithGenericReturnValueOnMappedSuperclass() { | ||
SimpleEntity implementation = new SimpleEntity(); | ||
|
||
implementation.setEntity( SimpleEntity.Type.ONE ); | ||
|
||
assertEquals( SimpleEntity.Type.ONE, implementation.getEntity() ); | ||
} | ||
|
||
@MappedSuperclass | ||
@Cache(usage = CacheConcurrencyStrategy.NONE) | ||
public static class AbstractMappedSuperclassWithGenericReturnValue<T extends Marker> { | ||
|
||
@Id | ||
@GeneratedValue | ||
public int id; | ||
|
||
@Access(AccessType.PROPERTY) | ||
private T entity; | ||
|
||
public T getEntity() { | ||
return entity; | ||
} | ||
|
||
public void setEntity(T entity) { | ||
this.entity = entity; | ||
} | ||
} | ||
|
||
public interface Marker { | ||
} | ||
|
||
@Entity | ||
@Cache(usage = CacheConcurrencyStrategy.NONE) | ||
public static class SimpleEntity extends AbstractMappedSuperclassWithGenericReturnValue<SimpleEntity.Type> { | ||
|
||
public enum Type implements Marker { | ||
ONE | ||
} | ||
} | ||
} |