HibernateCallback generateOneByExampleCallback(final T exampleInstance, final String... excludeProperty) {
HibernateCallback callback = new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
// Using Hibernate, more difficult with EntityManager and EJB-QL
Criteria crit = session.createCriteria(getPersistentClass());
Example example = Example.create(exampleInstance);
for (String exclude : excludeProperty) {
example.excludeProperty(exclude);
}
crit.add(example);
return crit.uniqueResult();
}