In using Hibernate Query Language to include a Parameter of Type Long in a statement you would use the following code:
Query q = session.createQuery(“from Class1 c where c.class2.class2_id = :class2_id”);
q.setLong(“class2_id”, class2_id);
q.list();…..
One thing to Immediately notice (if you are familiar with Hibernate) is that I am calling class2_id through class2. This is because in my little world class2 has a one to many relationship with Class1. This means there is an object called class2 joining them together in the annotations. However, I digress. The real take away is that a parameter called :class2_id was established in the query and the referenced in the setLong statement to set the value. After that calling the q.list function will return the values pulled back from the query. And TADA!