# Parametrization

**URL:** <https://discourse.hibernate.org/t/parametrization/6694>\
**Category:** Hibernate ORM\
**Created:** [September 27, 2022, 6:51am UTC](https://discourse.hibernate.org/t/parametrization/6694 "2022-09-27T06:51:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zahi\_Chreim](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/zahi_chreim/32/2027_2.png) [@Zahi\_Chreim](https://discourse.hibernate.org/u/Zahi_Chreim)\
**Post date:** [September 27, 2022, 6:51am UTC](https://discourse.hibernate.org/t/parametrization/6694/1 "2022-09-27T06:51:41Z")

</div>

Hello guys,

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

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [September 27, 2022, 9:17am UTC](https://discourse.hibernate.org/t/parametrization/6694/2 "2022-09-27T09:17:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Zahi\_Chreim](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/zahi_chreim/32/2027_2.png) [@Zahi\_Chreim](https://discourse.hibernate.org/u/Zahi_Chreim)\
**Post date:** [September 27, 2022, 9:50am UTC](https://discourse.hibernate.org/t/parametrization/6694/3 "2022-09-27T09:50:40Z")

</div>

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();

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [September 27, 2022, 10:07am UTC](https://discourse.hibernate.org/t/parametrization/6694/4 "2022-09-27T10:07:16Z")

</div>

No, that’s not possible.
