I am facing problem in converting java enum to string conversion. Please if you have any idea.
String mainQuerySt = "select o.ttType from Tt o";
Query mainQuery = em.createQuery(mainQuerySt);
List result = mainQuery.setFirstResult(offset).setMaxResults(numofRecords).getResultList();
I want the string representation of ttType enum. How to do it?
My Tt Definition:
@Enumerated(EnumType.ORDINAL)
@Column(name = "tt_type", nullable = false)
private TTType ttType;
My enum TTType definition:
public enum TTType
{
FC,
PD
;
@Override
public String toString()
{
switch (this)
{
case FC:
return "FC";
case PD:
return "PD";
default:
throw new AssertionError();
}
}
}
I can't use EnumType.STRING in @Enumerated now since the system is live.
Please reply.
EnumType.STRING?String toString()method is also failed to serve purpose? I guess it should work.