[JAVA-3944] Bug while converting database attribute to POJO Created: 19/Jan/21 Updated: 21/Jan/21 Resolved: 21/Jan/21 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | POJO |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Kunal jani | Assignee: | Ross Lawley |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Java MongoDB Using Reactivestreams for Storing DataBase Attributes as a POJO Object |
||
| Documentation Changes Summary: |
| Description |
|
I have declared a variable private String transitNumber(using camel case) annotated with @BsonProperty("transit_number") in my POJO class. However, when I execute my query as in java MongoDB using reactive streams, the value of transitNumber = null is shown in the query result. But when I * declare my variable as *private TransitNumber transit_number(using snake case), the query result is being accurately returned. However, according to the Java conventions, all the variables must be declared in the camel case fornat. Can anyone explain to me why this happens? ** ** |
| Comments |
| Comment by Ross Lawley [ 21/Jan/21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I can't reproduce this issue. The following Pojo:
When using the following code adapted from the QuickTour it works as expected:
It outputs:
For that reason I'm closing this ticket as cannot reproduce. Should you be able to provide an example of it failing please comment on this ticket and I will investigate further. Ross | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Kunal jani [ 19/Jan/21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Test case 1: @BsonProperty("transit_number") private String transitNumber; Output: transitNumber = null; Test case 2: @BsonProperty("transit_number") private String transit_number; Output: transitNumber = "123456";
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ross Lawley [ 19/Jan/21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Kunal jani, Many thanks for the ticket. Could you provide more detail on the bug? Either a full stacktrace or a test case to reproduce the error. Ideally, a minimal reproducible example would help as I could replicate the bug and use it as a test case for the fix. Did you know the best place for asking questions is our MongoDB community portal, located here? All the best, Ross |