1

I am very new to Java and Hibernate and after being taken from a Unix background to be handed a Java project with problems I need assistance please.

The project currently has Hibernate set up with criteria to search a database of document meta-data and currently assumes a "Unique Result", with this line of code;

doc = (DocumentDetails) criteria.uniqueResult();

Meaning, I think, it expects only one document's details as a result. But we now can have multiple possible documents' details returned and I need to place them into an ArrayList to determine which one is the latest document.

Any assistance would be appreciated on how to do this. I apologise for me being forward but I need to solve this one quick.

2 Answers 2

4
List<DocumentDetails> result = criteria.list();

As simple as that. Hibernate is documented.

Sign up to request clarification or add additional context in comments.

Comments

2
ArrayList<DocumentDetails> doc = (ArrayList<DocumentDetails>) criteria.list();

2 Comments

Hi Szajba, thanks for that. Do you mean simply replacing the line of code I listed above with this one will place all results into the ArrayList?
Yes you will get an ArrayList of DocumentDetails objects

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.