I keep finding both on here and Google people having troubles going from long
to int
and not the other way around. Yet I'm sure I'm not the only one that has run into this scenario before going from int
to Long
.
The only other answers I've found were "Just set it as Long in the first place" which really doesn't address the question.
I initially tried casting but I get a "Cannot cast from int to Long
"
for (int i = 0; i < myArrayList.size(); ++i ) {
content = new Content();
content.setDescription(myArrayList.get(i));
content.setSequence((Long) i);
session.save(content);
}
As you can imagine I'm a little perplexed, I'm stuck using int
since some content is coming in as an ArrayList
and the entity for which I'm storing this info requires the sequence number as a Long.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…