Was wondering if anyone can see an obvious problem with my query that does not run.
I have a component table and a ptsdata table. The component table has a FK to the ptsdata table. I am trying to query the component table where the ptsdataid = "some value".
The generated query is correct and selects the proper records. But it appears to fail during the mapping and I don't understand why. Anyone?
Component mapping -
<hibernate-mapping> <class name="com.translogiccorp.ptscustdata.domain.ComponentImpl" table="pts_sda.components"> <id name="id" type="java.lang.Long" column="id" > <generator class="increment"/> </id> <many-to-one name="ptsdataid" class="com.translogiccorp.ptscustdata.domain.PtsdataImpl" fetch="select"> <column name="pts_data_id" not-null="true" /> </many-to-one>
Ptsdata mapping -
<hibernate-mapping> <class name="com.translogiccorp.ptscustdata.domain.PtsdataImpl" table="pts_cust.pts_data"> <id name="id" type="java.lang.Long" column="id" > <generator class="increment"/> </id>
Accessor code -
protected Long id;
protected void setId(Long l) { id = l; } public Long getId() { return id; }
Query code -
s = HibernateUtil.getSession(); cr = s.createCriteria(ComponentImpl.class); cr.add(Restrictions.eq("ptsdataid", ptsdataid)); List<ComponentImpl> cil = cr.list();
Generated sql query -
select this_.id as id15_0_, this_.pts_data_id as pts2_15_0_, this_.component_name as component3_15_0_, this_.equipid as equipid15_0_, this_.zone_num as zone5_15_0_, this_.component_type_id as component6_15_0_ from pts_sda.components this_ where this_.pts_data_id=?
Stacktrace -
Sep 23, 2011 12:54:04 PM org.hibernate.property.BasicPropertyAccessor$BasicGetter get SEVERE: IllegalArgumentException in class: com.translogiccorp.ptscustdata.domain.BaseDomain, getter method of property: id org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.translogiccorp.ptscustdata.domain.BaseDomain.id at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:198) at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:227) at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3875) at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3583) at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:203) at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:242) at org.hibernate.type.EntityType.getIdentifier(EntityType.java:456) at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:130) at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1873) at org.hibernate.loader.Loader.bindParameterValues(Loader.java:1844) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1716) at org.hibernate.loader.Loader.doQuery(Loader.java:801) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274) at org.hibernate.loader.Loader.doList(Loader.java:2533) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276) at org.hibernate.loader.Loader.list(Loader.java:2271) at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716) at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347) at com.translogiccorp.ptscustdata.parser.EquipCfgParser.buildZonenums(EquipCfgParser.java:127) at com.translogiccorp.ptscustdata.parser.EquipCfgParser.execute(EquipCfgParser.java:94) at com.translogiccorp.ptscustdata.parser.BaseParser.run(BaseParser.java:48) at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@1888eb8 at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:172)
|