Benoy Prakash
Benoy Prakash

Reputation: 545

Storing data(java object) in couchbase

We are converting our, java + MySql application to couchbase, for that we are using spring-data and a couchbase server.

I am confused how the Java objects(Entity / POJO) needs to be saved on to the couchbase bucket.

I read that, i can't create one bucket per Entity, So shall i put all data on to one bucket and add a _class property so that i can identify the data bjects ?

Is that the right way? Please share any links or suggestions about the same.

Spring data with couchbase, This is the link i was using.

Upvotes: 1

Views: 595

Answers (1)

Laurent Doguin
Laurent Doguin

Reputation: 528

if you create objects through Spring Data Couchbase, they will automatically have this _class property. It is use by Spring Data to convert the Json object from Couchbase to a POJO. Using a type field (or the _class field added automatically by Spring Data)is indeed a good practice as it allows you to filter easily when creating views or using N1QL. Which is also how you will find objects of different types in the same bucket.

Upvotes: 2

Related Questions