empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r911183 - in /incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring: ./ src/main/java/org/apache/empire/samples/spring/ src/main/java/org/apache/empire/samples/spring/db/ src/main/java/org/apache/empire/samples/spring/suppor...
Date Wed, 17 Feb 2010 21:41:17 GMT
Author: doebele
Date: Wed Feb 17 21:41:17 2010
New Revision: 911183

URL: http://svn.apache.org/viewvc?rev=911183&view=rev
Log:
EMPIREDB-73

Added:
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/db/
  (with props)
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/db/SampleBean.java
  (with props)
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/db/SampleDB.java
  (with props)
Modified:
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/   (props changed)
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/pom.xml
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/EmpireAppImpl.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/support/EmpireDBException.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/resources/applicationContext.xml

Propchange: incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Feb 17 21:41:17 2010
@@ -0,0 +1,7 @@
+target
+
+.project
+
+.classpath
+
+.settings

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/pom.xml?rev=911183&r1=911182&r2=911183&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/pom.xml (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/pom.xml Wed Feb
17 21:41:17 2010
@@ -17,35 +17,28 @@
   specific language governing permissions and limitations
   under the License.
 -->
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
-         xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <artifactId>empire-db-examples</artifactId>
-        <groupId>org.apache.empire-db</groupId>
-        <version>2.0.6-incubating-SNAPSHOT</version>
-    </parent>
-    <groupId>org.apache.empire-db</groupId>
-    <artifactId>empire-db-example-spring</artifactId>
-    <name>Apache Empire-db Spring Example</name>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.apache.empire-db</groupId>
+		<artifactId>empire-db-examples</artifactId>
+		<version>2.0.6-incubating-SNAPSHOT</version>
+	</parent>
+	<groupId>org.apache.empire-db</groupId>
+	<artifactId>empire-db-example-spring</artifactId>
+	<name>Apache Empire-db Spring Example</name>
+	<description>Examples showing the use of empire-db with Spring.</description>
 
     <properties>
         <spring.version>3.0.0.M3</spring.version>
     </properties>
 
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.empire-db</groupId>
-            <artifactId>empire-db-example-basic</artifactId>
-            <version>2.0.6-incubating-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.empire-db</groupId>
-            <artifactId>empire-db</artifactId>
-            <version>2.0.6-incubating-SNAPSHOT</version>
-        </dependency>
-
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.empire-db</groupId>
+			<artifactId>empire-db</artifactId>
+		</dependency>
+		<!-- Spring -->
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-context</artifactId>
@@ -71,8 +64,50 @@
             <artifactId>commons-dbcp</artifactId>
             <version>1.2.2</version>
         </dependency>
-    </dependencies>
-    
+		
+		<!-- This dependency should be declared as runtime but the exec plugin is broken atm...
-->
+		<dependency>
+		    <groupId>hsqldb</groupId>
+		    <artifactId>hsqldb</artifactId>
+		    <!-- <scope>runtime</scope> -->
+		</dependency> 
+		<dependency>
+		    <groupId>postgresql</groupId>
+		    <artifactId>postgresql</artifactId>
+		    <version>8.3-603.jdbc3</version>
+		    <!-- <scope>runtime</scope> -->
+		</dependency> 
+		<dependency>
+		    <groupId>com.h2database</groupId>
+		    <artifactId>h2</artifactId>
+		    <version>1.1.107</version>
+		    <!-- <scope>runtime</scope> -->
+		</dependency> 
+		<dependency>
+		    <groupId>org.apache.derby</groupId>
+		    <artifactId>derby</artifactId>
+		    <version>10.4.2.0</version>
+		    <!-- <scope>runtime</scope> -->
+		</dependency> 
+
+		<!-- ojdbc 
+		<dependency>
+		    <groupId>ojdbc</groupId>
+		    <artifactId>ojdbc</artifactId>
+		    <version>14</version>
+		</dependency>
+		-->
+
+		<!-- msssql 
+		<dependency>
+		    <groupId>microsoft</groupId>
+		    <artifactId>sqljdbc</artifactId>
+		    <version>1.0</version>
+		</dependency>
+		-->
+		
+	</dependencies>
+
     <!-- better would be to add this repository in your settings.xml -->
     <repositories>
     	<repository>
@@ -81,4 +116,18 @@
 		    <url>http://s3.amazonaws.com/maven.springframework.org/milestone</url>
 		</repository>
     </repositories>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>exec-maven-plugin</artifactId>
+				<version>1.1.1</version>
+				<configuration>
+					<!-- <classpathScope>runtime</classpathScope> -->
+					<mainClass>org.apache.empire.samples.spring.SampleSpringApp</mainClass>
	
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
 </project>

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/EmpireAppImpl.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/EmpireAppImpl.java?rev=911183&r1=911182&r2=911183&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/EmpireAppImpl.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/EmpireAppImpl.java
Wed Feb 17 21:41:17 2010
@@ -33,8 +33,8 @@
 import org.apache.empire.db.h2.DBDatabaseDriverH2;
 import org.apache.empire.db.hsql.DBDatabaseDriverHSql;
 import org.apache.empire.db.postgresql.DBDatabaseDriverPostgreSQL;
-import org.apache.empire.samples.db.SampleBean;
-import org.apache.empire.samples.db.SampleDB;
+import org.apache.empire.samples.spring.db.SampleBean;
+import org.apache.empire.samples.spring.db.SampleDB;
 import org.apache.empire.samples.spring.support.EmpireDaoSupport;
 import org.apache.empire.xml.XMLWriter;
 import org.springframework.transaction.annotation.Transactional;

Propchange: incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/db/
------------------------------------------------------------------------------
    eol-style = native

Added: incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/db/SampleBean.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/db/SampleBean.java?rev=911183&view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/db/SampleBean.java
(added)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/db/SampleBean.java
Wed Feb 17 21:41:17 2010
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.samples.spring.db;
+
+
+/**
+ * The SampleBean class is used to demonstrate JavaBean support for SQL-Queries.
+ * The SampleBean is used in the SampleApp's queryRecords function.
+ */
+public class SampleBean
+{
+    private int    employeeId;
+    private String fullName;
+    private String gender;
+    private String phoneNumber;
+    private String department;
+    private String businessUnit;
+
+    /*
+     * Uncomment this if you want to use constructor instead of setters
+     * However, number of arguments and data types must match query!
+     *
+    public SampleBean(int employeeId, String fullName, String gender, String phoneNumber,
String department, String businessUnit)
+    {
+        this.employeeId = employeeId;
+        this.fullName = fullName;
+        this.gender = gender;
+        this.phoneNumber = phoneNumber;
+        this.department = department;
+        this.businessUnit = businessUnit;
+    }
+    */
+    
+    public int getEmployeeId()
+    {
+        return employeeId;
+    }
+
+    public void setEmployeeId(int employeeId)
+    {
+        this.employeeId = employeeId;
+    }
+
+    public String getFullName()
+    {
+        return fullName;
+    }
+
+    public void setFullName(String fullName)
+    {
+        this.fullName = fullName;
+    }
+
+    public String getGender()
+    {
+        return gender;
+    }
+
+    public void setGender(String gender)
+    {
+        this.gender = gender;
+    }
+
+    public String getPhoneNumber()
+    {
+        return phoneNumber;
+    }
+
+    public void setPhoneNumber(String phoneNumber)
+    {
+        this.phoneNumber = phoneNumber;
+    }
+
+    public String getDepartment()
+    {
+        return department;
+    }
+
+    public void setDepartment(String department)
+    {
+        this.department = department;
+    }
+
+    public String getBusinessUnit()
+    {
+        return businessUnit;
+    }
+
+    public void setBusinessUnit(String businessUnit)
+    {
+        this.businessUnit = businessUnit;
+    }
+
+    @Override
+    public String toString()
+    {
+        StringBuffer buf = new StringBuffer();
+        buf.append(employeeId);
+        buf.append("\t");
+        buf.append(fullName);
+        buf.append("\t");
+        buf.append(gender);
+        buf.append("\t");
+        buf.append(department);
+        buf.append("\t");
+        buf.append(businessUnit);
+        return buf.toString();
+    }
+    
+}

Propchange: incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/db/SampleBean.java
------------------------------------------------------------------------------
    eol-style = native

Propchange: incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/db/SampleBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/db/SampleDB.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/db/SampleDB.java?rev=911183&view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/db/SampleDB.java
(added)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/db/SampleDB.java
Wed Feb 17 21:41:17 2010
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.samples.spring.db;
+
+import org.apache.empire.commons.Options;
+import org.apache.empire.data.DataType;
+import org.apache.empire.data.DataMode;
+import org.apache.empire.db.DBColumn;
+import org.apache.empire.db.DBDatabase;
+import org.apache.empire.db.DBTable;
+import org.apache.empire.db.DBTableColumn;
+
+/**
+ * <PRE>
+ * This file contains the definition of the data model in Java.
+ * The SampleDB data model consists of two tables and a foreign key relation.
+ * The tables are defined as nested classes here, but you may put the in separate files if
you want.
+ *
+ * PLEASE NOTE THE NAMING CONVENTION:
+ * Since all tables, views and columns are declared as "final" constants they are all in
upper case.
+ * We recommend using a prefix of T_ for tables and C_ for columns in order to keep them
together
+ * when listed in your IDE's code completion.
+ * There is no need to stick to this convention but it makes life just another little bit
easier.
+ *
+ * You may declare other database tables or views in the same way.
+ * </PRE>
+ */
+public class SampleDB extends DBDatabase
+{
+    /**
+     * This class represents the definition of the Departments table.
+     */
+    public static class Departments extends DBTable
+    {
+        public final DBTableColumn DEPARTMENT_ID;
+        public final DBTableColumn NAME;
+        public final DBTableColumn HEAD;
+        public final DBTableColumn BUSINESS_UNIT;
+        public final DBTableColumn UPDATE_TIMESTAMP;
+
+        public Departments(DBDatabase db)
+        {
+            super("DEPARTMENTS", db);
+            // ID
+            DEPARTMENT_ID   = addColumn("DEPARTMENT_ID",    DataType.AUTOINC,       0, DataMode.AutoGenerated,
"DEP_ID_SEQUENCE");
+            NAME            = addColumn("NAME",             DataType.TEXT,         80, DataMode.NotNull);
+            HEAD            = addColumn("HEAD",             DataType.TEXT,         80, DataMode.Nullable);
+            BUSINESS_UNIT   = addColumn("BUSINESS_UNIT",    DataType.TEXT,          4, DataMode.NotNull,
"ITTK");
+            UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME,      0, DataMode.AutoGenerated);
+
+            // Primary Key
+            setPrimaryKey(DEPARTMENT_ID);
+            // Set other Indexes
+            addIndex("DEARTMENT_NAME_IDX", true, new DBColumn[] { NAME });
+            // Set timestamp column for save updates
+            setTimestampColumn(UPDATE_TIMESTAMP);
+        }
+    }
+
+    /**
+     * This class represents the definition of the Employees table.
+     */
+    public static class Employees extends DBTable
+    {
+        public final DBTableColumn EMPLOYEE_ID;
+        public final DBTableColumn SALUTATION;
+        public final DBTableColumn FIRSTNAME;
+        public final DBTableColumn LASTNAME;
+        public final DBTableColumn DATE_OF_BIRTH;
+        public final DBTableColumn DEPARTMENT_ID;
+        public final DBTableColumn GENDER;
+        public final DBTableColumn PHONE_NUMBER;
+        public final DBTableColumn EMAIL;
+        public final DBTableColumn SALARY;
+        public final DBTableColumn RETIRED;
+        public final DBTableColumn UPDATE_TIMESTAMP;
+
+        public Employees(DBDatabase db)
+        {
+            super("EMPLOYEES", db);
+            // ID
+            EMPLOYEE_ID     = addColumn("EMPLOYEE_ID",      DataType.AUTOINC,      0, DataMode.AutoGenerated,
"EMPLOYEE_ID_SEQUENCE");
+            SALUTATION      = addColumn("SALUTATION",       DataType.TEXT,        20, DataMode.Nullable);
+            FIRSTNAME       = addColumn("FIRSTNAME",        DataType.TEXT,        40, DataMode.NotNull);
+            LASTNAME        = addColumn("LASTNAME",         DataType.TEXT,        40, DataMode.NotNull);
+            DATE_OF_BIRTH   = addColumn("DATE_OF_BIRTH",    DataType.DATE,         0, DataMode.Nullable);
+            DEPARTMENT_ID   = addColumn("DEPARTMENT_ID",    DataType.INTEGER,      0, DataMode.NotNull);
+            GENDER          = addColumn("GENDER",           DataType.TEXT,         1, DataMode.Nullable);
+            PHONE_NUMBER    = addColumn("PHONE_NUMBER",     DataType.TEXT,        40, DataMode.Nullable);
+            EMAIL           = addColumn("EMAIL",            DataType.TEXT,        80, DataMode.Nullable);
+            SALARY          = addColumn("SALARY",           DataType.DECIMAL,   10.2, DataMode.Nullable);
+            RETIRED         = addColumn("RETIRED",          DataType.BOOL,         0, DataMode.NotNull,
false);
+            UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME,     0, DataMode.AutoGenerated);
+
+            // Primary Key
+            setPrimaryKey(EMPLOYEE_ID);
+            // Set other Indexes
+            addIndex("EMPLOYEE_NAME_IDX", true, new DBColumn[] { FIRSTNAME, LASTNAME, DATE_OF_BIRTH
});
+            // Set timestamp column for save updates
+            setTimestampColumn(UPDATE_TIMESTAMP);
+
+            // Create Options for GENDER column
+            Options genders = new Options();
+            genders.set("M", "Male");
+            genders.set("F", "Female");
+            GENDER.setOptions(genders);
+        }
+    }
+
+    // Declare all Tables and Views here
+    public final Departments  DEPARTMENTS = new Departments(this);
+    public final Employees    EMPLOYEES   = new Employees(this);
+
+    /**
+     * Constructor of the SampleDB data model description
+     *
+     * Put all foreign key relations here.
+     */
+    public SampleDB()
+    {
+        // Define Foreign-Key Relations
+        addRelation( EMPLOYEES.DEPARTMENT_ID.referenceOn( DEPARTMENTS.DEPARTMENT_ID ));
+    }
+
+}

Propchange: incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/db/SampleDB.java
------------------------------------------------------------------------------
    eol-style = native

Propchange: incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/db/SampleDB.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/support/EmpireDBException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/support/EmpireDBException.java?rev=911183&r1=911182&r2=911183&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/support/EmpireDBException.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/java/org/apache/empire/samples/spring/support/EmpireDBException.java
Wed Feb 17 21:41:17 2010
@@ -28,6 +28,11 @@
  */
 public class EmpireDBException extends UncategorizedDataAccessException {
 
+    /**
+     * Comment for <code>serialVersionUID</code>
+     */
+    private static final long serialVersionUID = 7451019261510054061L;
+
     public EmpireDBException(String msg, Throwable cause) {
         super(msg, cause);
     }

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/resources/applicationContext.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/resources/applicationContext.xml?rev=911183&r1=911182&r2=911183&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/resources/applicationContext.xml
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-spring/src/main/resources/applicationContext.xml
Wed Feb 17 21:41:17 2010
@@ -62,7 +62,7 @@
         <constructor-arg value="${empire.driver}"/>
         <constructor-arg value="${empire.schemaname}"/>
     </bean>
-    <bean id="sampleDatabase" class="org.apache.empire.samples.db.SampleDB">
+    <bean id="sampleDatabase" class="org.apache.empire.samples.spring.db.SampleDB">
     </bean>
 
     <!-- application dao/services -->



Mime
View raw message