HHH-14885 - New composite user-type
HHH-14950 - Support mapping of embeddables with no setters (assuming a custom instantiator or repo-strategy is used) Tests illustrating that HHH-14950 does indeed happen
This commit is contained in:
parent
4b69854b9c
commit
e06a3dcdbc
|
@ -6,13 +6,13 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.mapping.embeddable.strategy.instantiator.intf;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.hibernate.mapping.Collection;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.Property;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.DomainModelScope;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.NotImplementedYet;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
|
@ -21,11 +21,15 @@ import org.junit.jupiter.api.Test;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
* Builds on {@link org.hibernate.orm.test.mapping.embeddable.strategy.instantiator.intf2.InstantiationTests}
|
||||
* attempting to map an interface.
|
||||
*
|
||||
* At the moment this does not work, as Hibernate fails without setters
|
||||
*/
|
||||
@DomainModel( annotatedClasses = { Person.class, NameImpl.class } )
|
||||
@SessionFactory
|
||||
@NotImplementedYet( strict = false )
|
||||
@NotImplementedYet( reason = "Hibernate requires setter" )
|
||||
@JiraKey( "HHH-14950" )
|
||||
public class InstantiationTests {
|
||||
@Test
|
||||
public void modelTest(DomainModelScope scope) {
|
||||
|
@ -33,6 +37,10 @@ public class InstantiationTests {
|
|||
final Property name = personMapping.getProperty( "name" );
|
||||
final Component nameMapping = (Component) name.getValue();
|
||||
assertThat( nameMapping.getPropertySpan() ).isEqualTo( 2 );
|
||||
|
||||
final Property aliases = personMapping.getProperty( "aliases" );
|
||||
final Component aliasMapping = (Component) ( (Collection) aliases.getValue() ).getElement();
|
||||
assertThat( aliasMapping.getPropertySpan() ).isEqualTo( 2 );
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -6,17 +6,10 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.mapping.embeddable.strategy.instantiator.intf;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Embeddable;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Embeddable
|
||||
public interface Name {
|
||||
@Basic
|
||||
String getFirstName();
|
||||
|
||||
@Basic
|
||||
String getLastName();
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import java.util.Set;
|
|||
|
||||
import org.hibernate.annotations.EmbeddableInstantiator;
|
||||
|
||||
import jakarta.persistence.Access;
|
||||
import jakarta.persistence.AccessType;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.Embedded;
|
||||
import jakarta.persistence.Entity;
|
||||
|
@ -24,12 +26,16 @@ import jakarta.persistence.Table;
|
|||
public class Person {
|
||||
@Id
|
||||
public Integer id;
|
||||
|
||||
@Embedded
|
||||
@EmbeddableInstantiator( NameInstantiator.class )
|
||||
@Access( AccessType.PROPERTY )
|
||||
public Name name;
|
||||
|
||||
@ElementCollection
|
||||
@Embedded
|
||||
@EmbeddableInstantiator( NameInstantiator.class )
|
||||
@Access( AccessType.PROPERTY )
|
||||
public Set<Name> aliases;
|
||||
|
||||
//end::embeddable-instantiator-property[]
|
||||
|
|
|
@ -12,6 +12,8 @@ import org.hibernate.mapping.Property;
|
|||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.DomainModelScope;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.NotImplementedYet;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -28,6 +30,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*/
|
||||
@DomainModel( annotatedClasses = { Person.class, Name.class } )
|
||||
@SessionFactory
|
||||
@NotImplementedYet( reason = "Hibernate requires setter" )
|
||||
@JiraKey( "HHH-14950" )
|
||||
public class InstantiationTests {
|
||||
@Test
|
||||
public void modelTest(DomainModelScope scope) {
|
||||
|
|
Loading…
Reference in New Issue