Fix SqlResultSetMappingDescriptor generating ResultMemento for Embeddable attributes

This commit is contained in:
Andrea Boriero 2021-11-10 17:36:21 +01:00 committed by Christian Beikov
parent a771d035c9
commit 57f7e59e14
23 changed files with 38 additions and 28 deletions

View File

@ -29,6 +29,7 @@ import org.hibernate.metamodel.mapping.EntityDiscriminatorMapping;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.ModelPartContainer;
import org.hibernate.metamodel.mapping.internal.EmbeddedAttributeMapping;
import org.hibernate.query.NavigablePath;
import org.hibernate.query.internal.FetchMementoBasicStandard;
import org.hibernate.query.internal.FetchMementoEntityStandard;
@ -414,6 +415,10 @@ public class SqlResultSetMappingDescriptor implements NamedResultSetMappingDescr
subPart = ( (ModelPartContainer) subPart ).findSubPart( propertyPathParts[i], null );
}
return getFetchMemento( navigablePath, subPart );
}
private FetchMemento getFetchMemento(NavigablePath navigablePath, ModelPart subPart) {
if ( subPart instanceof BasicValuedModelPart ) {
assert columnNames.size() == 1;
final BasicValuedModelPart basicPart = (BasicValuedModelPart) subPart;
@ -423,8 +428,13 @@ public class SqlResultSetMappingDescriptor implements NamedResultSetMappingDescr
else if ( subPart instanceof EntityValuedFetchable ) {
return new FetchMementoEntityStandard( navigablePath, (EntityValuedFetchable) subPart, columnNames );
}
else if( subPart instanceof EmbeddedAttributeMapping ){
final ModelPart subPart1 = ( (EmbeddedAttributeMapping) subPart ).findSubPart( propertyPath.substring(
propertyPath.indexOf( "." ) + 1), null );
return getFetchMemento( navigablePath,subPart1 );
}
throw new NotYetImplementedFor6Exception(
"Only support for basic-valued model-parts have been implemented : " + propertyPath
"Only support for basic-valued, entity-valued and embedded model-parts have been implemented : " + propertyPath
+ " [" + subPart + "]"
);
}

View File

@ -4,7 +4,7 @@
* 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.test.idclass;
package org.hibernate.orm.test.idclass;
import java.io.Serializable;

View File

@ -4,7 +4,7 @@
* 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.test.mapping;
package org.hibernate.orm.test.mapping;
import java.util.Iterator;

View File

@ -4,7 +4,7 @@
* 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.test.mapping;
package org.hibernate.orm.test.mapping;
import static jakarta.persistence.CascadeType.ALL;

View File

@ -4,7 +4,7 @@
* 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.test.mapping;
package org.hibernate.orm.test.mapping;
import java.io.Serializable;

View File

@ -4,7 +4,7 @@
* 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.test.mapping;
package org.hibernate.orm.test.mapping;
import org.hibernate.testing.orm.junit.DomainModel;

View File

@ -4,7 +4,7 @@
* 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.test.mapping;
package org.hibernate.orm.test.mapping;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;

View File

@ -4,7 +4,7 @@
* 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.test.mapping;
package org.hibernate.orm.test.mapping;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;

View File

@ -4,7 +4,7 @@
* 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.test.mapping;
package org.hibernate.orm.test.mapping;
import java.io.Serializable;

View File

@ -4,7 +4,7 @@
* 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.test.mapping;
package org.hibernate.orm.test.mapping;
import java.io.Serializable;

View File

@ -4,7 +4,7 @@
* 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.test.mapping;
package org.hibernate.orm.test.mapping;
import static jakarta.persistence.CascadeType.ALL;
import static jakarta.persistence.FetchType.EAGER;

View File

@ -4,7 +4,7 @@
* 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.test.mapping.hhh14276;
package org.hibernate.orm.test.mapping.hhh14276;
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
@ -14,8 +14,8 @@ import org.hibernate.cfg.AvailableSettings;
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
import org.hibernate.query.sqm.mutation.internal.inline.InlineStrategy;
import org.hibernate.test.mapping.hhh14276.entity.PlayerStat;
import org.hibernate.test.mapping.hhh14276.entity.Score;
import org.hibernate.orm.test.mapping.hhh14276.entity.PlayerStat;
import org.hibernate.orm.test.mapping.hhh14276.entity.Score;
import org.hibernate.testing.TestForIssue;
import org.junit.Before;
import org.junit.Test;

View File

@ -4,7 +4,7 @@
* 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.test.mapping.hhh14276.entity;
package org.hibernate.orm.test.mapping.hhh14276.entity;
import java.io.Serializable;

View File

@ -4,7 +4,7 @@
* 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.test.mapping.hhh14276.entity;
package org.hibernate.orm.test.mapping.hhh14276.entity;
import java.io.Serializable;

View File

@ -4,7 +4,7 @@
* 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.test.mapping.hhh14276.entity;
package org.hibernate.orm.test.mapping.hhh14276.entity;
import java.io.Serializable;

View File

@ -4,7 +4,7 @@
* 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.test.mapping.hhh14276.entity;
package org.hibernate.orm.test.mapping.hhh14276.entity;
import java.io.Serializable;

View File

@ -4,15 +4,15 @@
* 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.test.mapping.hhh14343;
package org.hibernate.orm.test.mapping.hhh14343;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
import org.hibernate.query.sqm.mutation.internal.inline.InlineStrategy;
import org.hibernate.test.mapping.hhh14343.entity.NestedPlayerStat;
import org.hibernate.test.mapping.hhh14343.entity.NestedScore;
import org.hibernate.test.mapping.hhh14343.entity.NestedStat;
import org.hibernate.orm.test.mapping.hhh14343.entity.NestedPlayerStat;
import org.hibernate.orm.test.mapping.hhh14343.entity.NestedScore;
import org.hibernate.orm.test.mapping.hhh14343.entity.NestedStat;
import org.hibernate.testing.TestForIssue;
import org.junit.Before;
import org.junit.Test;

View File

@ -1,4 +1,4 @@
package org.hibernate.test.mapping.hhh14343.entity;
package org.hibernate.orm.test.mapping.hhh14343.entity;
import java.io.Serializable;

View File

@ -1,4 +1,4 @@
package org.hibernate.test.mapping.hhh14343.entity;
package org.hibernate.orm.test.mapping.hhh14343.entity;
import java.io.Serializable;

View File

@ -1,4 +1,4 @@
package org.hibernate.test.mapping.hhh14343.entity;
package org.hibernate.orm.test.mapping.hhh14343.entity;
import java.io.Serializable;

View File

@ -1,4 +1,4 @@
package org.hibernate.test.mapping.hhh14343.entity;
package org.hibernate.orm.test.mapping.hhh14343.entity;
import java.io.Serializable;

View File

@ -1,4 +1,4 @@
package org.hibernate.test.mapping.hhh14343.entity;
package org.hibernate.orm.test.mapping.hhh14343.entity;
import java.io.Serializable;

View File

@ -1,4 +1,4 @@
package org.hibernate.test.mapping.hhh14343.entity;
package org.hibernate.orm.test.mapping.hhh14343.entity;
import java.io.Serializable;