Skip to content

Commit

Permalink
Support Hibernate Subselect entity (fixes Blazebit#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwgmeligmeyling committed Mar 3, 2018
1 parent 0bde7e0 commit f9f3372
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,19 @@ public String[] getColumnTypes(EntityType<?> entityType, String attributeName) {
}

// In this case, the property might represent a formula
if (columnNames.length == 1 && columnNames[0] == null) {
boolean isFormula = columnNames.length == 1 && columnNames[0] == null;
boolean isSubselect = tables.length == 1 && tables[0] == null;

if (isFormula || isSubselect) {
Type propertyType = entityPersister.getPropertyType(attributeName);
long length;
int precision;
int scale;
try {
if (propertyType instanceof org.hibernate.type.EntityType) {
propertyType = ((org.hibernate.type.EntityType) propertyType).getIdentifierOrUniqueKeyType(sfi);
}

Method m = Type.class.getMethod("dictatedSizes", Mapping.class);
Object size = ((Object[]) m.invoke(propertyType, sfi))[0];
length = (long) size.getClass().getMethod("getLength").invoke(size);
Expand Down

0 comments on commit f9f3372

Please sign in to comment.