Hi,
There are two entities . TblProductopermaster2 entity is parent of TblProductoperwh entity
Code:
/**
* TblProductopermaster generated by hbm2java
*/
@Entity
@Table(name = "TBL_PRODUCTOPERMASTER2")
@Inheritance(strategy=InheritanceType.JOINED)
public class TblProductopermaster2 implements java.io.Serializable {
private int id;
private Set<TblData> tblData = new HashSet< TblData >(
0);
public TblProductopermaster2() {
}
public TblProductopermaster2(int id) {
this.id = id;
}
@Id
@GeneratedValue(generator="increment")
@GenericGenerator(name="increment", strategy = "increment")
@Column(name = "ID", unique = true, nullable = false)
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "tblDataID")
public Set<TblData> getTblData() {
return this.tblDatas;
}
public void setTblData(
Set< TblData > tblDatas) {
this.tblDatas = tblDatas;
}
}
Code:
@Entity
@Table(name = "TBL_PRODUCTOPERWH")
@PrimaryKeyJoinColumn(name="ID")
@Inheritance(strategy=InheritanceType.JOINED)
public class TblProductoperwh extends TblProductopermaster implements java.io.Serializable {
public TblProductoperwh() {
}
}
When below code is running .
Code:
DetachedCriteria dc = DetachedCriteria.forClass(TblProductoperwh.class);
dc.add(Restrictions.sizeEq("tblData", 0));
List l = dc.getExecutableCriteria(session).list();;
Error message is occurred
Code:
org.hibernate.MappingException: Could not locate CollectionPersister for role : p1.TblProductoperwh.tblData
at org.hibernate.metamodel.internal.MetamodelImpl.collectionPersister(MetamodelImpl.java:601)
at org.hibernate.engine.spi.SessionFactoryImplementor.getCollectionPersister(SessionFactoryImplementor.java:351)
at org.hibernate.criterion.SizeExpression.toSqlString(SizeExpression.java:40)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:400)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:106)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:75)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:80)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1875)
at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:366)
at com.pronit.siminac.mrt.server.server.Server.getAll(Server.java:78)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:4
What is the problem. It is not child class. Why?
When we call for parent class it is ok
Code:
DetachedCriteria dc = DetachedCriteria.forClass(TblProductopermaster2.class);
dc.add(Restrictions.sizeEq("tblData", 0));
List l = dc.getExecutableCriteria(session).list();;
Thank you