views:

57

answers:

1

i am facing null pointer exception in hibernate:

org.hibernate.dialect.function.CastFunction.render(CastFunction.java:11)

hibernate code is: ("Select date_format(str_to_date(form.dobDate,'%Y%m%d'),'%M (%Y)') as Month");

A: 

Without more info I would guess that dobDate is null (or the form).

However I feel yo are going against the grain here. I think hibernate's purpose is not to return properly formatted strings. I am already happy when hibernate translates my Java objects to/from the database properly.

Formatting dates etc I prefer to do in the Java code, actually as close as possible to the outside world, in the UI or in the I/O layers and keep things like dates as dates. This offers more flexibility and I find it keeps the code cleaner.

These kind of formatting things in hibernate are useful with legacy databases in where clauses though

Peter Tillemans