0

I have setter and getter in my model class but still getting Exception. this is my model class.

    @Entity
    @Table(name="A_CPView")
    public class APRecord extends AbstractAPRecord implements ARecord {
      private AMaID mAiD;

        private String aId = null;
        @Transient
        public String getAId() {
        if (getMAiD() != null) {
        if (getMAiD().getId() != null) {
            aId = getMAiD().getId().toString();
        }
    }

    return aId;
}

public void setAId(String aId) {
    this.aId = aId;
}
 @ManyToOne
@JoinColumn(name="agentG")
public AMaID getMAiD() {
    return mAiD;
}

public void setMAiD(AMaID mAiD) {
    this.mAiD = mAiD;
}
}

In my DAO:

     Criteria crit = statelessSession.createCriteria(APRecord.class, "accmpr");
    crit.createAlias("AMaID", "aMaId", Criteria.INNER_JOIN);


    crit.addOrder( Order.asc("pName") );
    crit.addOrder( Order.asc("kNum") );
    crit.setProjection(Projections.distinct(Projections.property("aId")));
    return crit.scroll(ScrollMode.FORWARD_ONLY);

It gives me a:

org.hibernate.QueryException: could not resolve property: aId

Can anyone tell me what the error is?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Jay
  • 471
  • 1
  • 4
  • 11

1 Answers1

2

Is it to do with having your aId getter set to Transient? Hibernate is not going to get/set the values off of Transient properties as it is not meant to be.

Mihir
  • 270
  • 3
  • 9
  • I could use the the other property from my model class which is agentG (Not up there). I used that but it gives me a ORDER BY items must appear in the select list if SELECT DISTINCT is specified in hibernate – Jay Aug 10 '15 at 21:19