Add Order By to entities created by seam-gen?
crhoffman Jun 9, 2009 6:29 PMI used seam-gen to reverse engineer some tables in MySQL. I now want the generated entities to start with a default sort order. What is the best way to do this? My records come out in random order. I tried adding an ORDER BY clause in an EJBQL statement (see below):
--------
@Name("tmpFindPropAttemptsList") public class TmpFindPropAttemptsList extends EntityQuery<TmpFindPropAttempts> { // private static final String EJBQL = "select tmpFindPropAttempts from TmpFindPropAttempts tmpFindPropAttempts"; private static final String EJBQL = "select tmpFindPropAttempts from TmpFindPropAttempts tmpFindPropAttempts order by accessionId, propNo"; private static final String[] RESTRICTIONS = { "lower(tmpFindPropAttempts.accessionId) like concat(lower(#{tmpFindPropAttemptsList.tmpFindPropAttempts.accessionId}),'%')", "lower(tmpFindPropAttempts.fullsciname) like concat(lower(#{tmpFindPropAttemptsList.tmpFindPropAttempts.fullsciname}),'%')", "lower(tmpFindPropAttempts.proptype) like concat(lower(#{tmpFindPropAttemptsList.tmpFindPropAttempts.proptype}),'%')", "lower(tmpFindPropAttempts.result) like concat(lower(#{tmpFindPropAttemptsList.tmpFindPropAttempts.result}),'%')",}; private TmpFindPropAttempts tmpFindPropAttempts = new TmpFindPropAttempts(); public TmpFindPropAttemptsList() { setEjbql(EJBQL); setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS)); setMaxResults(25); } public TmpFindPropAttempts getTmpFindPropAttempts() { return tmpFindPropAttempts; } }
---------
Or is there some place in the entity declaration where this should happen:
---------
/** * TmpFindPropAttempts generated by hbm2java */ @Entity @Table(name = "tmp_find_prop_attempts", catalog = "test") public class TmpFindPropAttempts implements java.io.Serializable { private int propNo; private TmpFindPropSciname tmpFindPropSciname; private short rowid; private String accessionId; private String fullsciname; private String proptype; private Date propdate; private String result; private Set<TmpFindPropDetail> tmpFindPropDetails = new HashSet<TmpFindPropDetail>( 0); public TmpFindPropAttempts() { }
... and so on ...
Thanks in advance for any advice!