Commit e02720c5e090acc2901ed6f58a429b2d4523f383
1 parent
e9888632
first database connection from the backend
Showing
5 changed files
with
53 additions
and
20 deletions
docker/wildfly/standalone.xml
| ... | ... | @@ -161,7 +161,7 @@ |
| 161 | 161 | <managed-scheduled-executor-service name="default" jndi-name="java:jboss/ee/concurrency/scheduler/default" context-service="default" hung-task-threshold="60000" keepalive-time="3000"/> |
| 162 | 162 | </managed-scheduled-executor-services> |
| 163 | 163 | </concurrent> |
| 164 | - <default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:jboss/datasources/ExampleDS" jms-connection-factory="java:jboss/DefaultJMSConnectionFactory" managed-executor-service="java:jboss/ee/concurrency/executor/default" managed-scheduled-executor-service="java:jboss/ee/concurrency/scheduler/default" managed-thread-factory="java:jboss/ee/concurrency/factory/default"/> | |
| 164 | + <default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:jboss/datasources/PostgreSQLDS" jms-connection-factory="java:jboss/DefaultJMSConnectionFactory" managed-executor-service="java:jboss/ee/concurrency/executor/default" managed-scheduled-executor-service="java:jboss/ee/concurrency/scheduler/default" managed-thread-factory="java:jboss/ee/concurrency/factory/default"/> | |
| 165 | 165 | </subsystem> |
| 166 | 166 | <subsystem xmlns="urn:jboss:domain:ejb3:4.0"> |
| 167 | 167 | <session-bean> | ... | ... |
services/Global/build.gradle
| ... | ... | @@ -11,14 +11,15 @@ dependencies { |
| 11 | 11 | "org.jboss.spec:jboss-javaee-7.0:1.1.0.Final", |
| 12 | 12 | "com.google.code.gson:gson:2.8.1", |
| 13 | 13 | "org.apache.httpcomponents:httpclient:4.5.3", |
| 14 | - "commons-io:commons-io:2.5", | |
| 15 | - "org.hibernate:hibernate-core:5.2.12.Final", | |
| 16 | - "org.hibernate:hibernate-entitymanager:4.3.6.Final" | |
| 14 | + "commons-io:commons-io:2.5" | |
| 17 | 15 | |
| 18 | 16 | compile group: 'org.postgresql', name: 'postgresql', version: '9.3-1100-jdbc4' |
| 19 | 17 | |
| 20 | 18 | providedCompile "org.slf4j:slf4j-api:1.7.25" |
| 21 | 19 | |
| 20 | + compileOnly group: 'org.hibernate', name: 'hibernate-core', version: '5.2.12.Final' | |
| 21 | + compileOnly group: 'org.hibernate', name: 'hibernate-entitymanager', version: '4.3.6.Final' | |
| 22 | + | |
| 22 | 23 | testCompile "org.jboss.arquillian.junit:arquillian-junit-container:1.1.13.Final", |
| 23 | 24 | "junit:junit:4.12" |
| 24 | 25 | ... | ... |
services/Global/src/main/java/de/bht/beuthbot/entities/User.java
| 1 | 1 | package de.bht.beuthbot.entities; |
| 2 | 2 | |
| 3 | -import de.bht.beuthbot.persistence.JsonHelper; | |
| 4 | -import org.hibernate.annotations.Type; | |
| 5 | - | |
| 6 | 3 | import javax.persistence.Entity; |
| 7 | 4 | import javax.persistence.Table; |
| 8 | -import java.util.HashMap; | |
| 9 | -import java.util.Map; | |
| 10 | 5 | |
| 11 | 6 | /** |
| 12 | 7 | * Created by Benjamin Rühl on 19.11.2017. |
| 13 | 8 | */ |
| 14 | 9 | @Entity |
| 15 | -@Table | |
| 10 | +@Table(name = "user_entity") | |
| 16 | 11 | public class User extends EntityBase implements de.bht.beuthbot.model.entities.User { |
| 17 | 12 | |
| 18 | 13 | private String facebookUserId; |
| 19 | 14 | private String telegramUserId; |
| 20 | 15 | |
| 21 | - @Type(type = "JsonMapType") | |
| 22 | - private Map<String, String> additionalData = new HashMap<>(); | |
| 16 | + //@Type(type = "JsonMapType") | |
| 17 | + //private Map<String, String> additionalData = new HashMap<>(); | |
| 23 | 18 | |
| 24 | 19 | @Override |
| 25 | 20 | public String getFacebookUserId() { |
| ... | ... | @@ -32,20 +27,30 @@ public class User extends EntityBase implements de.bht.beuthbot.model.entities.U |
| 32 | 27 | } |
| 33 | 28 | |
| 34 | 29 | @Override |
| 35 | - public <T extends Object> T getProperty(String propertyName, Class<T> propertyType) { | |
| 30 | + public <T> T getProperty(String propertyName, Class<T> propertyType) { | |
| 31 | + return null; | |
| 32 | + } | |
| 33 | + | |
| 34 | + @Override | |
| 35 | + public void setProperty(String propertyName, Object propertyValue) { | |
| 36 | + | |
| 37 | + } | |
| 38 | + | |
| 39 | + //@Override | |
| 40 | + /*public <T extends Object> T getProperty(String propertyName, Class<T> propertyType) { | |
| 36 | 41 | String propertyValue = additionalData.getOrDefault(propertyName, null); |
| 37 | 42 | |
| 38 | 43 | if (propertyValue == null) |
| 39 | 44 | return null; |
| 40 | 45 | |
| 41 | 46 | return (T) JsonHelper.fromJson(propertyValue, propertyType); |
| 42 | - } | |
| 47 | + }*/ | |
| 43 | 48 | |
| 44 | - @Override | |
| 45 | - public void setProperty(String propertyName, Object propertyValue) { | |
| 49 | + //@Override | |
| 50 | + /*public void setProperty(String propertyName, Object propertyValue) { | |
| 46 | 51 | String valueAsJson = JsonHelper.toJson(propertyValue, propertyValue.getClass()); |
| 47 | 52 | additionalData.put(propertyName, valueAsJson); |
| 48 | - } | |
| 53 | + }*/ | |
| 49 | 54 | |
| 50 | 55 | public void setFacebookUserId(String facebookUserId) { |
| 51 | 56 | this.facebookUserId = facebookUserId; | ... | ... |
services/Global/src/main/java/de/bht/beuthbot/persistence/UserManager.java
| ... | ... | @@ -6,10 +6,10 @@ import javax.ejb.Stateless; |
| 6 | 6 | import javax.persistence.EntityManager; |
| 7 | 7 | import javax.persistence.PersistenceContext; |
| 8 | 8 | |
| 9 | -@Stateless | |
| 9 | +//@Stateless | |
| 10 | 10 | public class UserManager { |
| 11 | 11 | |
| 12 | - @PersistenceContext(unitName="de.bht.beuthbot.jpa") | |
| 12 | + /*@PersistenceContext(unitName="PostgreSQLDS") | |
| 13 | 13 | protected EntityManager entityManager; |
| 14 | 14 | |
| 15 | 15 | public void createUser() { |
| ... | ... | @@ -18,5 +18,5 @@ public class UserManager { |
| 18 | 18 | user.setTelegramUserId("TelegramUserId"); |
| 19 | 19 | |
| 20 | 20 | entityManager.persist(user); |
| 21 | - } | |
| 21 | + }*/ | |
| 22 | 22 | } | ... | ... |
services/Global/src/main/resources/META-INF/persistence.xml
0 → 100644
| 1 | +<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" | |
| 2 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 3 | + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence | |
| 4 | + http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd" | |
| 5 | + version="2.1"> | |
| 6 | + | |
| 7 | + <persistence-unit name="PostgreSQLDS" transaction-type="RESOURCE_LOCAL"> | |
| 8 | + | |
| 9 | + <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> | |
| 10 | + | |
| 11 | + <jta-data-source>java:jboss/datasources/PostgreSQLDS</jta-data-source> | |
| 12 | + | |
| 13 | + <class>de.bht.beuthbot.entities.User</class> | |
| 14 | + | |
| 15 | + <properties> | |
| 16 | + | |
| 17 | + <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/> <!-- DB Dialect --> | |
| 18 | + <property name="hibernate.hbm2ddl.auto" value="create-drop" /> <!-- create / create-drop / update / none --> | |
| 19 | + <property name="hibernate.archive.autodetection" value="class"/> | |
| 20 | + | |
| 21 | + <property name="hibernate.show_sql" value="true" /> <!-- Show SQL in console --> | |
| 22 | + <property name="hibernate.format_sql" value="true" /> <!-- Show SQL formatted --> | |
| 23 | + </properties> | |
| 24 | + | |
| 25 | + </persistence-unit> | |
| 26 | + | |
| 27 | +</persistence> | |
| 0 | 28 | \ No newline at end of file | ... | ... |