Parametrization

Hello guys,

anyway to pass an object of type class to an entityManager nativeQuery and access it getters as parameter inside the query??

I have no idea what you mean, but the only “interpretation” that happens for native queries is replacement of special angle brace sequences, which is usually illegal SQL, and application of limit/offset. Other than that, Hibernate doesn’t touch the SQL.

Dear beikov,

This is how we use the setParameter in entity manager create native query :
Query query = em.createNativeQuery(SELECT * FROM MY_TABLE WHERE MY_COL = :key);
query.setParameter(key,example);

My question is :
MyClass myClass = new MyClass();
myClass.setName(“zahi”);
Query query = em.createNativeQuery(SELECT * FROM MY_TABLE WHERE MY_COL = :key.name);
query.setParameter(key,myClass);

did you get my point ? can i pass an object of class and in the query i mean by :key.name to get the value from the class getter myClass.getName();

No, that’s not possible.