scassandra / scassandra-server

Stubbed Cassandra
http://www.scassandra.org
Other
87 stars 34 forks source link

datastax mapper operations failing in Scassandra #63

Open ankit5858 opened 9 years ago

ankit5858 commented 9 years ago

We are trying to connect dataStax maaper with Scassandra server using java api but getting error NULL Pointer Exception.

It's seems that mapper initialization require keyspace metadata , which is seems to be not populated via session object and it is failing.

IS it possible using scassandra with mappers https://www.datastax.com/documentation/developer/java-driver/2.1/java-driver/reference/crudOperations.html

Code snippet

Test.java Cluster cluster=null; Session session=null; Employee emps=new Employee(); try{ cluster = Cluster.builder() .addContactPoint("127.0.0.1)" .withPort(8042) .build(); session = cluster.connect("employee"); System.out.println(session.getCluster().getClusterName()); System.out.println(session.getCluster().getMetadata().getKeyspaces());

Mapper mapper = new MappingManager(session).mapper(Employee.class)// getting problem here mapper.save(emps);

Employee Poja class @Table(name = "employees") public class Employee { @PartitionKey private String email; private String name; public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getName() { return name; } public void setName(String name) { this.name = name; }
}

chbatey commented 9 years ago

I've never tried using the mapping API against scassandra. I'll give it ago next week. Thanks for raising this.

chbatey commented 9 years ago

This will require priming of what ever system keyspaces the driver requires. As scassandra isn't aware of your schema then i think we can only document this.