Vivek Sadh
Vivek Sadh

Reputation: 4268

Could not resolve property exception for transient property

I am trying to apply hibernate criteria on a class which contains a transient field(A list of objects). When I call criteria.list() it throws exception and says that it is not able to resolve that property as it does not have any mapping. I am applying Hibernate Restrictions only on few mapped fields. The partial structure of the class is like this:-

@Table(name = "table_records")

public class SampleClass implements Serializable {

public SampleClass(){
}

@Id @GeneratedValue(strategy = GenerationType.TABLE, generator = "table_records_GEN")
private Integer id;

@Column(name = "start_datetime")
private Date startDatetime;

@Column(name = "end_datetime")
private Date endDatetime;


@Transient
public List<SomeObject> records;

It contains many other fields as well. I am getting error on records field as it is transient. Please suggest.

Upvotes: 1

Views: 1098

Answers (2)

Vivek Sadh
Vivek Sadh

Reputation: 4268

I have resolved the problem. The Restriction was actually applied on the "records" field instead of a "totalRecords" field and as it was not able to find mapping, it threw exception.

Thanks to those whose tried to help.

Upvotes: 1

Ramzan Zafar
Ramzan Zafar

Reputation: 1600

I guess you are missing @Entity from the main POJO

try it like

@Entity
@Table(name = "table_records")
public class SampleClass implements Serializable 

Upvotes: 0

Related Questions