mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 00:24:57 +00:00
HHH-17745 @HQL methods accepting embeddables
and replace usages of getJavaType().getTypeName(), since using getTypeName() directly is much more freindly to the annotation processor (as well as less verbose)
This commit is contained in:
parent
eb11676479
commit
f1e099b8e8
@ -66,9 +66,9 @@ public void bind(
|
||||
if ( !parameterJtd.getJavaTypeClass().equals( tenantIdTypeJtd.getJavaTypeClass() ) ) {
|
||||
throw new MappingException(
|
||||
"all @TenantId fields must have the same type: "
|
||||
+ parameterJtd.getJavaType().getTypeName()
|
||||
+ parameterJtd.getTypeName()
|
||||
+ " differs from "
|
||||
+ tenantIdTypeJtd.getJavaType().getTypeName()
|
||||
+ tenantIdTypeJtd.getTypeName()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public TypeDefinition resolveAutoApplied(BasicJavaType<?> jtd) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return typeDefinitionMap.get( jtd.getJavaType().getTypeName() );
|
||||
return typeDefinitionMap.get( jtd.getTypeName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -782,11 +782,11 @@ private static JdbcMapping resolveAttributeConverter(Class<AttributeConverter<?,
|
||||
new JpaAttributeConverterImpl( bean, converterJtd, domainJtd, relationalJtd );
|
||||
return new ConvertedBasicTypeImpl<>(
|
||||
ConverterDescriptor.TYPE_NAME_PREFIX
|
||||
+ valueConverter.getConverterJavaType().getJavaType().getTypeName(),
|
||||
+ valueConverter.getConverterJavaType().getTypeName(),
|
||||
String.format(
|
||||
"BasicType adapter for AttributeConverter<%s,%s>",
|
||||
domainJtd.getJavaType().getTypeName(),
|
||||
relationalJtd.getJavaType().getTypeName()
|
||||
domainJtd.getTypeName(),
|
||||
relationalJtd.getTypeName()
|
||||
),
|
||||
relationalJtd.getRecommendedJdbcType( typeConfiguration.getCurrentBaseSqlTypeIndicators() ),
|
||||
valueConverter
|
||||
|
@ -200,11 +200,11 @@ public NamedConverterResolution(
|
||||
|
||||
this.legacyResolvedType = new CustomMutabilityConvertedBasicTypeImpl<>(
|
||||
ConverterDescriptor.TYPE_NAME_PREFIX
|
||||
+ valueConverter.getConverterJavaType().getJavaType().getTypeName(),
|
||||
+ valueConverter.getConverterJavaType().getTypeName(),
|
||||
String.format(
|
||||
"BasicType adapter for AttributeConverter<%s,%s>",
|
||||
domainJtd.getJavaType().getTypeName(),
|
||||
relationalJtd.getJavaType().getTypeName()
|
||||
domainJtd.getTypeName(),
|
||||
relationalJtd.getTypeName()
|
||||
),
|
||||
jdbcType,
|
||||
valueConverter,
|
||||
|
@ -91,7 +91,7 @@ else if ( byte[].class.isAssignableFrom( type.getReturnedClass() ) ) {
|
||||
valueTransformer = UUIDJavaType.ToBytesTransformer.INSTANCE;
|
||||
}
|
||||
else {
|
||||
throw new HibernateException( "Unanticipated return type [" + type.getReturnedClass().getName() + "] for UUID conversion" );
|
||||
throw new HibernateException( "Unanticipated return type [" + type.getReturnedClassName() + "] for UUID conversion" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -772,11 +772,11 @@ public Dialect getDialect() {
|
||||
// todo : cache the AttributeConverterTypeAdapter in case that AttributeConverter is applied multiple times.
|
||||
return new ConvertedBasicTypeImpl<>(
|
||||
TYPE_NAME_PREFIX
|
||||
+ jpaAttributeConverter.getConverterJavaType().getJavaType().getTypeName(),
|
||||
+ jpaAttributeConverter.getConverterJavaType().getTypeName(),
|
||||
String.format(
|
||||
"BasicType adapter for AttributeConverter<%s,%s>",
|
||||
domainJavaType.getJavaType().getTypeName(),
|
||||
relationalJavaType.getJavaType().getTypeName()
|
||||
domainJavaType.getTypeName(),
|
||||
relationalJavaType.getTypeName()
|
||||
),
|
||||
metadata.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( jdbcTypeCode ),
|
||||
jpaAttributeConverter
|
||||
|
@ -153,7 +153,7 @@ else if ( bootAttributeDescriptor instanceof IndexBackref ) {
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"Could not resolve PropertyAccess for attribute `%s#%s`",
|
||||
getEmbeddableJavaType().getJavaType().getTypeName(),
|
||||
getEmbeddableJavaType().getTypeName(),
|
||||
bootAttributeDescriptor.getName()
|
||||
)
|
||||
);
|
||||
|
@ -330,7 +330,7 @@ else if ( bootAttributeDescriptor instanceof IndexBackref ) {
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"Could not resolve PropertyAccess for attribute `%s#%s`",
|
||||
mappedJtd.getJavaType().getTypeName(),
|
||||
mappedJtd.getTypeName(),
|
||||
bootAttributeDescriptor.getName()
|
||||
)
|
||||
);
|
||||
|
@ -141,7 +141,7 @@ public void validateInternalForm(Object naturalIdValue) {
|
||||
"Incoming natural-id value [%s (`%s`)] is not of expected type [`%s`] and could not be coerced",
|
||||
naturalIdValue,
|
||||
naturalIdValueClass.getName(),
|
||||
getJavaType().getJavaType().getTypeName()
|
||||
getJavaType().getTypeName()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -592,7 +592,7 @@ private static SelectablePath findBidirectionalOneToManyAttributeName(
|
||||
final Collection collection = (Collection) value;
|
||||
if ( propertyPath.equals( collection.getMappedByProperty() )
|
||||
&& collection.getElement().getType().getName()
|
||||
.equals( declaringType.getJavaType().getJavaType().getTypeName() ) ) {
|
||||
.equals( declaringType.getJavaType().getTypeName() ) ) {
|
||||
return parentSelectablePath == null
|
||||
? SelectablePath.parse( property.getName() )
|
||||
: parentSelectablePath.append( property.getName() );
|
||||
@ -627,7 +627,7 @@ else if ( value instanceof OneToOne ) {
|
||||
if (declaringTableGroupProducer.getNavigableRole().getLocalName().equals( oneToOne.getReferencedEntityName() )
|
||||
&& propertyPath.equals( oneToOne.getMappedByProperty() )
|
||||
&& oneToOne.getReferencedEntityName()
|
||||
.equals( declaringType.getJavaType().getJavaType().getTypeName() ) ) {
|
||||
.equals( declaringType.getJavaType().getTypeName() ) ) {
|
||||
return parentSelectablePath == null
|
||||
? SelectablePath.parse( property.getName() )
|
||||
: parentSelectablePath.append( property.getName() );
|
||||
@ -1466,13 +1466,13 @@ class Level3 {
|
||||
|
||||
where leve2Child is of type DerivedLevel2 while level2Parent of type Level2
|
||||
|
||||
for this reason we need the check entityMappingType.isSubclassEntityName( partMappingType.getMappedJavaType().getJavaType().getTypeName() )
|
||||
for this reason we need the check entityMappingType.isSubclassEntityName( partMappingType.getMappedJavaType().getTypeName() )
|
||||
to be sure that the referencedNavigablePath corresponds to leve2Child
|
||||
|
||||
*/
|
||||
while ( !( partMappingType instanceof EntityMappingType )
|
||||
|| ( partMappingType != entityMappingType
|
||||
&& !entityMappingType.getEntityPersister().isSubclassEntityName( partMappingType.getMappedJavaType().getJavaType().getTypeName() )
|
||||
&& !entityMappingType.getEntityPersister().isSubclassEntityName( partMappingType.getMappedJavaType().getTypeName() )
|
||||
&& !( (EntityMappingType) partMappingType ).getEntityPersister().isSubclassEntityName( entityMappingType.getEntityName() ) ) ) {
|
||||
referencedNavigablePath = referencedNavigablePath.getParent();
|
||||
if ( referencedNavigablePath == null ) {
|
||||
|
@ -15,7 +15,6 @@
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
|
||||
import jakarta.persistence.metamodel.SingularAttribute;
|
||||
import jakarta.persistence.metamodel.Type;
|
||||
|
||||
/**
|
||||
* Implementation of {@link jakarta.persistence.metamodel.EmbeddableType}.
|
||||
@ -33,7 +32,7 @@ public EmbeddableTypeImpl(
|
||||
JavaType<J> javaType,
|
||||
boolean isDynamic,
|
||||
JpaMetamodelImplementor domainMetamodel) {
|
||||
super( javaType.getJavaType().getTypeName(), javaType, null, domainMetamodel );
|
||||
super( javaType.getTypeName(), javaType, null, domainMetamodel );
|
||||
this.isDynamic = isDynamic;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public MappedSuperclassTypeImpl(
|
||||
IdentifiableDomainType<? super J> superType,
|
||||
JpaMetamodelImplementor jpaMetamodel) {
|
||||
this(
|
||||
javaType.getJavaType().getTypeName(),
|
||||
javaType.getTypeName(),
|
||||
mappedSuperclass.getDeclaredIdentifierMapper() != null
|
||||
|| superType != null && superType.hasIdClass(),
|
||||
mappedSuperclass.hasIdentifierProperty(),
|
||||
|
@ -6087,15 +6087,11 @@ public ModelPart findSubPart(String name, EntityMappingType treatTargetType) {
|
||||
Locale.ROOT,
|
||||
"Could not resolve attribute '%s' of '%s' due to the attribute being declared in multiple subtypes '%s' and '%s'",
|
||||
name,
|
||||
getJavaType().getJavaType().getTypeName(),
|
||||
getJavaType().getTypeName(),
|
||||
attribute.asAttributeMapping().getDeclaringType()
|
||||
.getJavaType()
|
||||
.getJavaType()
|
||||
.getTypeName(),
|
||||
.getJavaType().getTypeName(),
|
||||
subDefinedAttribute.asAttributeMapping().getDeclaringType()
|
||||
.getJavaType()
|
||||
.getJavaType()
|
||||
.getTypeName()
|
||||
.getJavaType().getTypeName()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -405,8 +405,8 @@ private void verifyInsertTypesMatch(
|
||||
// throw new SemanticException(
|
||||
// String.format(
|
||||
// "Expected insert attribute type [%s] did not match Query selection type [%s] at selection index [%d]",
|
||||
// insertionTargetPaths.get( i ).getJavaTypeDescriptor().getJavaType().getTypeName(),
|
||||
// expression.getNodeJavaType().getJavaType().getTypeName(),
|
||||
// insertionTargetPaths.get( i ).getJavaTypeDescriptor().getTypeName(),
|
||||
// expression.getNodeJavaType().getTypeName(),
|
||||
// i
|
||||
// ),
|
||||
// hqlString,
|
||||
|
@ -117,7 +117,7 @@ public Set<EntityDomainType<?>> getImplementors() {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return polymorphicJavaType.getJavaType().getTypeName();
|
||||
return polymorphicJavaType.getTypeName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -100,7 +100,7 @@ public SemanticPathPart resolvePathPart(
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"Static enum reference [%s#%s] cannot be de-referenced",
|
||||
referencedEnumTypeDescriptor.getJavaType().getTypeName(),
|
||||
referencedEnumTypeDescriptor.getTypeName(),
|
||||
enumValueName
|
||||
)
|
||||
);
|
||||
@ -115,7 +115,7 @@ public SqmPath<?> resolveIndexedAccess(
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"Static enum reference [%s#%s] cannot be de-referenced",
|
||||
referencedEnumTypeDescriptor.getJavaType().getTypeName(),
|
||||
referencedEnumTypeDescriptor.getTypeName(),
|
||||
enumValueName
|
||||
)
|
||||
);
|
||||
|
@ -243,7 +243,7 @@ public SemanticPathPart resolvePathPart(
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"Static field reference [%s#%s] cannot be de-referenced",
|
||||
fieldJavaType.getJavaType().getTypeName(),
|
||||
fieldJavaType.getTypeName(),
|
||||
fieldName
|
||||
)
|
||||
);
|
||||
@ -258,7 +258,7 @@ public SqmPath<?> resolveIndexedAccess(
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"Static field reference [%s#%s] cannot be de-referenced",
|
||||
fieldJavaType.getJavaType().getTypeName(),
|
||||
fieldJavaType.getTypeName(),
|
||||
fieldName
|
||||
)
|
||||
);
|
||||
|
@ -68,7 +68,7 @@ public J assemble(
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"Expecting raw JDBC value of type `%s`, but found `%s` : [%s]",
|
||||
valueConverter.getRelationalJavaType().getJavaType().getTypeName(),
|
||||
valueConverter.getRelationalJavaType().getTypeName(),
|
||||
jdbcValue.getClass().getName(),
|
||||
jdbcValue
|
||||
)
|
||||
|
@ -90,7 +90,7 @@ public List<DynamicInstantiationArgument> getArguments() {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DynamicInstantiation(" + getTargetJavaType().getJavaType().getTypeName() + ")";
|
||||
return "DynamicInstantiation(" + getTargetJavaType().getTypeName() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -94,7 +94,7 @@ public T assemble(RowProcessingState rowProcessingState, JdbcValuesSourceProcess
|
||||
catch ( NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException
|
||||
| java.lang.InstantiationException e ) {
|
||||
throw new InstantiationException( "Error instantiating class '"
|
||||
+ target.getJavaType().getTypeName() + "' using default constructor: " + e.getMessage(), e );
|
||||
+ target.getTypeName() + "' using default constructor: " + e.getMessage(), e );
|
||||
}
|
||||
for ( BeanInjection beanInjection : beanInjections ) {
|
||||
final Object assembled = beanInjection.getValueAssembler().assemble( rowProcessingState, options );
|
||||
|
@ -180,20 +180,20 @@ private DomainResultAssembler<R> assembler(
|
||||
if ( log.isDebugEnabled() ) {
|
||||
log.debugf(
|
||||
"Could not locate appropriate constructor for dynamic instantiation of [%s]; attempting bean-injection instantiation",
|
||||
javaType.getJavaType().getTypeName()
|
||||
javaType.getTypeName()
|
||||
);
|
||||
}
|
||||
|
||||
if ( !areAllArgumentsAliased) {
|
||||
throw new IllegalStateException(
|
||||
"Cannot instantiate class '" + javaType.getJavaType().getTypeName() + "'"
|
||||
"Cannot instantiate class '" + javaType.getTypeName() + "'"
|
||||
+ " (it has no constructor with signature " + signature()
|
||||
+ ", and not every argument has an alias)"
|
||||
);
|
||||
}
|
||||
if ( !duplicatedAliases.isEmpty() ) {
|
||||
throw new IllegalStateException(
|
||||
"Cannot instantiate class '" + javaType.getJavaType().getTypeName() + "'"
|
||||
"Cannot instantiate class '" + javaType.getTypeName() + "'"
|
||||
+ " (it has no constructor with signature " + signature()
|
||||
+ ", and has arguments with duplicate aliases ["
|
||||
+ StringHelper.join( ",", duplicatedAliases) + "])"
|
||||
@ -205,7 +205,7 @@ private DomainResultAssembler<R> assembler(
|
||||
|
||||
private List<String> signature() {
|
||||
return argumentResults.stream()
|
||||
.map( adt -> adt.getResultJavaType().getJavaType().getTypeName() )
|
||||
.map( adt -> adt.getResultJavaType().getTypeName() )
|
||||
.collect( toList() );
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
||||
@Override
|
||||
public String[] getRegistrationKeys() {
|
||||
return registerUnderJavaType()
|
||||
? new String[] { getName(), javaType.getJavaType().getTypeName() }
|
||||
? new String[] { getName(), javaType.getTypeName() }
|
||||
: new String[] { getName() };
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ public Object deepCopy(Object value, SessionFactoryImplementor factory) {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getReturnedClass().getName() + '(' + getRole() + ')';
|
||||
return getReturnedClassName() + '(' + getRole() + ')';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -663,7 +663,7 @@ public int getPropertyIndex(String name) {
|
||||
}
|
||||
}
|
||||
throw new PropertyNotFoundException(
|
||||
"Could not resolve attribute '" + name + "' of '" + getReturnedClass().getName() + "'"
|
||||
"Could not resolve attribute '" + name + "' of '" + getReturnedClassName() + "'"
|
||||
+ " (must be one of '" + StringHelper.join("', '", names) + "')"
|
||||
);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
||||
@Override
|
||||
public String[] getRegistrationKeys() {
|
||||
return registerUnderJavaType()
|
||||
? new String[] { getName(), javaType.getJavaType().getTypeName() }
|
||||
? new String[] { getName(), javaType.getTypeName() }
|
||||
: new String[] { getName() };
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ public StandardBasicTypeTemplate(
|
||||
super( jdbcType, javaType );
|
||||
this.registrationKeys = registrationKeys;
|
||||
|
||||
this.name = javaType.getJavaType() == null ? "(map-mode)" : javaType.getJavaType().getTypeName()
|
||||
this.name = javaType.getJavaType() == null ? "(map-mode)" : javaType.getTypeName()
|
||||
+ " -> " + jdbcType.getDefaultSqlTypeCode();
|
||||
}
|
||||
|
||||
|
@ -123,10 +123,21 @@ public interface Type extends Serializable {
|
||||
/**
|
||||
* The class handled by this type.
|
||||
*
|
||||
* @return The java type class handled by this type.
|
||||
* @return The Java class handled by this type.
|
||||
*/
|
||||
Class<?> getReturnedClass();
|
||||
|
||||
/**
|
||||
* The qualified name of the class handled by this type.
|
||||
*
|
||||
* @return The qualified Java class name.
|
||||
*
|
||||
* @since 6.5
|
||||
*/
|
||||
default String getReturnedClassName() {
|
||||
return getReturnedClass().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two instances of the class mapped by this type for persistence "equality",
|
||||
* that is, equality of persistent state, taking a shortcut for entity references.
|
||||
|
@ -82,6 +82,6 @@ protected <X> TemporalJavaType<X> forTimePrecision(TypeConfiguration typeConfigu
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TemporalJavaType(javaType=" + getJavaType().getTypeName() + ")";
|
||||
return "TemporalJavaType(javaType=" + getTypeName() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public <X> BigDecimal wrap(X value, WrapperOptions options) {
|
||||
|
||||
@Override
|
||||
public boolean isWider(JavaType<?> javaType) {
|
||||
switch ( javaType.getJavaType().getTypeName() ) {
|
||||
switch ( javaType.getTypeName() ) {
|
||||
case "byte":
|
||||
case "java.lang.Byte":
|
||||
case "short":
|
||||
|
@ -99,7 +99,7 @@ public <X> BigInteger wrap(X value, WrapperOptions options) {
|
||||
|
||||
@Override
|
||||
public boolean isWider(JavaType<?> javaType) {
|
||||
switch ( javaType.getJavaType().getTypeName() ) {
|
||||
switch ( javaType.getTypeName() ) {
|
||||
case "byte":
|
||||
case "java.lang.Byte":
|
||||
case "short":
|
||||
|
@ -132,7 +132,7 @@ public <X> Calendar wrap(X value, WrapperOptions options) {
|
||||
|
||||
@Override
|
||||
public boolean isWider(JavaType<?> javaType) {
|
||||
switch ( javaType.getJavaType().getTypeName() ) {
|
||||
switch ( javaType.getTypeName() ) {
|
||||
case "java.sql.Date":
|
||||
return true;
|
||||
default:
|
||||
|
@ -149,7 +149,7 @@ public <X> Calendar wrap(X value, WrapperOptions options) {
|
||||
|
||||
@Override
|
||||
public boolean isWider(JavaType<?> javaType) {
|
||||
switch ( javaType.getJavaType().getTypeName() ) {
|
||||
switch ( javaType.getTypeName() ) {
|
||||
case "java.util.Date":
|
||||
case "java.sql.Date":
|
||||
case "java.sql.Timestamp":
|
||||
|
@ -134,7 +134,7 @@ public <X> Calendar wrap(X value, WrapperOptions options) {
|
||||
|
||||
@Override
|
||||
public boolean isWider(JavaType<?> javaType) {
|
||||
switch ( javaType.getJavaType().getTypeName() ) {
|
||||
switch ( javaType.getTypeName() ) {
|
||||
case "java.sql.Time":
|
||||
return true;
|
||||
default:
|
||||
|
@ -169,7 +169,7 @@ public <X> Date wrap(X value, WrapperOptions options) {
|
||||
|
||||
@Override
|
||||
public boolean isWider(JavaType<?> javaType) {
|
||||
switch ( javaType.getJavaType().getTypeName() ) {
|
||||
switch ( javaType.getTypeName() ) {
|
||||
case "java.sql.Date":
|
||||
case "java.sql.Timestamp":
|
||||
case "java.util.Calendar":
|
||||
|
@ -100,7 +100,7 @@ else if ( value instanceof String ) {
|
||||
|
||||
@Override
|
||||
public boolean isWider(JavaType<?> javaType) {
|
||||
switch ( javaType.getJavaType().getTypeName() ) {
|
||||
switch ( javaType.getTypeName() ) {
|
||||
case "byte":
|
||||
case "java.lang.Byte":
|
||||
case "short":
|
||||
|
@ -99,7 +99,7 @@ else if (value instanceof String) {
|
||||
|
||||
@Override
|
||||
public boolean isWider(JavaType<?> javaType) {
|
||||
switch ( javaType.getJavaType().getTypeName() ) {
|
||||
switch ( javaType.getTypeName() ) {
|
||||
case "byte":
|
||||
case "java.lang.Byte":
|
||||
case "short":
|
||||
|
@ -96,7 +96,7 @@ public <X> Integer wrap(X value, WrapperOptions options) {
|
||||
|
||||
@Override
|
||||
public boolean isWider(JavaType<?> javaType) {
|
||||
switch ( javaType.getJavaType().getTypeName() ) {
|
||||
switch ( javaType.getTypeName() ) {
|
||||
case "byte":
|
||||
case "java.lang.Byte":
|
||||
case "short":
|
||||
|
@ -194,7 +194,7 @@ public <X> Date wrap(X value, WrapperOptions options) {
|
||||
|
||||
@Override
|
||||
public boolean isWider(JavaType<?> javaType) {
|
||||
switch ( javaType.getJavaType().getTypeName() ) {
|
||||
switch ( javaType.getTypeName() ) {
|
||||
case "java.sql.Date":
|
||||
case "java.sql.Timestamp":
|
||||
case "java.util.Date":
|
||||
|
@ -163,7 +163,7 @@ public <X> LocalDate wrap(X value, WrapperOptions options) {
|
||||
|
||||
@Override
|
||||
public boolean isWider(JavaType<?> javaType) {
|
||||
switch ( javaType.getJavaType().getTypeName() ) {
|
||||
switch ( javaType.getTypeName() ) {
|
||||
case "java.sql.Date":
|
||||
return true;
|
||||
default:
|
||||
|
@ -162,7 +162,7 @@ public <X> LocalDateTime wrap(X value, WrapperOptions options) {
|
||||
|
||||
@Override
|
||||
public boolean isWider(JavaType<?> javaType) {
|
||||
switch ( javaType.getJavaType().getTypeName() ) {
|
||||
switch ( javaType.getTypeName() ) {
|
||||
case "java.sql.Date":
|
||||
case "java.sql.Timestamp":
|
||||
case "java.util.Date":
|
||||
|
@ -169,7 +169,7 @@ public <X> LocalTime wrap(X value, WrapperOptions options) {
|
||||
|
||||
@Override
|
||||
public boolean isWider(JavaType<?> javaType) {
|
||||
switch ( javaType.getJavaType().getTypeName() ) {
|
||||
switch ( javaType.getTypeName() ) {
|
||||
case "java.sql.Time":
|
||||
return true;
|
||||
default:
|
||||
|
@ -96,7 +96,7 @@ else if ( value instanceof String ) {
|
||||
|
||||
@Override
|
||||
public boolean isWider(JavaType<?> javaType) {
|
||||
switch ( javaType.getJavaType().getTypeName() ) {
|
||||
switch ( javaType.getTypeName() ) {
|
||||
case "byte":
|
||||
case "java.lang.Byte":
|
||||
case "short":
|
||||
|
@ -42,7 +42,7 @@ public Short fromString(CharSequence string) {
|
||||
|
||||
@Override
|
||||
public boolean isWider(JavaType<?> javaType) {
|
||||
switch ( javaType.getJavaType().getTypeName() ) {
|
||||
switch ( javaType.getTypeName() ) {
|
||||
case "byte":
|
||||
case "java.lang.Byte":
|
||||
return true;
|
||||
|
@ -119,7 +119,7 @@ public <X> String wrap(X value, WrapperOptions options) {
|
||||
|
||||
@Override
|
||||
public boolean isWider(JavaType<?> javaType) {
|
||||
switch ( javaType.getJavaType().getTypeName() ) {
|
||||
switch ( javaType.getTypeName() ) {
|
||||
case "char":
|
||||
case "char[]":
|
||||
case "java.lang.Character":
|
||||
|
@ -42,7 +42,7 @@ public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
|
||||
return descriptor;
|
||||
}
|
||||
throw new JdbcTypeRecommendationException(
|
||||
"Could not determine recommended JdbcType for `" + getJavaType().getTypeName() + "`"
|
||||
"Could not determine recommended JdbcType for `" + getTypeName() + "`"
|
||||
);
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ public String toString(T value) {
|
||||
@Override
|
||||
public T fromString(CharSequence string) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Conversion from String strategy not known for this Java type : " + getJavaType().getTypeName()
|
||||
"Conversion from String strategy not known for this Java type: " + getTypeName()
|
||||
);
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ public <X> X unwrap(T value, Class<X> type, WrapperOptions options) {
|
||||
return (X) value;
|
||||
}
|
||||
throw new UnsupportedOperationException(
|
||||
"Unwrap strategy not known for this Java type : " + getJavaType().getTypeName()
|
||||
"Unwrap strategy not known for this Java type: " + getTypeName()
|
||||
);
|
||||
}
|
||||
|
||||
@ -76,12 +76,12 @@ public <X> T wrap(X value, WrapperOptions options) {
|
||||
return (T) value;
|
||||
}
|
||||
throw new UnsupportedOperationException(
|
||||
"Wrap strategy not known for this Java type : " + getJavaType().getTypeName()
|
||||
"Wrap strategy not known for this Java type: " + getTypeName()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BasicJavaType(" + getJavaType().getTypeName() + ")";
|
||||
return "BasicJavaType(" + getTypeName() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public EntityJavaType(Class<T> type, MutabilityPlan<T> mutabilityPlan) {
|
||||
@Override
|
||||
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
|
||||
throw new JdbcTypeRecommendationException(
|
||||
"Could not determine recommended JdbcType for `" + getJavaType().getTypeName() + "`"
|
||||
"Could not determine recommended JdbcType for '" + getTypeName() + "'"
|
||||
);
|
||||
}
|
||||
|
||||
@ -65,26 +65,26 @@ public String toString(T value) {
|
||||
@Override
|
||||
public T fromString(CharSequence string) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Conversion from String strategy not known for this Java type : " + getJavaType().getTypeName()
|
||||
"Conversion from String strategy not known for this Java type: " + getTypeName()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> X unwrap(T value, Class<X> type, WrapperOptions options) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unwrap strategy not known for this Java type : " + getJavaType().getTypeName()
|
||||
"Unwrap strategy not known for this Java type: " + getTypeName()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> T wrap(X value, WrapperOptions options) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Wrap strategy not known for this Java type : " + getJavaType().getTypeName()
|
||||
"Wrap strategy not known for this Java type: " + getTypeName()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EntityJavaType(" + getJavaType().getTypeName() + ")";
|
||||
return "EntityJavaType(" + getTypeName() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public FormatMapperBasedJavaType(
|
||||
@Override
|
||||
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
|
||||
throw new JdbcTypeRecommendationException(
|
||||
"Could not determine recommended JdbcType for Java type '" + getJavaType().getTypeName() + "'"
|
||||
"Could not determine recommended JdbcType for Java type '" + getTypeName() + "'"
|
||||
);
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ else if ( type == String.class ) {
|
||||
return (X) getFormatMapper( typeConfiguration ).toString( value, this, options );
|
||||
}
|
||||
throw new UnsupportedOperationException(
|
||||
"Unwrap strategy not known for this Java type : " + getJavaType().getTypeName()
|
||||
"Unwrap strategy not known for this Java type: " + getTypeName()
|
||||
);
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ else if ( value instanceof String ) {
|
||||
return getFormatMapper( typeConfiguration ).fromString( (String) value, this, options );
|
||||
}
|
||||
throw new UnsupportedOperationException(
|
||||
"Wrap strategy not known for this Java type : " + getJavaType().getTypeName()
|
||||
"Wrap strategy not known for this Java type: " + getTypeName()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ public JavaTypeBasicAdaptor(Class<T> type, MutabilityPlan<T> mutabilityPlan) {
|
||||
@Override
|
||||
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
|
||||
throw new JdbcTypeRecommendationException(
|
||||
"Could not determine recommended JdbcType for `" + getJavaType().getTypeName() + "`"
|
||||
"Could not determine recommended JdbcType for '" + getTypeName() + "'"
|
||||
);
|
||||
}
|
||||
|
||||
@ -42,26 +42,26 @@ public String toString(T value) {
|
||||
@Override
|
||||
public T fromString(CharSequence string) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Conversion from String strategy not known for this Java type : " + getJavaType().getTypeName()
|
||||
"Conversion from String strategy not known for this Java type: " + getTypeName()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> X unwrap(T value, Class<X> type, WrapperOptions options) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unwrap strategy not known for this Java type : " + getJavaType().getTypeName()
|
||||
"Unwrap strategy not known for this Java type: " + getTypeName()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> T wrap(X value, WrapperOptions options) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Wrap strategy not known for this Java type : " + getJavaType().getTypeName()
|
||||
"Wrap strategy not known for this Java type: " + getTypeName()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JavaTypeBasicAdaptor(" + getJavaType().getTypeName() + ")";
|
||||
return "JavaTypeBasicAdaptor(" + getTypeName() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,6 @@ public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JsonJavaType(" + getJavaType().getTypeName() + ")";
|
||||
return "JsonJavaType(" + getTypeName() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -19,22 +19,35 @@
|
||||
* {@link org.hibernate.type.descriptor.java.JavaType} for a given Java type.
|
||||
*/
|
||||
public final class UnknownBasicJavaType<T> extends AbstractJavaType<T> {
|
||||
private final String typeName;
|
||||
|
||||
public UnknownBasicJavaType(Class<T> type) {
|
||||
this( type, type.getTypeName() );
|
||||
}
|
||||
public UnknownBasicJavaType(Class<T> type, String typeName) {
|
||||
super( type );
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
public UnknownBasicJavaType(Class<T> type, MutabilityPlan<T> mutabilityPlan) {
|
||||
super( type, mutabilityPlan );
|
||||
this.typeName = type.getTypeName();
|
||||
}
|
||||
|
||||
public UnknownBasicJavaType(Type type, MutabilityPlan<T> mutabilityPlan) {
|
||||
super( type, mutabilityPlan );
|
||||
this.typeName = type.getTypeName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
|
||||
throw new JdbcTypeRecommendationException(
|
||||
"Could not determine recommended JdbcType for Java type '" + getJavaType().getTypeName() + "'"
|
||||
"Could not determine recommended JdbcType for Java type '" + getTypeName() + "'"
|
||||
);
|
||||
}
|
||||
|
||||
@ -46,7 +59,7 @@ public String toString(T value) {
|
||||
@Override
|
||||
public T fromString(CharSequence string) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Conversion from String strategy not known for this Java type : " + getJavaType().getTypeName()
|
||||
"Conversion from String strategy not known for this Java type: " + getTypeName()
|
||||
);
|
||||
}
|
||||
|
||||
@ -57,7 +70,7 @@ public <X> X unwrap(T value, Class<X> type, WrapperOptions options) {
|
||||
return (X) value;
|
||||
}
|
||||
throw new UnsupportedOperationException(
|
||||
"Unwrap strategy not known for this Java type : " + getJavaType().getTypeName()
|
||||
"Unwrap strategy not known for this Java type: " + getTypeName()
|
||||
);
|
||||
}
|
||||
|
||||
@ -68,12 +81,12 @@ public <X> T wrap(X value, WrapperOptions options) {
|
||||
return (T) value;
|
||||
}
|
||||
throw new UnsupportedOperationException(
|
||||
"Wrap strategy not known for this Java type : " + getJavaType().getTypeName()
|
||||
"Wrap strategy not known for this Java type: " + getTypeName()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BasicJavaType(" + getJavaType().getTypeName() + ")";
|
||||
return "BasicJavaType(" + getTypeName() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,6 @@ public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "XmlJavaType(" + getJavaType().getTypeName() + ")";
|
||||
return "XmlJavaType(" + getTypeName() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -1061,16 +1061,15 @@ private AbstractPluralAttribute createPluralAttribute(
|
||||
}
|
||||
}
|
||||
|
||||
private EmbeddableTypeImpl<Object> createEmbeddableDomainType(String entityName, CompositeType compositeType, ManagedDomainType<?> owner) {
|
||||
return new EmbeddableTypeImpl<Object>(new UnknownBasicJavaType<>(Object.class), true, metamodel.getJpaMetamodel()) {
|
||||
private EmbeddableTypeImpl<?> createEmbeddableDomainType(String entityName, CompositeType compositeType, ManagedDomainType<?> owner) {
|
||||
final JavaType<Object> javaType = new UnknownBasicJavaType<>(Object.class, compositeType.getReturnedClassName());
|
||||
return new EmbeddableTypeImpl<>(javaType, true, metamodel.getJpaMetamodel()) {
|
||||
@Override
|
||||
public PersistentAttribute<Object, Object> findAttribute(String name) {
|
||||
int i = compositeType.getPropertyIndex(name);
|
||||
Type subtype = compositeType.getSubtypes()[i];
|
||||
return createAttribute(
|
||||
name,
|
||||
entityName, //TOOD: WRONG!!!
|
||||
subtype,
|
||||
entityName,
|
||||
compositeType.getSubtypes()[compositeType.getPropertyIndex(name)],
|
||||
owner
|
||||
);
|
||||
}
|
||||
|
@ -264,6 +264,11 @@ public String getName() {
|
||||
return type.getSimpleName().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReturnedClassName() {
|
||||
return type.getQualifiedName().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComponentType() {
|
||||
return true;
|
||||
@ -803,11 +808,10 @@ boolean isConstructorDefined(String qualifiedClassName, List<Type> argumentTypes
|
||||
// }
|
||||
else if (type instanceof BasicType) {
|
||||
String className;
|
||||
//sadly there is no way to get the classname
|
||||
//from a Hibernate Type without trying to load
|
||||
//the class!
|
||||
//TODO: custom impl of getReturnedClassName()
|
||||
// for many more Hibernate types!
|
||||
try {
|
||||
className = type.getReturnedClass().getName();
|
||||
className = type.getReturnedClassName();
|
||||
}
|
||||
catch (Exception e) {
|
||||
continue;
|
||||
|
@ -0,0 +1,55 @@
|
||||
package org.hibernate.jpamodelgen.test.hqlsql;
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Embeddable
|
||||
public final class Address {
|
||||
private String street;
|
||||
private String city;
|
||||
private String zip;
|
||||
|
||||
public Address(String street, String city, String zip) {
|
||||
this.street = street;
|
||||
this.city = city;
|
||||
this.zip = zip;
|
||||
}
|
||||
|
||||
Address() {}
|
||||
|
||||
public String street() {
|
||||
return street;
|
||||
}
|
||||
|
||||
public String city() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public String zip() {
|
||||
return zip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) return true;
|
||||
if (obj == null || obj.getClass() != this.getClass()) return false;
|
||||
var that = (Address) obj;
|
||||
return Objects.equals(this.street, that.street) &&
|
||||
Objects.equals(this.city, that.city) &&
|
||||
Objects.equals(this.zip, that.zip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(street, city, zip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Address[" +
|
||||
"street=" + street + ", " +
|
||||
"city=" + city + ", " +
|
||||
"zip=" + zip + ']';
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@
|
||||
import org.hibernate.annotations.NaturalId;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Entity
|
||||
public class Book {
|
||||
@ -16,4 +17,5 @@ public class Book {
|
||||
@ManyToOne Publisher publisher;
|
||||
BigDecimal price;
|
||||
int pages;
|
||||
LocalDate publicationDate;
|
||||
}
|
||||
|
@ -40,6 +40,9 @@ public interface Dao {
|
||||
@HQL("from Book where isbn = :isbn")
|
||||
Book findByIsbn(String isbn);
|
||||
|
||||
@HQL("order by isbn asc, publicationDate desc")
|
||||
List<Book> allBooks();
|
||||
|
||||
@SQL("select * from Book where isbn = :isbn")
|
||||
Book findByIsbnNative(String isbn);
|
||||
|
||||
@ -64,4 +67,6 @@ public interface Dao {
|
||||
@HQL("select new list(title, pages) from Book")
|
||||
List<List> dtoQuery4();
|
||||
|
||||
@HQL("from Publisher where address = :address")
|
||||
List<Publisher> publisherAt(Address address);
|
||||
}
|
||||
|
@ -7,4 +7,5 @@
|
||||
public class Publisher {
|
||||
@Id Long id;
|
||||
String name;
|
||||
}
|
||||
Address address;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user