-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix hbm.xml builds with CompositeAttributes
- Loading branch information
Showing
6 changed files
with
132 additions
and
1 deletion.
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
52 changes: 52 additions & 0 deletions
52
...-orm/deployment/src/test/java/io/quarkus/hibernate/orm/xml/hbm/HbmXmlComplexFileTest.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,52 @@ | ||
package io.quarkus.hibernate.orm.xml.hbm; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import javax.inject.Inject; | ||
import javax.persistence.EntityManager; | ||
import javax.persistence.EntityManagerFactory; | ||
import javax.transaction.Transactional; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.hibernate.orm.SchemaUtil; | ||
import io.quarkus.hibernate.orm.SmokeTestUtils; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class HbmXmlComplexFileTest { | ||
@RegisterExtension | ||
final static QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.withApplicationRoot(jar -> jar | ||
.addClass(SmokeTestUtils.class) | ||
.addClass(SchemaUtil.class) | ||
.addClass(NonAnnotatedComplexEntity.class) | ||
.addClass(NonAnnotatedComponentEntity.class) | ||
.addAsResource("application-mapping-files-my-complex-hbm-xml.properties", "application.properties") | ||
.addAsResource("META-INF/hbm-complex.xml", "my-complex-hbm.xml")); | ||
|
||
@Inject | ||
EntityManagerFactory entityManagerFactory; | ||
|
||
@Inject | ||
EntityManager entityManager; | ||
|
||
@Test | ||
@Transactional | ||
public void ormXmlTakenIntoAccount() { | ||
assertThat(SchemaUtil.getColumnNames(entityManagerFactory, NonAnnotatedComplexEntity.class)) | ||
.contains("thename") | ||
.doesNotContain("name"); | ||
assertThat(SchemaUtil.getColumnNames(entityManagerFactory, NonAnnotatedComplexEntity.class)) | ||
.contains("value"); | ||
} | ||
|
||
@Test | ||
@Transactional | ||
public void smokeTest() { | ||
SmokeTestUtils.testSimplePersistRetrieveUpdateDelete(entityManager, | ||
NonAnnotatedComplexEntity.class, NonAnnotatedComplexEntity::new, | ||
NonAnnotatedComplexEntity::getId, NonAnnotatedComplexEntity::setName, NonAnnotatedComplexEntity::getName); | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
.../deployment/src/test/java/io/quarkus/hibernate/orm/xml/hbm/NonAnnotatedComplexEntity.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,41 @@ | ||
package io.quarkus.hibernate.orm.xml.hbm; | ||
|
||
public class NonAnnotatedComplexEntity { | ||
|
||
private long id; | ||
|
||
private String name; | ||
|
||
private NonAnnotatedComponentEntity value; | ||
|
||
public NonAnnotatedComplexEntity() { | ||
} | ||
|
||
public NonAnnotatedComplexEntity(String name) { | ||
this.name = name; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public NonAnnotatedComponentEntity getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(NonAnnotatedComponentEntity value) { | ||
this.value = value; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...eployment/src/test/java/io/quarkus/hibernate/orm/xml/hbm/NonAnnotatedComponentEntity.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,14 @@ | ||
package io.quarkus.hibernate.orm.xml.hbm; | ||
|
||
public class NonAnnotatedComponentEntity { | ||
|
||
private String value; | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
extensions/hibernate-orm/deployment/src/test/resources/META-INF/hbm-complex.xml
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE hibernate-mapping PUBLIC | ||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN" | ||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> | ||
<hibernate-mapping> | ||
<class name="io.quarkus.hibernate.orm.xml.hbm.NonAnnotatedComplexEntity"> | ||
<id name="id"> | ||
<generator class="identity"/> | ||
</id> | ||
<property name="name" column="thename"/> | ||
<component name="value" class="io.quarkus.hibernate.orm.xml.hbm.NonAnnotatedComponentEntity" lazy="false"> | ||
<property name="value"> | ||
<column name="value"/> | ||
</property> | ||
</component> | ||
</class> | ||
</hibernate-mapping> |
7 changes: 7 additions & 0 deletions
7
...orm/deployment/src/test/resources/application-mapping-files-my-complex-hbm-xml.properties
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,7 @@ | ||
quarkus.datasource.db-kind=h2 | ||
quarkus.datasource.jdbc.url=jdbc:h2:mem:test | ||
|
||
quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect | ||
#quarkus.hibernate-orm.log.sql=true | ||
quarkus.hibernate-orm.database.generation=drop-and-create | ||
quarkus.hibernate-orm.mapping-files=my-complex-hbm.xml |