HHH-8944 - ColumnTransformer handling is too aggressive in qualifying "column names"
This commit is contained in:
parent
6c0c44f7d0
commit
5803ad5839
|
@ -649,10 +649,17 @@ public class Ejb3Column {
|
|||
}
|
||||
|
||||
private void processExpression(ColumnTransformer annotation) {
|
||||
String nonNullLogicalColumnName = logicalColumnName != null ? logicalColumnName : ""; //use the default for annotations
|
||||
if ( annotation != null &&
|
||||
( StringHelper.isEmpty( annotation.forColumn() )
|
||||
|| annotation.forColumn().equals( nonNullLogicalColumnName ) ) ) {
|
||||
if ( annotation == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String nonNullLogicalColumnName = logicalColumnName != null
|
||||
? logicalColumnName
|
||||
//use the default for annotations
|
||||
: "";
|
||||
|
||||
if ( StringHelper.isEmpty( annotation.forColumn() )
|
||||
|| annotation.forColumn().equals( nonNullLogicalColumnName ) ) {
|
||||
readExpression = annotation.read();
|
||||
if ( StringHelper.isEmpty( readExpression ) ) {
|
||||
readExpression = null;
|
||||
|
|
|
@ -269,12 +269,13 @@ public class Column implements Selectable, Serializable, Cloneable {
|
|||
@Override
|
||||
public String getTemplate(Dialect dialect, SQLFunctionRegistry functionRegistry) {
|
||||
return hasCustomRead()
|
||||
? Template.renderWhereStringTemplate( customRead, dialect, functionRegistry )
|
||||
// see note in renderTransformerReadFragment wrt access to SessionFactory
|
||||
? Template.renderTransformerReadFragment( customRead, getQuotedName( dialect ) )
|
||||
: Template.TEMPLATE + '.' + getQuotedName( dialect );
|
||||
}
|
||||
|
||||
public boolean hasCustomRead() {
|
||||
return ( customRead != null && customRead.length() > 0 );
|
||||
return customRead != null;
|
||||
}
|
||||
|
||||
public String getReadExpr(Dialect dialect) {
|
||||
|
@ -345,7 +346,7 @@ public class Column implements Selectable, Serializable, Cloneable {
|
|||
}
|
||||
|
||||
public void setCustomRead(String customRead) {
|
||||
this.customRead = customRead;
|
||||
this.customRead = StringHelper.nullIfEmpty( customRead );
|
||||
}
|
||||
|
||||
public String getCanonicalName() {
|
||||
|
|
|
@ -88,6 +88,16 @@ public final class Template {
|
|||
|
||||
private Template() {}
|
||||
|
||||
public static String renderTransformerReadFragment(
|
||||
String fragment,
|
||||
String... columnNames) {
|
||||
// NOTE : would need access to SessionFactoryImplementor to make this configurable
|
||||
for ( String columnName : columnNames ) {
|
||||
fragment = fragment.replace( columnName, TEMPLATE + '.' + columnName );
|
||||
}
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public static String renderWhereStringTemplate(String sqlWhereString, Dialect dialect, SQLFunctionRegistry functionRegistry) {
|
||||
return renderWhereStringTemplate(sqlWhereString, TEMPLATE, dialect, functionRegistry);
|
||||
}
|
||||
|
|
|
@ -55,4 +55,12 @@ public class Staff {
|
|||
public double getDiameter() { return diameter; }
|
||||
public void setDiameter(double diameter) { this.diameter = diameter; }
|
||||
private double diameter;
|
||||
|
||||
@Column(name="kooky")
|
||||
@ColumnTransformer(
|
||||
read = "cast( kooky as VARCHAR )"
|
||||
)
|
||||
public String getKooky() { return kooky; }
|
||||
public void setKooky(String kooky) { this.kooky = kooky; }
|
||||
private String kooky;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue