HHH-15358 Add test for issue
This commit is contained in:
parent
ba48130c3f
commit
c39ccfd8eb
|
@ -0,0 +1,38 @@
|
|||
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
|
||||
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
|
||||
version="2.1">
|
||||
|
||||
<persistence-unit name="NullWhere">
|
||||
<description>
|
||||
Persistence unit for Hibernate User Guide
|
||||
</description>
|
||||
|
||||
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
|
||||
|
||||
<class>org.hibernate.orm.test.where.annotations.Nonce</class>
|
||||
|
||||
<properties>
|
||||
<property name="jakarta.persistence.jdbc.driver"
|
||||
value="org.h2.Driver" />
|
||||
|
||||
<property name="jakarta.persistence.jdbc.url"
|
||||
value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1" />
|
||||
|
||||
<property name="jakarta.persistence.jdbc.user"
|
||||
value="sa" />
|
||||
|
||||
<property name="jakarta.persistence.jdbc.password"
|
||||
value="" />
|
||||
|
||||
<property name="hibernate.show_sql"
|
||||
value="true" />
|
||||
|
||||
<property name="hibernate.hbm2ddl.auto"
|
||||
value="update" />
|
||||
</properties>
|
||||
|
||||
</persistence-unit>
|
||||
|
||||
</persistence>
|
|
@ -0,0 +1,54 @@
|
|||
package org.hibernate.orm.test.where.annotations;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.Jpa;
|
||||
import org.hibernate.testing.orm.junit.Setting;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
|
||||
@Jpa(
|
||||
annotatedClasses = NullWhereClauseTest.Person.class,
|
||||
properties = {
|
||||
@Setting(name = AvailableSettings.GLOBALLY_QUOTED_IDENTIFIERS, value = "true"),
|
||||
}
|
||||
)
|
||||
@TestForIssue(jiraKey = "HHH-15358")
|
||||
public class NullWhereClauseTest {
|
||||
|
||||
@Test
|
||||
public void testIt(EntityManagerFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
entityManager ->
|
||||
entityManager.persist( new Person( 1, "Andrea" ) )
|
||||
);
|
||||
}
|
||||
|
||||
@Entity
|
||||
@Table(name = "person")
|
||||
@Where(clause = "`used` IS NULL")
|
||||
public static class Person {
|
||||
@Id
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String used;
|
||||
|
||||
public Person() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Person(Integer id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue