0
我試圖堅持很多數據,但我總是得到一個「memoryOutException」。 我已經嘗試沖洗,清除,關閉...所有的解決方案在SOF中提出的一切..沒有工作,我的記憶不斷增長,堅持/承諾進行得越來越慢...有Hibernate ogm內存泄漏? (或者不是很好)
使用public class Insersecao1 {
private static EntityManagerFactory emf;
private static SessionFactory factory;
public static void main(final String[] args) throws Exception {
File pathFile = new File("D:\\Dados lab\\Database-json");
AnalyzedCommit analyzedCommit = null;
emf = Persistence.createEntityManagerFactory("hikePu");
EntityManager entityManager = emf.createEntityManager();
entityManager.getTransaction().begin();
int count = 1;
for (File f : pathFile.listFiles()) {
analyzedCommit = ... ;
entityManager.persist(analyzedCommit);
if (count % 75 == 0) {
entityManager.getTransaction().commit();
entityManager.close();
entityManager = emf.createEntityManager(); //Tried create a new one
entityManager.getTransaction().begin();
}
count++;
System.out.println(count);
}
} }
在行家:
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-neo4j</artifactId>
<version>5.0.4.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.jbossts</groupId>
<artifactId>jbossjta</artifactId>
<version>4.16.6.Final</version>
</dependency>
,堅持:
<persistence-unit name="hikePu" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<properties>
<property name="hibernate.ogm.datastore.provider" value="neo4j_embedded" />
<property name="hibernate.ogm.datastore.database" value="EasyDB" />
<property name="hibernate.ogm.neo4j.database_path" value="D:\Dados lab\mydb" />
<!-- <property name="hibernate.ogm.neo4j.database_path" value="mydb" />-->
<property name="dbms.allow_format_migration" value="true" />
</properties>
</persistence-unit>