karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject [14/35] karaf-boot git commit: Add a JPA sample
Date Mon, 09 May 2016 14:48:33 GMT
Add a JPA sample

Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/19a1877c
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/19a1877c
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/19a1877c

Branch: refs/heads/master
Commit: 19a1877cc571586ad28263c78669e1237a6bf71c
Parents: dd56eb8
Author: Guillaume Nodet <gnodet@apache.org>
Authored: Thu Apr 14 20:43:53 2016 +0200
Committer: Guillaume Nodet <gnodet@apache.org>
Committed: Thu Apr 14 20:43:53 2016 +0200

----------------------------------------------------------------------
 .../karaf-boot-sample-jpa/README.md             | 23 +++++++
 .../karaf-boot-sample-jpa/pom.xml               | 47 ++++++++++++++
 .../src/main/java/sample/jpa/Task.java          | 65 ++++++++++++++++++++
 3 files changed, 135 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/19a1877c/karaf-boot-samples/karaf-boot-sample-jpa/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-jpa/README.md b/karaf-boot-samples/karaf-boot-sample-jpa/README.md
new file mode 100644
index 0000000..3a3f6a3
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-jpa/README.md
@@ -0,0 +1,23 @@
+== karaf-boot-sample-jpa ==
+
+This sample shows how to define a JPA bundle and generate the persistent unit.
+
+= Design
+
+A Task entity is defined and annotated with the persistent unit annotations.
+
+= Build
+
+To build, simply do:
+
+  mvn clean install
+
+= Deploy
+
+To deploy i:
+
+* you can drop the generated jar file (target/karaf-boot-sample-jpa-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+  bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-jpa/1.0
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/19a1877c/karaf-boot-samples/karaf-boot-sample-jpa/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-jpa/pom.xml b/karaf-boot-samples/karaf-boot-sample-jpa/pom.xml
new file mode 100644
index 0000000..032396f
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-jpa/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.karaf.boot</groupId>
+    <artifactId>karaf-boot-sample-jpa</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.karaf.boot</groupId>
+            <artifactId>karaf-boot-starter-jpa</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.karaf.boot</groupId>
+                <artifactId>karaf-boot-maven-plugin</artifactId>
+                <version>${project.version}</version>
+                <extensions>true</extensions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/19a1877c/karaf-boot-samples/karaf-boot-sample-jpa/src/main/java/sample/jpa/Task.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-jpa/src/main/java/sample/jpa/Task.java b/karaf-boot-samples/karaf-boot-sample-jpa/src/main/java/sample/jpa/Task.java
new file mode 100644
index 0000000..63995c0
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-jpa/src/main/java/sample/jpa/Task.java
@@ -0,0 +1,65 @@
+/**
+ *  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 sample.jpa;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.karaf.boot.jpa.Hibernate;
+import org.apache.karaf.boot.jpa.PersistentUnit;
+import org.apache.karaf.boot.jpa.Property;
+import org.apache.karaf.boot.jpa.Provider;
+
+@PersistentUnit(name = "tasklist", provider = Provider.Hibernate, properties = {
+        @Property(name = "hibernate.hbm2ddl.auto", value = "create-drop")
+})
+@Hibernate.Dialect(Hibernate.DialectType.HSQL)
+@Entity
+@XmlRootElement
+public class Task {
+    @Id
+    Integer id;
+    String title;
+
+    public Task() {
+    }
+
+
+    public Task(Integer id, String title) {
+        super();
+        this.id = id;
+        this.title = title;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = new Integer(id);
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+}


Mime
View raw message