AssignCoScholastic.javaVarlıklar eşlemede olduğunda birincil anahtar olmayan değer nasıl edinilir?
@Entity
@Table(name="assignCoScholastic")
public class AssignCoScholastic
{
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int assginCoScholasticId;
@ManyToOne
@JoinColumn(name="assignClassId")
private AssignClass assignClass;
@ManyToOne
@JoinColumn(name="coscholasticId")
private CoScholastic coscholastic;
@ManyToOne
@JoinColumn(name="subCoScholasticId")
private SubCoScholasticActivity subCoScholasticActivity;
private String year;
@ManyToOne
@JoinColumn(name="school_id")
private SchoolModel schoolModel;
CoScholastic.java
@Entity
@Table(name="coscholastic")
public class CoScholastic {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int coScholasticId;
@Column(name="Coscholastic_Name")
private String coscholasticName;
// Getters and Setters
Uygulama: Ben kodunun üzerinde yürütmeye çalışırken istisna altında alıyorum
@Override
public List<Object[]> listOfAssignCoScholastics(int assiginedClass, int schoolId, String year) {
Session session=sessionFactory.openSession();
session.beginTransaction();
List<Object[]> listOfAssignCoScholastics=new ArrayList<Object[]>();
try
{
Criteria criteria=session.createCriteria(AssignCoScholastic.class);
criteria.setProjection(Projections.property("coscholastic.coScholasticId"));
criteria.setProjection(Projections.property("coscholastic.coscholasticName"));
criteria.add(Restrictions.eq("assignClass.assignID", assiginedClass));
criteria.add(Restrictions.eq("schoolModel.school_id", schoolId));
criteria.add(Restrictions.like("year", year));
listOfAssignCoScholastics=criteria.list();
session.getTransaction().commit();
}catch(Exception ex){
ex.printStackTrace();
}finally{
session.close();
sessionFactory.close();
}
return listOfAssignCoScholastics;
}
.
org.hibernate.QueryException: could not resolve property:
ve nasıl çözüleceğini nedir ??
İstisna:
org.hibernate.QueryException: could not resolve property: coscholastic.coscholasticName of: com.slv.model.AssignCoScholastic
at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:81)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:75)
at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1465)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getType(CriteriaQueryTranslator.java:547)
at org.hibernate.criterion.PropertyProjection.getTypes(PropertyProjection.java:60)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getProjectedTypes(CriteriaQueryTranslator.java:362)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:100)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:82)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:92)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1697)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
at com.slv.daoimpl.RegistrationDaoImpl.listOfAssignCoScholastics(RegistrationDaoImpl.java:1907)
at com.slv.controller.SchoolController.loadAssignCoscholastic(SchoolController.java:920)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
kod ama sadece adı alma im ama id yukarıda kullanılan, onun dönen Adı sütun yalnızca –
yıl niteliktir hangi sınıftan ..? –
yıl özniteliği, AssignCoScholastic.java kaynaklıdır. –