I do not want to use Criteria, i hope the default behavior of hibernate will be:
you can query any POJO use a method like queryByExample:
1, if you set a int/long/nubmer type property, the the method will dynamic generate the HQL :
Code:
From XXXPojo Where intPropertyName = :intPropertyValue
2, if you set a string property, the method will auto append:
Code:
and stringPropertyName like :stiringPropertyValue
3,if POJO have a date/dateTime property, such as birthday, i can define the orther two property like
birhtdayStart, birthdayEnd, and annotate them with
Code:
@Transient
@Column(name="birthday", operation=">=")
private Date birhtdayStart;
@Transient
@Column(name="birthday", operation="<")
private Date birthdayEnd;
the method will auto append like
Code:
birthday >= :birthdayStart and birthday < :birthdayEnd