HHH-15379 Add test for issue

This commit is contained in:
Andrea Boriero 2022-06-30 12:03:47 +02:00 committed by Sanne Grinovero
parent d6f9b0b683
commit c553d35a86
4 changed files with 114 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package org.hibernate.orm.test.hbm.mappingexception;
public class Address {
private Long id;
private String details;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDetails() {
return details;
}
public void setDetails(String details) {
this.details = details;
}
}

View File

@ -0,0 +1,35 @@
package org.hibernate.orm.test.hbm.mappingexception;
import java.util.Set;
public class Employee {
private long id;
private boolean name;
private Set<Address> addresses;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public boolean isName() {
return name;
}
public void setName(boolean name) {
this.name = name;
}
public Set<Address> getAddresses() {
return addresses;
}
public void setAddresses(Set<Address> addresses) {
this.addresses = addresses;
}
}

View File

@ -0,0 +1,32 @@
package org.hibernate.orm.test.hbm.mappingexception;
import org.hibernate.MappingException;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.testing.TestForIssue;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class UnmappedCollectionExceptionTest {
@Test
@TestForIssue(jiraKey = "HHH-15379")
public void mappingExceptionTest() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
try {
assertThrows( MappingException.class, () -> {
new MetadataSources( ssr )
.addResource( "org/hibernate/orm/test/hbm/mappingexception/unmapped_collection.hbm.xml" )
.buildMetadata();
} );
}
finally {
ssr.close();
}
}
}

View File

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<!DOCTYPE hibernate-mapping SYSTEM "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="org.hibernate.orm.test.hbm.mappingexception">
<class name="Employee">
<id column="EMPLOYEE_ID" name="id">
<generator class="increment"/>
</id>
<property column="EMPLOYEE_NAME" name="name"/>
<!-- Address has not a hbm mapping -->
<set name="addresses">
<key column="EMPLOYEE_ID"/>
<many-to-many class="Address"/>
</set>
</class>
</hibernate-mapping>