Hi,
Every time i execute the below code, i get an IllegalArgumentException.
Code:
Query q1 = currentSession.createQuery("from Track t");
q1.setMaxResults(100);
List<Track> tracks = (List<Track>) q1.list();
Query q2 = currentSession.createQuery("from Track t left join fetch t.files where t in (:tracks)");
q2.setParameter("tracks", tracks);
q2.list();
Track is a subclass of BaseEntity, where the getId() and setId() methods are found.The error message i
keep getting is:
Code:
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.tracker.robot.db.entities.BaseEntity.id
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:195)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:199)
[...]
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
If i replace the second query with the below, everything works fine. However, that issues a subquery - which takes longer.
Code:
Query q2 = currentSession.createQuery("from Track t left join fetch t.files where t in (select Track t1 where t1.flag = 2)");
Does anyone have an idea about why i keep getting this error. I can't see why Hibernate is unable to understand the
second query as
Code:
SELECT [fields] FROM track WHERE where track.id in([ids of all tracks])
?
I'd love to hear any ideas or suggestions as to how i might be able to solve this issue!