[jbosstools-commits] JBoss Tools SVN: r43475 - in workspace/akazakov/db/org.jboss.tools.common.db: META-INF and 9 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Sep 6 15:31:40 EDT 2012


Author: akazakov
Date: 2012-09-06 15:31:40 -0400 (Thu, 06 Sep 2012)
New Revision: 43475

Added:
   workspace/akazakov/db/org.jboss.tools.common.db/.classpath
   workspace/akazakov/db/org.jboss.tools.common.db/.project
   workspace/akazakov/db/org.jboss.tools.common.db/META-INF/
   workspace/akazakov/db/org.jboss.tools.common.db/META-INF/MANIFEST.MF
   workspace/akazakov/db/org.jboss.tools.common.db/build.properties
   workspace/akazakov/db/org.jboss.tools.common.db/lib/
   workspace/akazakov/db/org.jboss.tools.common.db/lib/antlr-2.7.7.jar
   workspace/akazakov/db/org.jboss.tools.common.db/lib/derby.jar
   workspace/akazakov/db/org.jboss.tools.common.db/lib/derbyclient.jar
   workspace/akazakov/db/org.jboss.tools.common.db/lib/derbynet.jar
   workspace/akazakov/db/org.jboss.tools.common.db/lib/derbytools.jar
   workspace/akazakov/db/org.jboss.tools.common.db/lib/dom4j-1.6.1.jar
   workspace/akazakov/db/org.jboss.tools.common.db/lib/hibernate-commons-annotations-4.0.1.Final.jar
   workspace/akazakov/db/org.jboss.tools.common.db/lib/hibernate-core-4.1.6.Final.jar
   workspace/akazakov/db/org.jboss.tools.common.db/lib/hibernate-entitymanager-4.1.6.Final.jar
   workspace/akazakov/db/org.jboss.tools.common.db/lib/hibernate-jpa-2.0-api-1.0.1.Final.jar
   workspace/akazakov/db/org.jboss.tools.common.db/lib/javassist-3.15.0-GA.jar
   workspace/akazakov/db/org.jboss.tools.common.db/lib/jboss-logging-3.1.0.GA.jar
   workspace/akazakov/db/org.jboss.tools.common.db/lib/jboss-transaction-api_1.1_spec-1.0.0.Final.jar
   workspace/akazakov/db/org.jboss.tools.common.db/plugin.xml
   workspace/akazakov/db/org.jboss.tools.common.db/src/
   workspace/akazakov/db/org.jboss.tools.common.db/src/META-INF/
   workspace/akazakov/db/org.jboss.tools.common.db/src/META-INF/persistence.xml
   workspace/akazakov/db/org.jboss.tools.common.db/src/org/
   workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/
   workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/
   workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/
   workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/
   workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/CommonDbPlugin.java
   workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/DBManager.java
   workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/
   workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/ModelObject.java
   workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/StartDBAction.java
Log:
Share project "org.jboss.tools.common.db" into "https://svn.jboss.org/repos/jbosstools"
https://issues.jboss.org/browse/JBIDE-12446

Added: workspace/akazakov/db/org.jboss.tools.common.db/.classpath
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/.classpath	                        (rev 0)
+++ workspace/akazakov/db/org.jboss.tools.common.db/.classpath	2012-09-06 19:31:40 UTC (rev 43475)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="lib" path="lib/derby.jar"/>
+	<classpathentry kind="lib" path="lib/derbyclient.jar"/>
+	<classpathentry kind="lib" path="lib/derbynet.jar"/>
+	<classpathentry kind="lib" path="lib/derbytools.jar"/>
+	<classpathentry kind="lib" path="lib/antlr-2.7.7.jar"/>
+	<classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/>
+	<classpathentry kind="lib" path="lib/hibernate-commons-annotations-4.0.1.Final.jar"/>
+	<classpathentry kind="lib" path="lib/hibernate-core-4.1.6.Final.jar"/>
+	<classpathentry kind="lib" path="lib/hibernate-entitymanager-4.1.6.Final.jar" sourcepath="/home/igels/Downloads/Java/JBoss/Hibernate/hibernate-release-4.1.6.Final/project"/>
+	<classpathentry kind="lib" path="lib/hibernate-jpa-2.0-api-1.0.1.Final.jar" sourcepath="/home/igels/Downloads/Java/JBoss/Hibernate/geronimo-jpa_2.0_spec-1.1-sources.jar">
+		<attributes>
+			<attribute name="javadoc_location" value="jar:file:/home/igels/Downloads/Java/JBoss/Hibernate/geronimo-jpa_2.0_spec-1.1-javadoc.jar!/"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="lib" path="lib/javassist-3.15.0-GA.jar"/>
+	<classpathentry kind="lib" path="lib/jboss-logging-3.1.0.GA.jar"/>
+	<classpathentry kind="lib" path="lib/jboss-transaction-api_1.1_spec-1.0.0.Final.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/.classpath
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/akazakov/db/org.jboss.tools.common.db/.project
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/.project	                        (rev 0)
+++ workspace/akazakov/db/org.jboss.tools.common.db/.project	2012-09-06 19:31:40 UTC (rev 43475)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.jboss.tools.common.db</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/.project
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/akazakov/db/org.jboss.tools.common.db/META-INF/MANIFEST.MF
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/META-INF/MANIFEST.MF	                        (rev 0)
+++ workspace/akazakov/db/org.jboss.tools.common.db/META-INF/MANIFEST.MF	2012-09-06 19:31:40 UTC (rev 43475)
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: CommonDb
+Bundle-SymbolicName: org.jboss.tools.common.db;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.jboss.tools.common.db.CommonDbPlugin
+Bundle-Vendor: Red Hat, Inc.
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.ui;bundle-version="3.7.0",
+ org.jboss.tools.common
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: org.jboss.tools.common.db
+Bundle-ClassPath: .,
+ lib/antlr-2.7.7.jar,
+ lib/derby.jar,
+ lib/derbyclient.jar,
+ lib/derbynet.jar,
+ lib/derbytools.jar,
+ lib/dom4j-1.6.1.jar,
+ lib/hibernate-commons-annotations-4.0.1.Final.jar,
+ lib/hibernate-core-4.1.6.Final.jar,
+ lib/hibernate-entitymanager-4.1.6.Final.jar,
+ lib/hibernate-jpa-2.0-api-1.0.1.Final.jar,
+ lib/javassist-3.15.0-GA.jar,
+ lib/jboss-logging-3.1.0.GA.jar,
+ lib/jboss-transaction-api_1.1_spec-1.0.0.Final.jar


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/META-INF/MANIFEST.MF
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/akazakov/db/org.jboss.tools.common.db/build.properties
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/build.properties	                        (rev 0)
+++ workspace/akazakov/db/org.jboss.tools.common.db/build.properties	2012-09-06 19:31:40 UTC (rev 43475)
@@ -0,0 +1,18 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml,\
+               lib/antlr-2.7.7.jar,\
+               lib/derby.jar,\
+               lib/derbyclient.jar,\
+               lib/derbynet.jar,\
+               lib/derbytools.jar,\
+               lib/dom4j-1.6.1.jar,\
+               lib/hibernate-commons-annotations-4.0.1.Final.jar,\
+               lib/hibernate-core-4.1.6.Final.jar,\
+               lib/hibernate-entitymanager-4.1.6.Final.jar,\
+               lib/hibernate-jpa-2.0-api-1.0.1.Final.jar,\
+               lib/javassist-3.15.0-GA.jar,\
+               lib/jboss-logging-3.1.0.GA.jar,\
+               lib/jboss-transaction-api_1.1_spec-1.0.0.Final.jar


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/build.properties
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/akazakov/db/org.jboss.tools.common.db/lib/antlr-2.7.7.jar
===================================================================
(Binary files differ)


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/lib/antlr-2.7.7.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: workspace/akazakov/db/org.jboss.tools.common.db/lib/derby.jar
===================================================================
(Binary files differ)


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/lib/derby.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: workspace/akazakov/db/org.jboss.tools.common.db/lib/derbyclient.jar
===================================================================
(Binary files differ)


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/lib/derbyclient.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: workspace/akazakov/db/org.jboss.tools.common.db/lib/derbynet.jar
===================================================================
(Binary files differ)


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/lib/derbynet.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: workspace/akazakov/db/org.jboss.tools.common.db/lib/derbytools.jar
===================================================================
(Binary files differ)


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/lib/derbytools.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: workspace/akazakov/db/org.jboss.tools.common.db/lib/dom4j-1.6.1.jar
===================================================================
(Binary files differ)


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/lib/dom4j-1.6.1.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: workspace/akazakov/db/org.jboss.tools.common.db/lib/hibernate-commons-annotations-4.0.1.Final.jar
===================================================================
(Binary files differ)


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/lib/hibernate-commons-annotations-4.0.1.Final.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: workspace/akazakov/db/org.jboss.tools.common.db/lib/hibernate-core-4.1.6.Final.jar
===================================================================
(Binary files differ)


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/lib/hibernate-core-4.1.6.Final.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: workspace/akazakov/db/org.jboss.tools.common.db/lib/hibernate-entitymanager-4.1.6.Final.jar
===================================================================
(Binary files differ)


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/lib/hibernate-entitymanager-4.1.6.Final.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: workspace/akazakov/db/org.jboss.tools.common.db/lib/hibernate-jpa-2.0-api-1.0.1.Final.jar
===================================================================
(Binary files differ)


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/lib/hibernate-jpa-2.0-api-1.0.1.Final.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: workspace/akazakov/db/org.jboss.tools.common.db/lib/javassist-3.15.0-GA.jar
===================================================================
(Binary files differ)


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/lib/javassist-3.15.0-GA.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: workspace/akazakov/db/org.jboss.tools.common.db/lib/jboss-logging-3.1.0.GA.jar
===================================================================
(Binary files differ)


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/lib/jboss-logging-3.1.0.GA.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: workspace/akazakov/db/org.jboss.tools.common.db/lib/jboss-transaction-api_1.1_spec-1.0.0.Final.jar
===================================================================
(Binary files differ)


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/lib/jboss-transaction-api_1.1_spec-1.0.0.Final.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: workspace/akazakov/db/org.jboss.tools.common.db/plugin.xml
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/plugin.xml	                        (rev 0)
+++ workspace/akazakov/db/org.jboss.tools.common.db/plugin.xml	2012-09-06 19:31:40 UTC (rev 43475)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+   	<extension
+         point="org.eclipse.ui.commands">
+      	<command
+            	categoryId="org.eclipse.ui.category.navigate"
+            	description="Common DB"
+            	id="org.jboss.tools.common.db.action"
+            	name="Common DB">
+      	</command>
+	</extension>
+
+   <extension
+         point="org.eclipse.ui.actionSets">
+      <actionSet
+            description="Common DB"
+            id="org.jboss.tools.common.db.actionSet"
+            label="Common DB"
+            visible="true">
+			<action id="runDB" 
+	      		style="push"
+				label="CommonD DB"
+                definitionId="org.jboss.tools.common.db.test"
+				menubarPath="navigate/open.ext2"
+	      		class="org.jboss.tools.common.db.test.StartDBAction">
+			</action>
+      </actionSet>
+   </extension>
+
+</plugin>


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/plugin.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/akazakov/db/org.jboss.tools.common.db/src/META-INF/persistence.xml
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/src/META-INF/persistence.xml	                        (rev 0)
+++ workspace/akazakov/db/org.jboss.tools.common.db/src/META-INF/persistence.xml	2012-09-06 19:31:40 UTC (rev 43475)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Persistence deployment descriptor for dev profile -->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" 
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" 
+             version="2.0">
+
+   <persistence-unit name="orgJbossToolsCommonDbEntityManagerFactory" transaction-type="RESOURCE_LOCAL">
+      <provider>org.hibernate.ejb.HibernatePersistence</provider>
+      <!--jta-data-source>java:/orgJbossToolsCommonDbDatasource</jta-data-source-->
+      <properties>
+        <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
+
+         <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/>
+         <!--property name="hibernate.hbm2ddl.auto" value="update"/-->
+         <property name="hibernate.hbm2ddl.auto" value="create">
+         <property name="hibernate.show_sql" value="true"/>
+         <property name="hibernate.format_sql" value="true"/>
+         <!--property name="jboss.entity.manager.factory.jndi.name" value="java:/orgJbossToolsCommonDbEntityManagerFactory"/-->
+      </properties>
+   </persistence-unit>
+
+</persistence>
\ No newline at end of file


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/src/META-INF/persistence.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/CommonDbPlugin.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/CommonDbPlugin.java	                        (rev 0)
+++ workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/CommonDbPlugin.java	2012-09-06 19:31:40 UTC (rev 43475)
@@ -0,0 +1,49 @@
+package org.jboss.tools.common.db;
+
+import java.sql.SQLException;
+
+import org.eclipse.swt.widgets.Display;
+import org.jboss.tools.common.log.BaseUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class CommonDbPlugin extends BaseUIPlugin {
+
+	public static final String PLUGIN_ID = "org.jboss.tools.cdi.core";
+
+	private static CommonDbPlugin plugin;
+
+	public CommonDbPlugin() {
+		plugin = this;
+	}
+
+	public static CommonDbPlugin getDefault() {
+		return plugin;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext bundleContext) throws Exception {
+		super.start(bundleContext);
+        Display.getDefault().asyncExec(new Runnable() {
+        	public void run() {
+				try {
+					DBManager.getInstance().start();
+				} catch (InstantiationException | IllegalAccessException
+						| ClassNotFoundException | SQLException e) {
+					logError(e);
+				}
+        	}
+        });
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext bundleContext) throws Exception {
+		DBManager.getInstance().stop();
+		super.stop(bundleContext);
+	}
+}
\ No newline at end of file


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/CommonDbPlugin.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/DBManager.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/DBManager.java	                        (rev 0)
+++ workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/DBManager.java	2012-09-06 19:31:40 UTC (rev 43475)
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.db;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.eclipse.core.runtime.IPath;
+import org.hibernate.ejb.Ejb3Configuration;
+import org.jboss.tools.common.db.test.ModelObject;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class DBManager {
+
+	private static final String entityManagerFactoryName = "orgJbossToolsCommonDbEntityManagerFactory";
+	private static final String driver = "org.apache.derby.jdbc.ClientDriver";
+	private static final String protocol = "jdbc:derby:";
+	private static final String dbName = "DB/derbyDB";
+	//	String protocol = "jdbc:derby:";
+
+	private static DBManager instance = new DBManager();
+
+	private static boolean started;
+	private String url;
+
+	private EntityManagerFactory emf;
+//	private EntityManager em;
+
+	private DBManager() {
+	}
+
+	public static DBManager getInstance() {
+		return instance;
+	}
+
+	public synchronized void start() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
+		if(started) {
+			return;
+		}
+		CommonDbPlugin.getDefault().getBundle().loadClass(driver).newInstance();
+		Properties props = new Properties();
+		CommonDbPlugin plugin = CommonDbPlugin.getDefault();
+		//The plug-in instance can be null at shutdown, when the plug-in is stopped. 
+		IPath path = plugin.getStateLocation();
+		File file = new File(path.toFile(), dbName); //$NON-NLS-1$
+		String location = file.getAbsolutePath();
+		url = protocol + location + ";create=true";
+		Connection conn = DriverManager.getConnection(url, props);
+		conn.close();
+		started = true;
+		init();
+	}
+
+	public EntityManager createEntityManager() {
+		try {
+			start();
+		} catch (InstantiationException | IllegalAccessException
+				| ClassNotFoundException | SQLException e) {
+			CommonDbPlugin.getDefault().logError(e);
+		}
+		EntityManager em = emf.createEntityManager();
+		return em;
+	}
+
+	private void init() {
+		Map<String, Object> configOverrides = new HashMap<String, Object>();
+		configOverrides.put("javax.persistence.jdbc.url", url);
+
+//		emf = Persistence.createEntityManagerFactory(entityManagerFactoryName, configOverrides);
+
+		Ejb3Configuration cfg = new Ejb3Configuration();
+		Ejb3Configuration configured = cfg.configure(entityManagerFactoryName, configOverrides);
+		configured.addAnnotatedClass(ModelObject.class);
+//		configured.setProperty("javax.persistence.jdbc.driver", driver);
+//		configured.setProperty("hibernate.dialect", "org.hibernate.dialect.DerbyDialect");
+//		configured.setProperty("hibernate.hbm2ddl.auto", "create");
+//		configured.setProperty("hibernate.show_sql", "true");
+//		configured.setProperty("hibernate.format_sql", "true");
+		emf = configured.buildEntityManagerFactory();
+	}
+
+	public synchronized void stop() {
+		if(!started) {
+			return;
+		}
+        try {
+        	emf.close();
+            DriverManager.getConnection("jdbc:derby:;shutdown=true");
+        } catch (SQLException e) {
+            if (((e.getErrorCode() != 50000) || (!"XJ015".equals(e.getSQLState()) ))) {
+            	//"Derby did not shut down normally"
+            	CommonDbPlugin.getDefault().logError(e);
+            } else {
+            	started = false;
+            }
+        }
+	}
+}
\ No newline at end of file


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/DBManager.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/ModelObject.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/ModelObject.java	                        (rev 0)
+++ workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/ModelObject.java	2012-09-06 19:31:40 UTC (rev 43475)
@@ -0,0 +1,49 @@
+package org.jboss.tools.common.db.test;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+ at Entity
+public class ModelObject implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	private long id;
+	private String name;
+
+	/**
+	 * @return the id
+	 */
+	@Id
+	@GeneratedValue
+	@Column
+	public long getId() {
+		return id;
+	}
+
+	/**
+	 * @param id the id to set
+	 */
+	public void setId(long id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the name
+	 */
+	@Column
+	public String getName() {
+		return name;
+	}
+
+	/**
+	 * @param name the name to set
+	 */
+	public void setName(String name) {
+		this.name = name;
+	}
+}
\ No newline at end of file


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/ModelObject.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/StartDBAction.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/StartDBAction.java	                        (rev 0)
+++ workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/StartDBAction.java	2012-09-06 19:31:40 UTC (rev 43475)
@@ -0,0 +1,46 @@
+package org.jboss.tools.common.db.test;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.jboss.tools.common.db.DBManager;
+
+public class StartDBAction implements IWorkbenchWindowActionDelegate {
+
+	@Override
+	public void run(IAction action) {
+		EntityManager em = DBManager.getInstance().createEntityManager();
+		em.getTransaction().begin();
+		ModelObject mo = new ModelObject();
+		mo.setName("testObject");
+		em.persist(mo);
+		em.getTransaction().commit();
+
+		em.getTransaction().begin();
+		System.out.println("Quearing...");
+		List results = em.createQuery("select o from ModelObject o where o.name='testObject'").getResultList();
+		for (Object object : results) {
+			System.out.println(((ModelObject)object).getId() + ": " + ((ModelObject)object).getName());
+		}
+		em.getTransaction().commit();
+
+		em.close();
+	}
+
+	@Override
+	public void selectionChanged(IAction action, ISelection selection) {
+	}
+
+	@Override
+	public void dispose() {
+	}
+
+	@Override
+	public void init(IWorkbenchWindow window) {
+	}
+}
\ No newline at end of file


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/StartDBAction.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain



More information about the jbosstools-commits mailing list