Matthew, Maybe this could also be of interest: http://projects.spring.io/spring-data-cassandra/
Cheers, Jens On Fri, Apr 24, 2015 at 12:50 PM, Phil Yang <[email protected]> wrote: > > > 2015-04-23 22:16 GMT+08:00 Matthew Johnson <[email protected]>: >> >> In HBase, we do something like: >> >> Put put = new Put(id); >> put.add(myPojo.getTimestamp(), myPojo.getValue()); >> put.add(myPojo.getMySecondTimestamp(), myPojo.getSecondValue()); >> server.put(put); >> >> Is there any similar mechanism in Cassandra Java driver for creating these >> inserts programmatically? Or, can the 'session.execute' take a list of >> commands so that each column can be inserted as its own insert statement >> but >> without the overhead of multiple calls to the server? >> >> > > For your first question, do you mean object-mapping API? > http://docs.datastax.com/en/developer/java-driver/2.1/java-driver/reference/crudOperations.html > > For the second question, C* can execute several commands by unlogged > batch, however, because of the distributed nature of Cassandra, there is a > better solution, see > https://medium.com/@foundev/cassandra-batch-loading-without-the-batch-keyword-40f00e35e23e > > > > >> Thanks! >> Matt >> >> >> -----Original Message----- >> From: Jim Witschey [mailto:[email protected]] >> Sent: 23 April 2015 14:46 >> To: [email protected] >> Subject: Re: Creating 'Put' requests >> >> Are prepared statements what you're looking for? >> >> >> http://docs.datastax.com/en/developer/java-driver/2.1/java-driver/quick_start/qsSimpleClientBoundStatements_t.html >> Jim Witschey >> >> Software Engineer in Test | [email protected] >> >> >> >> >> >> On Thu, Apr 23, 2015 at 9:28 AM, Matthew Johnson <[email protected] >> > >> wrote: >> > Hi all, >> > >> > >> > >> > Currently looking at switching from HBase to Cassandra, and one big >> > difference so far is that in HBase, we create a ‘Put’ object, add to >> > it a set of column/value pairs, and send the Put to the server. So far >> > in Cassandra 2.1.4 the tutorials seem to suggest using CQL3, which I >> > really like for prototyping eg: >> > >> > >> > >> > session.execute("INSERT INTO simplex.playlists (id, song_id, title, >> > album, >> > artist) VALUES (1,1,'La Petite Tonkinoise','Bye Bye >> > Blackbird','Joséphine Baker');"); >> > >> > >> > >> > But for more complicated code this will quickly become unmanageable, >> > and doesn’t lend itself well to dynamically creating row data based on >> > various conditions. Is there a way to send a Java object, populated >> > with the desired column/value pairs, to the server instead of executing >> an >> > insert statement? >> > Would this require some other library, or does the DataStax Java >> > driver support this already? >> > >> > >> > >> > Thanks in advance, >> > >> > Matt >> > >> > >> > > > > -- > Thanks, > Phil Yang > > -- Jens Rantil Backend engineer Tink AB Email: [email protected] Phone: +46 708 84 18 32 Web: www.tink.se Facebook <https://www.facebook.com/#!/tink.se> Linkedin <http://www.linkedin.com/company/2735919?trk=vsrp_companies_res_photo&trkInfo=VSRPsearchId%3A1057023381369207406670%2CVSRPtargetId%3A2735919%2CVSRPcmpt%3Aprimary> Twitter <https://twitter.com/tink>
