-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
R-05 Adding repo support - still not running
- Loading branch information
1 parent
75e629a
commit 8916f45
Showing
5 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.ps.reactive.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.cassandra.config.AbstractCassandraConfiguration; | ||
import org.springframework.data.cassandra.repository.config.EnableReactiveCassandraRepositories; | ||
|
||
@Configuration | ||
@EnableReactiveCassandraRepositories( | ||
basePackages = { | ||
"com.ps.db.cassandra" | ||
}) | ||
public class CassandraConfig extends AbstractCassandraConfiguration { | ||
|
||
protected String getKeyspaceName() { | ||
return "keyspace"; | ||
} | ||
|
||
public String[] getEntityBasePackages() { | ||
return new String[]{"com.ps.db.cassandra"}; | ||
} | ||
} | ||
|
36 changes: 36 additions & 0 deletions
36
src/main/java/com/ps/reactive/config/PostgresR2DBCConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.ps.reactive.config; | ||
|
||
import io.r2dbc.spi.ConnectionFactories; | ||
import io.r2dbc.spi.ConnectionFactory; | ||
import io.r2dbc.spi.ConnectionFactoryOptions; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.cassandra.repository.config.EnableReactiveCassandraRepositories; | ||
import org.springframework.data.r2dbc.core.DefaultReactiveDataAccessStrategy; | ||
import org.springframework.data.r2dbc.core.R2dbcEntityOperations; | ||
import org.springframework.r2dbc.core.DatabaseClient; | ||
|
||
import static io.r2dbc.spi.ConnectionFactoryOptions.*; | ||
|
||
@Configuration | ||
@EnableReactiveCassandraRepositories( | ||
basePackages = { | ||
"com.ps.db.postgres" | ||
}) | ||
public class PostgresR2DBCConfig { | ||
|
||
@Bean | ||
@Qualifier("postgres") | ||
public ConnectionFactory connectionFactory() { | ||
return ConnectionFactories.get( | ||
ConnectionFactoryOptions.builder() | ||
.option(DRIVER, "postgresql") | ||
.option(HOST, "localhost") | ||
.option(PORT, 5432) | ||
.option(USER, "postgres") | ||
.option(PASSWORD, "postgres") | ||
.option(DATABASE, "postgres") | ||
.build()); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/ps/reactive/db/cassandra/CassandraReactiveRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.ps.reactive.db.cassandra; | ||
|
||
import org.springframework.data.repository.reactive.ReactiveSortingRepository; | ||
|
||
public interface CassandraReactiveRepository extends ReactiveSortingRepository<Person, PersonKey> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.ps.reactive.db.cassandra; | ||
|
||
import lombok.Data; | ||
import org.springframework.data.cassandra.core.mapping.Column; | ||
import org.springframework.data.cassandra.core.mapping.PrimaryKey; | ||
import org.springframework.data.cassandra.core.mapping.Table; | ||
|
||
@Data | ||
@Table(value="people") | ||
public class Person { | ||
|
||
@PrimaryKey | ||
private PersonKey key; | ||
|
||
@Column(value="employment") | ||
private String employment; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.ps.reactive.db.cassandra; | ||
|
||
import lombok.Data; | ||
import org.springframework.data.cassandra.core.cql.Ordering; | ||
import org.springframework.data.cassandra.core.cql.PrimaryKeyType; | ||
import org.springframework.data.cassandra.core.mapping.PrimaryKeyClass; | ||
import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; | ||
|
||
import java.io.Serializable; | ||
|
||
@Data | ||
@PrimaryKeyClass | ||
public class PersonKey implements Serializable { | ||
@PrimaryKeyColumn(name = "city", ordinal = 0, type = PrimaryKeyType.PARTITIONED) | ||
private String city; | ||
|
||
@PrimaryKeyColumn(name = "lastname", ordinal = 1, type = PrimaryKeyType.CLUSTERED, ordering = Ordering.ASCENDING) | ||
private String lastName; | ||
|
||
@PrimaryKeyColumn(name = "firstname", ordinal = 2, type = PrimaryKeyType.CLUSTERED, ordering = Ordering.ASCENDING) | ||
private String firstName; | ||
|
||
@PrimaryKeyColumn(name = "email", ordinal = 3, type = PrimaryKeyType.CLUSTERED, ordering = Ordering.ASCENDING) | ||
private String email; | ||
} |