3
這有助於單元測試。要做到這一點有沒有如何以編程方式讓eclipselink刪除並創建所有表?
這有助於單元測試。要做到這一點有沒有如何以編程方式讓eclipselink刪除並創建所有表?
以下應爲你工作:
ServerSession session = entityManager.unwrap(ServerSession.class);
SchemaManager schemaManager = new SchemaManager(session);
schemaManager.replaceDefaultTables(true, true);
的一種方法是執行SQL腳本生成的EclipseLink規定:
persistence.xml中 <property name="eclipselink.ddl-generation.output-mode" value="both"/>
我已經用我的數據庫銷燬代碼替換了您的代碼,但隨後測試失敗。爲什麼會這樣?我是否必須在事務內運行此代碼? – simpatico 2010-10-23 17:25:07
不應該在事務之外運行此代碼。 – 2010-10-26 16:22:23
(還沒有試過) – simpatico 2012-05-28 13:45:45