I have a query that looks like this
Document document = DocDAO.getSession().read(someId);
MyFile file = (MyFile) DAO.getSession()
.createQuery("SELECT file FROM MyFile file WHERE file.document = :document AND file.version = :version")
.setParameter("document", document)
.setParameter("version", version)
.uniqueResult();
Now, I should get a file where file.getDocument().getId() == someId, and someId is a BigInteger. But unfortunately, they are not equal. What kind of errors can lead to the queried entity not being the entity I was looking for?
Cheers
Nik
BigInteger is an object, not a primitive. You may need to do
bigInt1.equals(bigInt2)rather thanbigInt1 == bigInt2.EDIT:
Maybe I’m wrong about that. Javadoc says:
EDIT AGAIN:
If you want to do away with BigInteger, try declaring your JPA entity attribute as a
Long(orlongif it is not nullable) and then use the@Columnannotation to define what the actual database column structure is if necessary. Here is an example of this annotation:I don’t remember exactly how to use the
lengthattribute when the column is numeric. Max number of digits? You can look up the details for@Columnand experiment until you get it right.