-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-16040 New coercing assembler when types are different from expected
- Loading branch information
Showing
17 changed files
with
375 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...ate-core/src/main/java/org/hibernate/sql/results/graph/basic/CoercingResultAssembler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* 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.sql.results.graph.basic; | ||
|
||
import org.hibernate.sql.results.jdbc.spi.RowProcessingState; | ||
import org.hibernate.type.descriptor.converter.spi.BasicValueConverter; | ||
import org.hibernate.type.descriptor.java.JavaType; | ||
|
||
/** | ||
* A {@link BasicResultAssembler} which does type coercion to handle cases | ||
* where the expression type and the expected result {@link JavaType} are different | ||
* (e.g. same column mapped with differently typed properties). | ||
* | ||
* @author Marco Belladelli | ||
*/ | ||
public class CoercingResultAssembler<J> extends BasicResultAssembler<J> { | ||
public CoercingResultAssembler( | ||
int valuesArrayPosition, | ||
JavaType<J> assembledJavaType, | ||
BasicValueConverter<J, ?> valueConverter) { | ||
super( valuesArrayPosition, assembledJavaType, valueConverter ); | ||
} | ||
|
||
/** | ||
* Access to the row value, coerced to expected type | ||
*/ | ||
@Override | ||
public Object extractRawValue(RowProcessingState rowProcessingState) { | ||
return assembledJavaType.coerce( | ||
rowProcessingState.getJdbcValue( valuesArrayPosition ), | ||
rowProcessingState.getSession() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.