0

this is not a homework or the actual code. It is a quick example created to explain the situation.

public student {
private long studentId;
Private long studentName;
@Column(name = "ID")
getStudentId(){
}

@Column(name = "NAME"
getStudentName(){
}

}

is there a way to have a dyanmic way to get the column name

 Criterion rest1 = Restrictions.eq("NAME", criteriaModel.getEncounterTypeClassCd());

dont want to hard code the column name is there a better way that doing what I am doing.

Praveen
  • 101
  • 14

1 Answers1

0

You may need to read the annotaton's value. Right?

Some thing like mentioned in this thread might help.

Anyway defining the value in a constant and using it in both places would be simpler, as the column names don't change that often after the development phase.

Community
  • 1
  • 1
Hari Nair
  • 96
  • 1
  • 1
  • 10