hibernate-session

    0熱度

    1回答

    我還是不明白以下幾點: method xxx{ Teacher t=dao.get(new Teacher(1)); t.setName("mark"); finder.find(Teacher.class,null,null,null); dao.getSf().getCurrentSession().evict(t); t.setN

    0熱度

    1回答

    如果我把<query..>放在我的Car.hbm.xml中,我從(Session) HibernateUtil.getSessionFactory().getCurrentSession();返回的會話爲空,如果我從我的xml映射文件中刪除查詢,那麼會話不再爲空。 爲什麼我得到這個錯誤?我真的被這種問題困住了。 我得到這個XML映射: <hibernate-mapping package="at.

    1熱度

    1回答

    我有很多獨立的功能,我必須做一個session.clear()transaction.commit()在他們每一種釋放內存。 我可能是錯的,但我認爲,在transaction.commit()時,默認情況下不會調用hibernate中的session.clear()。 我想知道是否有任何方法我可以配置hibernate在每個transaction.commit()上執行清除自動會話,而無需執行se

    1熱度

    1回答

    我正在開發具有多個彈簧上下文的Web應用程序。它有一個保持業務邏輯,hibernate會話和應用程序的核心需求的主要上下文,其他上下文用於spring mvc綁定。通常,應用程序正常工作和一切,但是當我刷新主背景下,努力實現從其他上下文Hibernate的Session,Hibernate的Session拋出此異常: org.hibernate.HibernateException: No Ses

    18熱度

    1回答

    我有一個使用Hibernate 4和Spring Transactions的Spring 3.2應用程序。所有的方法工作得很好,我可以正確訪問數據庫來保存或檢索實體。 然後,我介紹了一些多線程,並且因爲每個線程訪問到DB我是從休眠收到以下錯誤: org.hibernate.HibernateException: Illegal attempt to associate a collection w

    2熱度

    2回答

    在Grails領域一個已經實現了beforeDelete如下 class Shop { def beforeDelete() { Shop.withNewSession { Client.findAllByShop(this)*.shop = null } } } 但客戶店空值不會保存到數據庫。 如果我添加手動會話沖洗 cl

    1熱度

    1回答

    我有簡單的Spring MVC - Hibernate應用程序,在連接到MySQL 5.5數據庫時工作正常(插入&讀取數據)。在將相同的應用程序連接到Oracle 10g時,它從數據庫中讀取記錄,但無法插入記錄。 在調試時,我發現會話的flushMode是MANUAL。保存記錄後,我明確寫了session.flush(),並且代碼在兩個數據庫中都開始正常工作。 我的問題 - 當我從休眠的docum

    1熱度

    1回答

    我試圖使用Hibernate的自動版本,但在更新方法F中的會議被稱爲我沒有看到在版本字段中輸入在查詢的WHERE子句也不是在數據庫中增加的版本。我正在做一些根本性的錯誤,但是什麼?調用sesssionFactory的getCurrentSession是個問題嗎? 我有以下的實體類: package dslibweb.model; import javax.persistence.Entity;

    10熱度

    4回答

    我想用spring測試框架來測試hibernate session的save()方法。 @Test方法是: @Test @Transactional public void testSave() { User expected = createUser(); getGenericDao().currentSession().save(expected); User actual = ge

    1熱度

    2回答

    我有以下方法,每隔幾秒插入一批大量的記錄。運行之後的一段時間,我得到的錯誤如下所示: ERROR: Communications link failure The last packet successfully received from the server was 523 milliseconds ago. The last packet sent successfully to the s