-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve casing of field names #187
Comments
The best would be not to touch field names at all. Or at least provide a command line switch that allows some backward-compatible mode. |
@joelittlejohn, do you have an opinion on this one? This is kind of blocker for us - we cannot upgrade to the latest version as it breaks compatibility with the previous... |
I see the problem here, but I'm concerned that you're treating the private field names as a public interface. The contract here is defined by the public members and the annotations present on those members. Putting that aside for now, I guess there are a couple of options here:
One thing that surprises me is that your Mongo library doesn't appear to understand Java Bean conventions. Which ORM library are you using to interact with Mongo? |
We are using spring and spring-data. The mongo library is:
While I agree that we should not be relying on any of the private field names, I also think that it makes sense to preserve names as they are in the JSON schema. When if "FTP" is not a proper field name in a Java class, "fTP" is even worse. Speaking of #126 - I see you discussed lots of different options before choosing to lowercase the first letter. But one I think was overlooked - what if enum is called TimeFormat while the field of that type will be timeFormat? Thanks |
Not sure I understand what you mean here. Can you elaborate? #126 involves a field, and enum, called TimeFormat. |
I think I'll investigate whether it's possible to use the fully qualified naming fix with CodeModel. This would solve #126 and allow us to leave these names alone. |
@Illapikov I have had a lot of success using Jongo with the class files generated by this project. It uses Jackson to map objects into Mongo BSON, so you get the names in the binding annotations, instead of the bean names. The project is also super receptive to patches, so you can get changes in if you need them. |
I can second @ctrimble's recommendation. I've used Jongo on the most recent projects I've worked on (the ones that combine Java and Mongo anyway) and it's by far the best API for persistence & data-binding for Mongo that I have found. |
While Jongo seems to be a nice library, it would be a huge change from what we have at the moment. We will have to replace all the repositories generated for us by spring data (http://docs.spring.io/spring-data/data-commons/docs/1.6.1.RELEASE/reference/html/repositories.html) which we then extensively customized with some lower-level code. |
And thanks a lot for that! ) |
@dimas, one other thought. The spring mapping documentation states that they support a |
@ctrimble, interesting, thanks. |
We used 0.3.7 version and tried to update to newest(0.4.2) version.
Schema look like:
Generated sources was (0.3.7):
Generated sources are (0.4.2):
We use mongo to store our data.
In mongo it was (0.3.7):
In mongo it is (0.4.2):
So mongo mapper tried to find ABC field in java class and we are losing all data, which generated before update.
Possible solution: if property name all in uppercase left it without replacing first to lowercase.
Related to: #126
The text was updated successfully, but these errors were encountered: