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
CREATE KEYSPACE IF NOT EXISTS kc WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1' };
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>
<maven.compiler.source>${java.version}</maven.compiler.source>
<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>
<metrics.version>3.2.2</metrics.version>
<spring.version>5.0.0.RC2</spring.version>
<spring-data.version>Kay-M4</spring-data.version>
<spring.version>5.0.2.RELEASE</spring.version>
<spring-data-releasetrain.version>Kay-SR2</spring-data-releasetrain.version>
</properties>
<repositories>
@ -54,7 +54,7 @@
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId>
<version>1.4.6.RELEASE</version>
<version>${spring-data-releasetrain.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
@ -117,11 +117,7 @@
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-cassandra</artifactId>
<!-- 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>
<version>${org.datanucleus.version}</version>
</dependency>
<dependency>
@ -231,13 +227,13 @@
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<!-- version>${org.spring.release-train}</version -->
<version>2.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-keyvalue</artifactId>
<!-- version>${org.spring.release-train}</version -->
<version>2.0.5.RELEASE</version>
</dependency>
<dependency>
@ -457,7 +453,6 @@
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>5.0.0-release</version>
<configuration>
<api>JPA</api>
<persistenceUnitName>crud</persistenceUnitName>

View file

@ -8,6 +8,7 @@ import com.example.crud.entities.Product;
import org.datanucleus.ExecutionContext;
import org.datanucleus.enhancer.DataNucleusEnhancer;
import org.datanucleus.store.StoreManager;
import org.datanucleus.store.connection.ConnectionManager;
import org.datanucleus.store.connection.ManagedConnection;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -74,7 +75,8 @@ class ApplicationConfiguration {
@Bean
public Session session() {
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();
return session;
}

View file

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