Verify array support: add 'EntityOfArrays' case to the GambitDomainModel and the PluralAttributeMappingTests
Signed-off-by: Koen Aers <koen.aers@gmail.com>
This commit is contained in:
parent
86fa0d5fed
commit
23f2cc584b
|
@ -12,6 +12,7 @@ import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
|||
import org.hibernate.metamodel.MappingMetamodel;
|
||||
|
||||
import org.hibernate.testing.orm.domain.StandardDomainModel;
|
||||
import org.hibernate.testing.orm.domain.gambit.EntityOfArrays;
|
||||
import org.hibernate.testing.orm.domain.gambit.EntityOfSets;
|
||||
import org.hibernate.testing.orm.domain.gambit.EntityOfMaps;
|
||||
import org.hibernate.testing.orm.domain.gambit.EntityOfLists;
|
||||
|
@ -35,6 +36,17 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
|||
@SuppressWarnings("WeakerAccess")
|
||||
public class PluralAttributeMappingTests {
|
||||
|
||||
@Test
|
||||
public void testArrays(SessionFactoryScope scope) {
|
||||
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
|
||||
final EntityMappingType containerEntityDescriptor = domainModel.getEntityDescriptor( EntityOfArrays.class );
|
||||
|
||||
assertThat( containerEntityDescriptor.getNumberOfAttributeMappings(), is( 2 ) );
|
||||
|
||||
final AttributeMapping arrayOfBasics = containerEntityDescriptor.findAttributeMapping( "arrayOfBasics" );
|
||||
assertThat( arrayOfBasics, notNullValue() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLists(SessionFactoryScope scope) {
|
||||
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
package org.hibernate.testing.orm.domain.gambit;
|
||||
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OrderColumn;
|
||||
|
||||
/**
|
||||
* @author Koen Aers
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Entity
|
||||
public class EntityOfArrays {
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
|
||||
private String[] arrayOfBasics;
|
||||
|
||||
|
||||
public EntityOfArrays() {
|
||||
}
|
||||
|
||||
public EntityOfArrays(Integer id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Id
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// arrayOfBasics
|
||||
|
||||
@ElementCollection
|
||||
@OrderColumn
|
||||
public String[] getArrayOfBasics() {
|
||||
return arrayOfBasics;
|
||||
}
|
||||
|
||||
public void setArrayOfBasics(String[] arrayOfBasics) {
|
||||
this.arrayOfBasics = arrayOfBasics;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,6 +19,7 @@ public class GambitDomainModel extends AbstractDomainModelDescriptor {
|
|||
BasicEntity.class,
|
||||
Component.class,
|
||||
EmbeddedIdEntity.class,
|
||||
EntityOfArrays.class,
|
||||
EntityOfBasics.class,
|
||||
EntityOfComposites.class,
|
||||
EntityOfDynamicComponent.class,
|
||||
|
|
Loading…
Reference in New Issue