mysql - Java - how to query by Enum values -


i need data database enum values , enum following:

    public enum inspecttype{      often,      regular,      special,      } 

and entity ,

    public class techbridgeinspect{      private inspecttype insepcttype;      get...      set...      } 

if want select total count database inspecttype = , how write it?

i try following cannot worked. select count(*) techbridgeinspect inspecttype = 'often';

update: try following jpql , worked ,

    string jpql1= "select count(inspect) techbridgeinspect inspect inspect.insepcttype in (:inspecttype)";     entitymanager.createquery(jpql1,long.class).setparameter("inspecttype", enumset.of(techbridgeinspect.inspecttype.often)).getsingleresult(); 

try this, if using jpa,

select count(t) techbridgeinspect t  t  t.inspecttype = inspecttype.often 

Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -