Dema
Dema

Reputation: 6887

Using ProperCase convention with Morphia and MongoDB

For legacy reasons (the database was created originally using .NET classes) my MongoDB documents all use ProperCase naming convention.

Is there a way to instruct Morphia to serialize/deserialize documents respecting this convention even if my properties on my POJOs are declared using camelCase, so I don't need to annotate all fields with @Property?

Right now, I am having to write this:

public class User {

  @Property("Name")
  public String name;

  @Property("Email")
  public String email;

  @Property("FacebookId")
  public String facebookId;

  ... 
}

Upvotes: 0

Views: 94

Answers (1)

evanchooly
evanchooly

Reputation: 6233

There is no way currently to configure morphia like that. Morphia uses the field name by default so you could name your java fields that way and morphia would pick them up but then you'd be violating the standard Java conventions.

Upvotes: 1

Related Questions