Hello all,
I am very new to hibernate. I have a one-to-one relationship between two tables MASTER and ROSTER.
I have correctly mapped a unidirectional one-to-one association from my persistent class Roster to Master.
I need to search all Roster records by transaction_date property of Master.
I have spent hours trying to search for an elegant way to do this query using Criteria, but to no avail. I ended up doing something
like this which gives me the desired output. I actually need to do an equality comparison on date attributes in my table. I am using Oracle as backend.
Code:
Criteria criteria = session.createCriteria(Roster.class);
criteria.createCriteria("master")
.add(Restrictions.sqlRestriction("to_char(transaction_date,'MM/DD/YYYY') = '"+transaction_date+"'"));
Can you please let me know a better way to express such query in Hibernate(esp. the one using date comparisons on equality). Your suggestions would be highly appreciated.
Thanks.