This commit is contained in:
Gregory Burd 2018-03-26 09:23:28 -04:00
parent f2d926a3f8
commit 168ad3b424
4 changed files with 16 additions and 17 deletions

1
README
View file

@ -8,6 +8,7 @@ mvn clean compile -Dmaven.compiler.showDeprecation=true -Dmaven.compiler.showWar
https://www.one-tab.com/page/K4XlsjF2TyugqYE_8ORqxg https://www.one-tab.com/page/K4XlsjF2TyugqYE_8ORqxg
CREATE KEYSPACE IF NOT EXISTS kc WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1' };
https://apple.stackexchange.com/questions/215919/enable-multicast-on-mac https://apple.stackexchange.com/questions/215919/enable-multicast-on-mac

19
pom.xml
View file

@ -14,11 +14,11 @@
<java.version>1.8</java.version> <java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source> <maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target> <maven.compiler.target>${java.version}</maven.compiler.target>
<org.datanucleus.version>[5.1.0-m3, 5.9)</org.datanucleus.version> <org.datanucleus.version>5.1.0-release</org.datanucleus.version>
<aspectj.version>1.8.10</aspectj.version> <aspectj.version>1.8.10</aspectj.version>
<metrics.version>3.2.2</metrics.version> <metrics.version>3.2.2</metrics.version>
<spring.version>5.0.0.RC2</spring.version> <spring.version>5.0.2.RELEASE</spring.version>
<spring-data.version>Kay-M4</spring-data.version> <spring-data-releasetrain.version>Kay-SR2</spring-data-releasetrain.version>
</properties> </properties>
<repositories> <repositories>
@ -54,7 +54,7 @@
<dependency> <dependency>
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId> <artifactId>spring-data-releasetrain</artifactId>
<version>1.4.6.RELEASE</version> <version>${spring-data-releasetrain.version}</version>
<scope>import</scope> <scope>import</scope>
<type>pom</type> <type>pom</type>
</dependency> </dependency>
@ -117,11 +117,7 @@
<dependency> <dependency>
<groupId>org.datanucleus</groupId> <groupId>org.datanucleus</groupId>
<artifactId>datanucleus-cassandra</artifactId> <artifactId>datanucleus-cassandra</artifactId>
<!-- version>${org.datanucleus.version}</version --> <version>${org.datanucleus.version}</version>
<type>jar</type>
<scope>system</scope>
<version>5.1.0-m4-SNAPSHOT</version>
<systemPath>${project.basedir}/lib/datanucleus-cassandra-5.1.0-m4-SNAPSHOT.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
@ -231,13 +227,13 @@
<dependency> <dependency>
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId> <artifactId>spring-data-jpa</artifactId>
<!-- version>${org.spring.release-train}</version --> <version>2.0.5.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-data-keyvalue</artifactId> <artifactId>spring-data-keyvalue</artifactId>
<!-- version>${org.spring.release-train}</version --> <version>2.0.5.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
@ -457,7 +453,6 @@
<plugin> <plugin>
<groupId>org.datanucleus</groupId> <groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId> <artifactId>datanucleus-maven-plugin</artifactId>
<version>5.0.0-release</version>
<configuration> <configuration>
<api>JPA</api> <api>JPA</api>
<persistenceUnitName>crud</persistenceUnitName> <persistenceUnitName>crud</persistenceUnitName>

View file

@ -8,6 +8,7 @@ import com.example.crud.entities.Product;
import org.datanucleus.ExecutionContext; import org.datanucleus.ExecutionContext;
import org.datanucleus.enhancer.DataNucleusEnhancer; import org.datanucleus.enhancer.DataNucleusEnhancer;
import org.datanucleus.store.StoreManager; import org.datanucleus.store.StoreManager;
import org.datanucleus.store.connection.ConnectionManager;
import org.datanucleus.store.connection.ManagedConnection; import org.datanucleus.store.connection.ManagedConnection;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -74,7 +75,8 @@ class ApplicationConfiguration {
@Bean @Bean
public Session session() { public Session session() {
StoreManager storeManager = ((ExecutionContext)entityManager().getDelegate()).getNucleusContext().getStoreManager(); StoreManager storeManager = ((ExecutionContext)entityManager().getDelegate()).getNucleusContext().getStoreManager();
ManagedConnection connection = storeManager.getConnection(-1); ConnectionManager connectionManager = storeManager.getConnectionManager();
ManagedConnection connection = connectionManager.getConnection(-1);
Session session = (Session) connection.getConnection(); Session session = (Session) connection.getConnection();
return session; return session;
} }

View file

@ -1,5 +1,6 @@
package com.example.crud.repositories; package com.example.crud.repositories;
import com.codahale.metrics.annotation.Metered;
import com.datastax.driver.mapping.annotations.QueryParameters; import com.datastax.driver.mapping.annotations.QueryParameters;
import com.example.crud.entities.Inventory; import com.example.crud.entities.Inventory;
import org.datanucleus.api.jpa.annotations.ReadOnly; import org.datanucleus.api.jpa.annotations.ReadOnly;
@ -16,11 +17,11 @@ import java.util.List;
//@Metrics(registry = "${this.registry}") //@Metrics(registry = "${this.registry}")
public interface InventoryRepository extends JpaRepository<Inventory, String>, JpaSpecificationExecutor { public interface InventoryRepository extends JpaRepository<Inventory, String>, JpaSpecificationExecutor {
//@Metered(name = "${this.id}") @Metered(name = "${this.id}")
@Transactional @Transactional
@Cacheable(value = "inventory", key = "#name") @Cacheable(value = "inventory", key = "#name")
@QueryParameters(consistency="QUORUM") @QueryParameters(consistency="QUORUM")
//Query(value="select * from inventory where firstName = :name", nativeQuery=true) @Query(value="select * from inventory where firstName = :name", nativeQuery=true)
Inventory findByName(@Param("name") String name); Inventory findByName(@Param("name") String name);
@ReadOnly @ReadOnly
@ -30,9 +31,9 @@ public interface InventoryRepository extends JpaRepository<Inventory, String>, J
@Transactional @Transactional
@CacheEvict(value = "inventory", key = "#name") @CacheEvict(value = "inventory", key = "#name")
void deleteInventoryBy(String name); void deleteInventoryByName(String name);
@Transactional @Transactional
//CacheEvict(value = "inventory", key = "#name") @CacheEvict(value = "inventory", key = "#name")
<S extends String> S save(S s); <S extends String> S save(S s);
} }