How to map mongodb collections on spring-data-mongodb when the names differ from your pojo definition


package com.wordpress.vrsbrazil;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

/*When collection name is different*/
@Document(collection="myCollectionName")
public class MyPojo {

@Id
public String id;

/*When field name is different*/
@Field("collectionFieldName")
public Integer myAttribute;

//getters and setters

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s