|
Java форум JavaTalks форум программистов
|
|
|
|
| Предыдущая тема :: Следующая тема |
| Автор |
Сообщение |
aint : 95 Новичок Откуда: Ukraine.Shit city
|
Фев 05, 2012 15:25 |
|
|
Достаю объект по id. Если задать id не существующей истории, то вместо null, хибер возвращает объект story с заданным id, который успешно проходит проверку на null.
| Код: |
story = storyDAO.getElementByID(storyId);
if (story != null) {
System.out.println("------STORY.id = " + story.getId());
System.out.println("------STORY: " + story); // org.hibernate.ObjectNotFoundException: No row with the given identifier exists
...
|
Почему хибер возвращает не null и как с этим бороться без очередного try-catch? |
|
|
|
 |
aint : 95 Новичок Откуда: Ukraine.Shit city
|
Фев 05, 2012 19:46 |
|
|
нашел на stack overflow
| Цитата: |
If load() can’t find the object in the cache or database, an exception is thrown. The load() method never returns null. The get() method returns null if the object can’t be found. |
Но сейчас нет возможности проверить. |
|
|
|
 |
|
|
|