- 리스트를 가져온후 곧바로 guestList.size()를 사용했을 경우 나는 오류
- List<GuestBookTable> detached = pm.detachCopy(guestBookList); if(detached.size()>0)...이렇게 사용
- 해결책이 이것이 아닌 것 같음 일단 보류...
While learning to use JDO with datanucleus for a project to be run in app engine I tried to implement a method that gets a collection of persistant objects from the database. Trying to test the results I used the
The solution is simple. To iterate throw the objects of the collection, they have to be in a detached state, not in persistant state.
So the code in the dao class would look like:
size()
method on the collection. The result was following exception:
org.datanucleus.exceptions.NucleusUserException: Object Manager has been closed
at org.datanucleus.ObjectManagerImpl.assertIsOpen(ObjectManagerImpl.java:3816)
at org.datanucleus.ObjectManagerImpl.findObjectUsingAID(ObjectManagerImpl.java:2073)
....
The solution is simple. To iterate throw the objects of the collection, they have to be in a detached state, not in persistant state.
So the code in the dao class would look like:
public CollectiongetAllValueObjects() { Collection results = Collections.checkedCollection(getJdoTemplate().find(ValueObject.class), ValueObject.class); // To iterate the collection it has to be detached getPersistenceManager().detachCopyAll(results); return results; }
댓글 없음:
댓글 쓰기