Using Hibernate 3.5.3:
There is a function in the database (which uses Oracle-related table functions) that returns the number of rows and values โโwhen the object identifier is supplied. (This function is part of legacy code that cannot be changed.)
Example result:
select * from table(DateOptions_Function('ID_OF_ENTITY')); OPTION DATE
I want to map the result of @Formula (containing the above SQL) to an object object.
public class DateOptions { private LocalDate startDate; private LocalDate endDate; private LocalDate otherDate;
I want to display it like in the object:
@Formula("(select * from table(DateOptions_Function(ENTITY_ID)))") @Type(type = "mypackage.DateOptionsUserType") public DateOptions getDateOptions() { return dateOptions; }
I tried to create a Hibernate UserType with the hope of creating a DateOptions object using the ResultSet in nullSafeGet(...) .
I am specifying sql types in my DateOptionsUserType
public int[] sqlTypes() { return new int[] {Types.VARCHAR, Types.DATE}; }
However, when I start, I get the following exception: org.hibernate.MappingException: property mapping has wrong number of columns: mypackage.MyEnity.dateOptions type: mypackage.DateOptionsUserType (I also tried CompositeUserType with the same result).
Any idea what might cause the problem? Is this possible (matching @Formula with a custom non-entity object)?
source share