I have two columns in my table are which is BigInt data type (NODEID and ULNODEID) and I want to keep it that way. I am using MYSQL workbench 8.0 for these table.
I want to get the value of my nodeid using the function below:
public long get_urlnodeid(long nodeID) {
try {
String sql = "select NODEID from urllink where ULNODEID="+nodeID;
if (em == null) {
throw new Exception("could not found URL object.");
}
return (long) em.createNativeQuery(sql).getSingleResult();
} catch (Exception e) {
msg = CoreUtil.wrapMsg(CoreUtil.FUNC_ERROR,
this.getClass().getName(), "get", e.getMessage());
}
return 0;
}
It throws an exception saying Big Integer cannot be cast to java.lang.Long
Is there a way I can retrieve the value while keeping it in long?
((Number)em.createNativeQuery(sql).getSingleResult()).longValue()Numberwon't work.