heads up for the quick pickup.
i see this code in the latest hibernate3 online it is in org.springframework.orm.hibernate3.HibernateTemplate
a test case would be: create an entity with and enum: psudo code:
@Entity @NamedQuery(name = "testQuery", query = "from TestEntity where type like :type ") public class TestEntity{ @Id @Column(name = "ID") @GeneratedValue(strategy = GenerationType.AUTO) @SearchableId private Long id; @Enumerated(EnumType.STRING) private ContentType type;
//getters and setters
}
the ContentType is some enum which is stored as a String.
than call:
final String[] names = { "type" }; Object[] values = { "%" }; List found = getHibernateTemplate().findByNamedQueryAndNamedParam("testQuery", names, values);
you will get an conversion exception that the string can't be converted to an enum. because: queryObject.setParameter(paramName, value); will try to set it as an enum instead of queryObject.setString(paramName, value); which would set it as a string.
|