Hello
I can't figure out how to pass a null through hibernate to a sql query as a search parameter. The query uses the COALESCE function to dynamically build my query search criteria:
In straing SQL:
Code:
SELECT u.USERNAME AS USERNAME , u.ID USER_ID, h.* FROM TFL_ATU_CONTACT contact
left join TFL_ATU_TOPUP_HISTORY h ON contact.ATU_TOPUP_HISTORY_ID = h.ID
left join TFL_CARD card ON h.PRESTIGE_ID=card.PRESTIGE_ID
left join TFL_USER_TO_CARD u2card ON u2card.PRESTIGE_ID=card.PRESTIGE_ID
left join TFL_USER u ON u.ID = u2card.USER_ID
GROUP BY
h.ID,
h.PRESTIGE_ID,
h.STATUS,
h.PICKUP_DATE,
h.PICKUP_STATION_NLC,
h.ATU_STATE_ID,
h.AMOUNT,
h.BUS_ROUTE,
h.LAST_MODIFIED,
h.CREATE_DATE,
u.ID,
u.USERNAME
HAVING u.USERNAME= COALESCE(NULL, u.USERNAME)
h.PICKUP_DATE= COALESCE(NULL, h.PICKUP_DATE)
I want to alter this to take a parameter passed by code ie
code]
HAVING u.USERNAME= COALESCE(?, u.USERNAME)
h.PICKUP_DATE= COALESCE(?, h.PICKUP_DATE)
[/code]
So I can execute:
Code:
.findByNamedQuery("my.query.name", new Object[] {null});
When I run this I get the following error
Code:
2007-06-29 11:55:07,627 DEBUG [org.hibernate.type.SerializableType] - <binding null to parameter: 1>
2007-06-29 11:55:07,674 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: 932, SQLState: 42000>
2007-06-29 11:55:07,674 ERROR [org.hibernate.util.JDBCExceptionReporter] - <ORA-00932: inconsistent datatypes: expected BINARY got CHAR>
I'm pretty stuck with this so any help would be great
Many thanks in advance
BM
[/code]