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

HHH-18693 Hibernate Processor does not handle inner types #9098

Merged
Merged
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
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;

import org.hibernate.annotations.processing.Exclude;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.SessionFactory;
@@ -34,6 +35,7 @@
}
)
@SessionFactory
@Exclude
public class PersistentBagContainsTest {

/**
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
import jakarta.persistence.OneToMany;

import org.hibernate.Session;
import org.hibernate.annotations.processing.Exclude;
import org.hibernate.event.service.spi.EventListenerRegistry;
import org.hibernate.event.spi.EventType;
import org.hibernate.event.spi.PostInsertEvent;
@@ -31,6 +32,7 @@
* @author Gail Badner
*/
@JiraKey( value = "HHH-9979")
@Exclude
public class MergeListPreAndPostPersistTest extends BaseCoreFunctionalTestCase {

protected Class[] getAnnotatedClasses() {
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@

import java.util.List;

import org.hibernate.annotations.processing.Exclude;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.After;
import org.junit.Before;
@@ -24,6 +25,7 @@
/**
* @author Christian Beikov
*/
@Exclude
public class QuotedIdentifierTest extends BaseCoreFunctionalTestCase {

private Person person;
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
import jakarta.persistence.Entity;
import jakarta.persistence.Id;

import org.hibernate.annotations.processing.Exclude;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
@@ -36,6 +37,7 @@
import static org.junit.Assert.assertThat;

@JiraKey(value = "HHH-13788")
@Exclude
public class SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseAndQuotedNameTest {

private File updateOutputFile;
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.processor.test.data.innerclass;

import jakarta.persistence.Embeddable;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.NamedQuery;

public class Dummy {
@Entity(name = "Inner")
@NamedQuery(name = "allInner", query = "from Inner")
public static class Inner extends Persona {
@Id
Integer id;

String name;

public Integer getId() {
return id;
}

@Override
public void setId(Integer id) {
this.id = id;
}

@Override
public String getName() {
return name;
}

@Override
public void setName(String name) {
this.name = name;
}
}

@Embeddable
public static class DummyEmbeddable {
private String name;
private int value;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getValue() {
return value;
}

public void setValue(int value) {
this.value = value;
}
}

@MappedSuperclass
public abstract static class Persona {
private String city;

public String getCity() {
return city;
}

public void setCity(String city) {
this.city = city;
}

public abstract void setId(Integer id);

public abstract String getName();

public abstract void setName(String name);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.processor.test.data.innerclass;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.NamedQuery;
import org.hibernate.processor.test.data.innerclass.InnerClassTest.One.Two;
import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;

import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.assertNoMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;
import static org.junit.Assert.assertEquals;

public class InnerClassTest extends CompilationTest {

@WithClasses({Person.class, Dummy.class, Inner.class, Two.class})
@Test
public void test() {
System.out.println( getMetaModelSourceAsString( InnerClassTest.class ) );
System.out.println( getMetaModelSourceAsString( Dummy.class ) );
System.out.println( getMetaModelSourceAsString( Person.class ) );
System.out.println( getMetaModelSourceAsString( InnerClassTest.class, true ) );
System.out.println( getMetaModelSourceAsString( Dummy.class, true ) );
System.out.println( getMetaModelSourceAsString( Person.class, true ) );
assertEquals(
getMetaModelSourceAsString( Inner.class ),
getMetaModelSourceAsString( Two.class )
);
assertEquals(
getMetaModelSourceAsString( Inner.class, true ),
getMetaModelSourceAsString( Two.class, true )
);
assertMetamodelClassGeneratedFor( Inner.class );
assertMetamodelClassGeneratedFor( Inner.class, true );
assertMetamodelClassGeneratedFor( Two.class );
assertMetamodelClassGeneratedFor( Two.class, true );
assertMetamodelClassGeneratedFor( Dummy.Inner.class );
assertMetamodelClassGeneratedFor( Dummy.Inner.class, true );
assertMetamodelClassGeneratedFor( Person.class );
assertMetamodelClassGeneratedFor( Person.class, true );
assertMetamodelClassGeneratedFor( Person.PersonId.class );
assertNoMetamodelClassGeneratedFor( Dummy.class );
assertMetamodelClassGeneratedFor( Dummy.DummyEmbeddable.class );
/*assertNoMetamodelClassGeneratedFor( Dummy.class );*/
}

@Entity(name = "Inner")
@NamedQuery(name = "allInner", query = "from Inner")
public static class Inner {
@Id
Integer id;

String address;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}
}

static class One {
@Entity
static class Two {
@Id
Integer id;
String value;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.processor.test.data.innerclass;

import jakarta.persistence.Embeddable;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;

/**
* @author Hardy Ferentschik
*/
@Entity
public class Person {
@EmbeddedId
private PersonId id;

private String address;

@Embeddable
public static class PersonId {
private String name;
private String snn;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getSnn() {
return snn;
}

public void setSnn(String snn) {
this.snn = snn;
}
}


}
Loading