Am I supposed to call EntityManager.clear() often to avoid memory leaks?

后端 未结 3 1177
滥情空心
滥情空心 2021-01-12 03:39

I\'m new to JPA/OpenJPA and I noticed that if I don\'t call EntityManager.clear() after i persist entities I get an OutOfMemoryError (I keep adding

3条回答
  •  遥遥无期
    2021-01-12 04:26

    I don't have much experience with JPA. However this'll be useful -
    In JPA you must either:
    - Create a new EntityManager for each transaction.
    - Call clear() after each transaction to clear the persistence context.

提交回复
热议问题