Browse Source

fixing the persistence config. By default, use the container datasource

Kpacha 12 years ago
parent
commit
a715527077

+ 0 - 38
ninja/src/main/java/conf/application.conf

@@ -1,38 +0,0 @@
-##############################################################################
-# The main properties file to configure your application
-#
-# Properties can be prefixed by "%".
-# "%"" matches a mode you can set as system property. For instance when you
-# are using maven you can do: mvn -Dmode=test jetty:run
-#
-# Using that the following property:
-# %test.myproperty=test property
-# would overwrite the property
-# myproperty=my property
-#
-# You can define as many environments as you want. Simply set them in the mode.
-##############################################################################
-application.name=ninja test application
-
-application.cookie.prefix=NINJA
-
-#ISO Language Code, optionally followed by a valid ISO Country Code. 
-application.languages=en,de
-
-application.session.expire_time_in_seconds=3600
-application.session.send_only_if_changed=true
-application.session.transferred_over_https_only=false
-
-
-##############################################################################
-# Configure JPA
-# simply tell Ninja which persistence unit to use.
-# The persistence units are defined at META-INF/persistence.xml
-##############################################################################
-ninja.migration.run=false
-ninja.jpa.persistence_unit_name = mysql
-
-db.connection.url=jdbc:mysql://localhost/hello_world
-db.connection.username=benchmarkdbuser
-db.connection.password=benchmarkdbpass
-application.secret = b9z4AQO0huDRrJXFVjNiNXmSVqPSbcqjEiNjdPVBApb8n9GnxVjWBr9jp8tRfe73

+ 0 - 36
ninja/src/main/java/conf/messages.properties

@@ -1,36 +0,0 @@
-#
-# Copyright (C) 2012 the original author or authors.
-#
-# Licensed 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.
-#
-
-# This file is utf-8
-header.title=Ninja \u2764 JPA
-header.home=Home
-header.new=New
-header.login=Login
-header.logout=Logout
-
-login.username=Username / Email
-login.password=Password
-login.loginNowButton=Sign in
-
-login.errorLogin=Error. Username / password not valid.
-login.loginSuccessful=Login successful.
-login.logoutSuccessful=Logout successful.
-
-articleNew.pageTitle=Create new article
-articleNew.newArticle=New article
-articleNew.title=Title
-articleNew.content=Content
-articleNew.postNewArticle=Post now

+ 9 - 22
ninja/src/main/resources/META-INF/persistence.xml

@@ -5,8 +5,8 @@
 	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
 	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
 	version="2.0">
 	version="2.0">
 
 
-	<!-- The following config is an example config for mysql -->
-	<persistence-unit name="mysql-test" transaction-type="RESOURCE_LOCAL">
+	<!-- Direct mysql -->
+	<persistence-unit name="mysql" transaction-type="RESOURCE_LOCAL">
 		<provider>org.hibernate.ejb.HibernatePersistence</provider>
 		<provider>org.hibernate.ejb.HibernatePersistence</provider>
 
 
 		<properties>
 		<properties>
@@ -29,30 +29,17 @@
 		</properties>
 		</properties>
 	</persistence-unit>
 	</persistence-unit>
 
 
-	<!-- The following config is an example config for mysql -->
-	<persistence-unit name="mysql" transaction-type="RESOURCE_LOCAL">
+	<!-- Resin datasource -->
+	<persistence-unit name="resin" transaction-type="RESOURCE_LOCAL">
 		<provider>org.hibernate.ejb.HibernatePersistence</provider>
 		<provider>org.hibernate.ejb.HibernatePersistence</provider>
 		<jta-data-source>java:comp/env/jdbc/hello_world</jta-data-source>
 		<jta-data-source>java:comp/env/jdbc/hello_world</jta-data-source>
 
 
 		<properties>
 		<properties>
-			<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
-			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
-
-			<property name="hibernate.show_sql" value="false" />
-			<property name="hibernate.format_sql" value="false" />
-
-			<!-- Connection Pooling settings -->
-<!-- 			<property name="hibernate.connection.provider_class" -->
-<!-- 				value="org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider" /> -->
-			<property name="hibernate.connection.provider_class"
-				value="org.hibernate.connection.C3P0ConnectionProvider" />
-
-			<property name="hibernate.c3p0.max_size" value="100" />
-			<property name="hibernate.c3p0.min_size" value="0" />
-			<property name="hibernate.c3p0.acquire_increment" value="1" />
-			<property name="hibernate.c3p0.idle_test_period" value="300" />
-			<property name="hibernate.c3p0.max_statements" value="0" />
-			<property name="hibernate.c3p0.timeout" value="100" />
+			<property name="hibernate.connection.datasource" value="java:comp/env/jdbc/hello_world" />
+			<property name="hibernate.transaction.factory_class"
+				value="org.hibernate.transaction.JTATransactionFactory" />
+			<property name="hibernate.transaction.manager_lookup_class"
+				value="org.hibernate.transaction.ResinTransactionManagerLookup" />
 		</properties>
 		</properties>
 	</persistence-unit>
 	</persistence-unit>
 </persistence>
 </persistence>

+ 6 - 6
ninja/src/main/resources/conf/application.conf

@@ -23,18 +23,18 @@ application.session.expire_time_in_seconds=3600
 application.session.send_only_if_changed=true
 application.session.send_only_if_changed=true
 application.session.transferred_over_https_only=false
 application.session.transferred_over_https_only=false
 
 
-
 ##############################################################################
 ##############################################################################
 # Configure JPA
 # Configure JPA
 # simply tell Ninja which persistence unit to use.
 # simply tell Ninja which persistence unit to use.
 # The persistence units are defined at META-INF/persistence.xml
 # The persistence units are defined at META-INF/persistence.xml
 ##############################################################################
 ##############################################################################
 ninja.migration.run=false
 ninja.migration.run=false
-ninja.jpa.persistence_unit_name = mysql
-%test.ninja.jpa.persistence_unit_name = mysql-test
 
 
-# db.connection.url=jdbc:mysql://localhost/hello_world
+ninja.jpa.persistence_unit_name = resin
+
+%test.ninja.jpa.persistence_unit_name = mysql
 %test.db.connection.url=jdbc:mysql://localhost/hello_world
 %test.db.connection.url=jdbc:mysql://localhost/hello_world
-db.connection.username=benchmarkdbuser
-db.connection.password=benchmarkdbpass
+%test.db.connection.username=benchmarkdbuser
+%test.db.connection.password=benchmarkdbpass
+
 application.secret = b9z4AQO0huDRrJXFVjNiNXmSVqPSbcqjEiNjdPVBApb8n9GnxVjWBr9jp8tRfe73
 application.secret = b9z4AQO0huDRrJXFVjNiNXmSVqPSbcqjEiNjdPVBApb8n9GnxVjWBr9jp8tRfe73