mardi 4 août 2015

Passing string which is the name of entity/perisistance class in createcriteria of hibernate

I have to dynamically load tables for which I was passing through controller and when I have to write hibernate peristance logic of suppose createCriteria, I gave:

getSession().createCriteria( Class.forName(tableName)).list()

where tableName is a string which would contain the name of the class. Even then I was unscessful and getting ClassNotFound Exception. It works for

getSession().createCriteria(Book.class).list() which I feel is hardcoding in my case. Please help regarding with which I could dynamically call tables.

Aucun commentaire:

Enregistrer un commentaire