Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle App Engine datastore - Enums
    primarykey
    data
    text
    <p>Im trying to save and query an enum into a Google App Engine datastore using JPA.<br> According to <a href="http://www.datanucleus.org/products/accessplatform_2_2/jpa/types.html" rel="nofollow">DataNucleas</a> an Enum is a JPA persistable data type by default. But what im getting is the following exception :</p> <pre><code>com.xxx.utils.ActionLogUtils logCreateUserAction: actiontype: **com.xxx.endpoints.ActionLog$ACTION_TYPE** is not a supported property type. java.lang.IllegalArgumentException: actiontype: **com.xxx.endpoints.ActionLog$ACTION_TYPE** is not a supported property type. at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedSingleValue(DataTypeUtils.java:235) at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:207) at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:173) at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:148) at com.google.appengine.api.datastore.PropertyContainer.setProperty(PropertyContainer.java:101) </code></pre> <p>my entity class looks like this :</p> <pre><code>@Entity public class ActionLog { public static enum ACTION_TYPE { ACTION_1(1), ACTION_2(2), ACTION_3(3); private final int value; private ACTION_TYPE(int value) { this.value = value; } public int getValue() { return value; } } private ACTION_TYPE actiontype; public ActionLog() { } public ACTION_TYPE getActiontype() { return actiontype; } public void setActiontype(ACTION_TYPE actiontype) { this.actiontype = actiontype; } } </code></pre> <p>And the code that causes the exception is :</p> <pre><code>public static void logCreateUserAction(String userId) { DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); try { Key userKey = KeyFactory.createKey("User", userId); Entity actionLogEntity = new Entity("ActionLog", userKey); actionLogEntity.setProperty("actiontype", ACTION_TYPE.ACTION_1); datastore.put(actionLogEntity); } catch (Exception e) { log.log(Level.SEVERE, e.getMessage(), e); } } </code></pre> <p>What am i doing wrong here ? I really searched the web and google's documenation but couldn't find anything about enums. Can you please help ? Im really stucked here.</p> <p>Thanks a lot. I really appreciate it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload