reproducer of HHH-18677
This commit is contained in:
parent
d94a2a7ea9
commit
13c8f809af
|
@ -0,0 +1,35 @@
|
|||
package org.hibernate.orm.test.jpa;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.DiscriminatorColumn;
|
||||
import jakarta.persistence.DiscriminatorValue;
|
||||
import jakarta.persistence.Embedded;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Inheritance;
|
||||
import jakarta.persistence.InheritanceType;
|
||||
|
||||
@Entity
|
||||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
||||
@DiscriminatorColumn(name="type")
|
||||
@DiscriminatorValue("MAIN")
|
||||
public class Book {
|
||||
@Id
|
||||
public String isbn;
|
||||
|
||||
public String title;
|
||||
|
||||
@Column(insertable = false, updatable = false, nullable = false)
|
||||
protected String type;
|
||||
|
||||
@Embedded
|
||||
public EmbeddedDataColumn myData;
|
||||
|
||||
public Book() {
|
||||
}
|
||||
|
||||
public Book(String isbn, String title) {
|
||||
this.isbn = isbn;
|
||||
this.title = title;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.hibernate.orm.test.jpa;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Embeddable;
|
||||
|
||||
@Embeddable
|
||||
public class EmbeddedDataColumn {
|
||||
|
||||
@Column
|
||||
public String embeddedData = null;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package org.hibernate.orm.test.jpa;
|
||||
|
||||
import jakarta.persistence.DiscriminatorValue;
|
||||
import jakarta.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
@DiscriminatorValue("SUB")
|
||||
public class SubBook extends Book {
|
||||
|
||||
public SubBook() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SubBook(String isbn, String title) {
|
||||
super(isbn, title);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package org.hibernate.orm.test.jpa;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Embeddable;
|
||||
|
||||
@Embeddable
|
||||
public class ValueEmbeddedDataColumn<T> extends EmbeddedDataColumn {
|
||||
@Column
|
||||
public T myvalue;
|
||||
}
|
|
@ -36,8 +36,12 @@ import org.hibernate.dialect.PostgresPlusDialect;
|
|||
import org.hibernate.dialect.SybaseDialect;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.orm.test.jpa.Book;
|
||||
import org.hibernate.orm.test.jpa.Distributor;
|
||||
import org.hibernate.orm.test.jpa.EmbeddedDataColumn;
|
||||
import org.hibernate.orm.test.jpa.Item;
|
||||
import org.hibernate.orm.test.jpa.SubBook;
|
||||
import org.hibernate.orm.test.jpa.ValueEmbeddedDataColumn;
|
||||
import org.hibernate.orm.test.jpa.Wallet;
|
||||
import org.hibernate.stat.Statistics;
|
||||
|
||||
|
@ -70,7 +74,11 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
|||
Distributor.class,
|
||||
Wallet.class,
|
||||
Employee.class,
|
||||
Contractor.class
|
||||
Contractor.class,
|
||||
Book.class,
|
||||
SubBook.class,
|
||||
EmbeddedDataColumn.class,
|
||||
ValueEmbeddedDataColumn.class,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1658,4 +1666,24 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
|||
entityManager.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-18236")
|
||||
public void test18236() {
|
||||
EntityManager em = getOrCreateEntityManager();
|
||||
try {
|
||||
em.getTransaction().begin();
|
||||
em.persist( new Book("9781932394153", "Hibernate in Action") );
|
||||
em.flush();
|
||||
|
||||
List results = em.createNativeQuery("select b.* from book b", Book.class).getResultList();
|
||||
assertEquals(1, results.size());
|
||||
}
|
||||
finally {
|
||||
em.getTransaction().rollback();
|
||||
em.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue