Commit 50fe14b6 authored by Øyvin Halfdan Thuv's avatar Øyvin Halfdan Thuv
Browse files

Changing to UUID for primary keys.

parent a4af119c
package statelessws;
import java.util.UUID;
public class Incident {
private final long id;
private final UUID id;
private final String name;
public Incident(long id, String name) {
public Incident(UUID id, String name) {
this.id = id;
this.name = name;
}
public long getId() {
public UUID getId() {
return id;
}
......
......@@ -5,6 +5,7 @@ import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
import java.util.concurrent.atomic.AtomicLong;
import java.util.UUID;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
......@@ -31,15 +32,17 @@ public class IncidentController {
/*
* USE storage;
* CREATE TABLE incident ( id int PRIMARY KEY, name text );
* CREATE TABLE incident ( id uuid PRIMARY KEY, name text );
* INSERT INTO incident (id, name) VALUES (0, 'Great incident');
*/
@RequestMapping("/incident")
@RequestMapping("/incidents")
public Incident incident() {
ResultSet incidents = session.execute("SELECT * FROM incident");
Row incident = incidents.one();
return new Incident(incident.getInt("id"),
return new Incident(incident.getUUID("id"),
incident.getString("name"));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment