-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Continue support for XML complete mappings - inheritance
- Loading branch information
Showing
9 changed files
with
263 additions
and
7 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
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
76 changes: 76 additions & 0 deletions
76
...-orm/src/test/java/org/hibernate/models/orm/xml/complete/CompleteXmlInheritanceTests.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,76 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright: Red Hat Inc. and Hibernate Authors | ||
*/ | ||
package org.hibernate.models.orm.xml.complete; | ||
|
||
import org.hibernate.models.orm.internal.ManagedResourcesImpl; | ||
import org.hibernate.models.orm.spi.AttributeMetadata; | ||
import org.hibernate.models.orm.spi.EntityHierarchy; | ||
import org.hibernate.models.orm.spi.EntityTypeMetadata; | ||
import org.hibernate.models.orm.spi.ManagedResources; | ||
import org.hibernate.models.orm.spi.ProcessResult; | ||
import org.hibernate.models.orm.spi.Processor; | ||
import org.hibernate.models.source.SourceModelTestHelper; | ||
import org.hibernate.models.source.internal.SourceModelBuildingContextImpl; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import org.jboss.jandex.Index; | ||
|
||
import jakarta.persistence.Id; | ||
|
||
import static jakarta.persistence.InheritanceType.JOINED; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.hibernate.models.internal.SimpleClassLoading.SIMPLE_CLASS_LOADING; | ||
|
||
/** | ||
* @author Steve Ebersole | ||
*/ | ||
public class CompleteXmlInheritanceTests { | ||
@Test | ||
void testIt() { | ||
|
||
final ManagedResourcesImpl.Builder managedResourcesBuilder = new ManagedResourcesImpl.Builder(); | ||
managedResourcesBuilder.addXmlMappings( "mappings/complete/simple-inherited.xml" ); | ||
final ManagedResources managedResources = managedResourcesBuilder.build(); | ||
|
||
final Index jandexIndex = SourceModelTestHelper.buildJandexIndex( | ||
SIMPLE_CLASS_LOADING, | ||
Root.class, | ||
Sub.class | ||
); | ||
final SourceModelBuildingContextImpl buildingContext = SourceModelTestHelper.createBuildingContext( | ||
jandexIndex, | ||
SIMPLE_CLASS_LOADING | ||
); | ||
|
||
final ProcessResult processResult = Processor.process( | ||
managedResources, | ||
null, | ||
new Processor.Options() { | ||
@Override | ||
public boolean areGeneratorsGlobal() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean shouldIgnoreUnlistedClasses() { | ||
return false; | ||
} | ||
}, | ||
buildingContext | ||
); | ||
|
||
assertThat( processResult.getEntityHierarchies() ).hasSize( 1 ); | ||
final EntityHierarchy hierarchy = processResult.getEntityHierarchies().iterator().next(); | ||
assertThat( hierarchy.getInheritanceType() ).isEqualTo( JOINED ); | ||
|
||
final EntityTypeMetadata rootMetadata = hierarchy.getRoot(); | ||
assertThat( rootMetadata.getClassDetails().getClassName() ).isEqualTo( Root.class.getName() ); | ||
final AttributeMetadata idAttr = rootMetadata.findAttribute( "id" ); | ||
assertThat( idAttr.getMember().getAnnotationUsage( Id.class ) ).isNotNull(); | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
hibernate-models-orm/src/test/java/org/hibernate/models/orm/xml/complete/Root.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 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright: Red Hat Inc. and Hibernate Authors | ||
*/ | ||
package org.hibernate.models.orm.xml.complete; | ||
|
||
/** | ||
* @author Steve Ebersole | ||
*/ | ||
public class Root { | ||
private Integer id; | ||
private String name; | ||
|
||
protected Root() { | ||
// for Hibernate use | ||
} | ||
|
||
public Root(Integer id, String name) { | ||
this.id = id; | ||
this.name = name; | ||
} | ||
|
||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
hibernate-models-orm/src/test/java/org/hibernate/models/orm/xml/complete/Sub.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,31 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright: Red Hat Inc. and Hibernate Authors | ||
*/ | ||
package org.hibernate.models.orm.xml.complete; | ||
|
||
/** | ||
* @author Steve Ebersole | ||
*/ | ||
public class Sub extends Root { | ||
private String subName; | ||
|
||
protected Sub() { | ||
// for Hibernate use | ||
} | ||
|
||
public Sub(Integer id, String name, String subName) { | ||
super( id, name ); | ||
this.subName = subName; | ||
} | ||
|
||
public String getSubName() { | ||
return subName; | ||
} | ||
|
||
public void setSubName(String subName) { | ||
this.subName = subName; | ||
} | ||
} |
Oops, something went wrong.