Storing data(java object) in couchbase

551 views Asked by At

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.

1

There are 1 answers

0
Laurent Doguin On

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.