i have an issue with hql queries which contain a null in the select, for example: "select firstname, lastname, null from Employer"
The Nullpointer comes from:
Caused by: java.lang.NullPointerException
at org.hibernate.hql.internal.NameGenerator.generateColumnNames(NameGenerator.java:27)
So the code in NameGenerator at that line:
public static String[][] generateColumnNames(Type[] types, SessionFactoryImplementor f) throws MappingException {
String[][] columnNames = new String[types.length][];
for ( int i = 0; i < types.length; i++ ) {
int span = types[i].getColumnSpan( f ); // <-- line 27
columnNames[i] = new String[span];
for ( int j = 0; j < span; j++ ) {
columnNames[i][j] = NameGenerator.scalarName( i, j );
}
}
return columnNames;
}
I narrowed it down to the new Class NullNode (added since Hibernate 5), which simply returns null for getType():
public class NullNode extends AbstractSelectExpression {
public Type getDataType() {
return null;
}
....
}
So my question is.. is this a bug in hibernate or am i missusing hibernate at that place?
types[i]
orf
– Hibernicism