Reputation: 2128
Currently I upload a CSV file which contains the following columns to the Google App Engine datastore:
id, roleName, eggName, highestAllTimePrice, lowestAllTimePrice, averagePrice
And the result of the table when I go to localhost:8888/_ah/admin/datastore are as follows:
Key, Write Ops, ID/Name, averagePrice, eggName, eggNumber, highestAllTimePrice, lowestAllTimePrice, roleName
I get all of the data from the table as follows:
public String GetData(final ModelMap model)
{
EntityManager em = EMF.get().createEntityManager();
Query q = em.createQuery("SELECT s FROM Egg s");
List<Egg> eggs = new ArrayList<Egg>(q.getResultList());
model.addAttribute("eggs", eggs);
return "index";
}
Entity
@Entity
public class Egg {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key key;
private int eggNumber;
private String roleName;
private String eggName;
private double highestPrice;
private double lowestPrice;
private double averagePrice;
// getters setters
}
But when I run that query, I get this error:
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double
at com.google.appengine.datanucleus.FetchFieldManager.fetchDoubleField(FetchFieldManager.java:140)
at org.datanucleus.state.AbstractStateManager.replacingDoubleField(AbstractStateManager.java:2256)
at Entity.Egg.jdoReplaceField(Egg.java)
at Entity.Egg.jdoReplaceFields(Egg.java)
The problem is I don't know why it's converting types? Have I mapped my entity class wrong?
Upvotes: 0
Views: 136
Reputation: 468
Perhaps your double fields (highestPrice, etc) are considered to be strings in the datastore, and thus cannot be mapped to your entity.
Upvotes: 1