org.eclipse.persistence.internal.jpa.EntityManagerImpl Java Examples
The following examples show how to use
org.eclipse.persistence.internal.jpa.EntityManagerImpl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataGenerator.java From olingo-odata2 with Apache License 2.0 | 6 votes |
/** * This method deletes data from JPA tables created. This method reads comma * separated SQL delete statements from DataDeleteSQLs properties files and * executes them in order. */ public void clean() { // Delete using SQLs String[] deleteStatements = getSQLDeleteStatements(); if (deleteStatements.length > 0) { // If configuration is proper with at least one delete Statements Session session = ((EntityManagerImpl) entityManager).getActiveSession(); entityManager.getTransaction().begin(); for (String deleteStatement : deleteStatements) { System.out.println("Cleaning - " + deleteStatement); SQLCall sqlCall = new SQLCall(deleteStatement); DataModifyQuery query = new DataModifyQuery(); query.setCall(sqlCall); session.executeQuery(query); } entityManager.getTransaction().commit(); } else { System.err.println("Delete configuration file doesn't have any delete statements."); } }
Example #2
Source File: DatabaseReadOnlyNetwork.java From BotLibre with Eclipse Public License 1.0 | 5 votes |
public DatabaseReadOnlyNetwork(EntityManager entityManager, boolean isShortTerm) { super(new EntityManagerImpl(entityManager.unwrap(ServerSession.class), SynchronizationType.UNSYNCHRONIZED), isShortTerm); ServerSession server = entityManager.unwrap(ServerSession.class); if (!server.getProperties().containsKey("network")) { server.setProperty("network", this); } }
Example #3
Source File: DataGenerator.java From olingo-odata2 with Apache License 2.0 | 5 votes |
/** * This method generates data to be used in the application. It does so by * reading properties file. Currently it iterates through comma separated * file names in file SQLInsertConfig and gets the insert statements from * those files in the order provided in the file. */ public void generate() { String[] resourceSQLPropFileNames = getSQLInsertFileNames(); if (resourceSQLPropFileNames.length > 0) { // If configuration is proper with at least one file Session session = ((EntityManagerImpl) entityManager).getActiveSession(); ResourceBundle[] resourceBundleArr = new ResourceBundle[resourceSQLPropFileNames.length]; entityManager.getTransaction().begin(); for (int i = 0; i < resourceSQLPropFileNames.length; i++) { // For each Entity SQL property file, System.out.println("Reading from File - " + resourceSQLPropFileNames[i]); resourceBundleArr[i] = ResourceBundle.getBundle(resourceSQLPropFileNames[i]);// Get SQL statements as properties Set<String> keySet = resourceBundleArr[i].keySet(); List<String> queryNames = new ArrayList<String>(keySet); Collections.sort(queryNames); for (String queryName : queryNames) { // while(keySet.hasMoreElements()) { String sqlQuery = resourceBundleArr[i].getString(queryName); System.out.println("Executing Query - " + sqlQuery); SQLCall sqlCall = new SQLCall(sqlQuery); DataModifyQuery query = new DataModifyQuery(); query.setCall(sqlCall); session.executeQuery(query); } } setMaterialInStore(); entityManager.flush(); entityManager.getTransaction().commit(); } }