Closed dearrudam closed 1 year ago
Hey Max, if we look at the Id
annotation, it provides the_id
as default:
String value() default "_id";
Thus, the native name is id
on the database.
What Eclipse JNoSQL do in both case is convert the "field" to the native name, or if it does not find it will keep so:
Hey Otavio, thanks for the answer!
I didn't take a look at the mapping resolution implementation. Next time I'll take a look on it more deeply in order to understand more the whole process execution.
Again, thanks!
I'm going to close this issue.
@dearrudam there is no issue with asking Max.
Feel free to ask as much as you can/wish.
That is our pleasure to help.
Which JNoSQL project the issue refers to?
JNoSQL Databases
Bug description
During my work on PR: https://github.com/JNOSQL/demos-se/pull/36, I've tried to execute the
App4
class and some questions come to my mind, so, please, follow my thought:According to the
App4
class, it is expected that such one will store anUserScopePropertiesBroken
instance into the database and retrieve the stored one by using the fluent query interface where the"id"
field is equal to"user"
and the"scope"
is equal to"scope"
. It was expected to retrieve the persisted previously entity but anOptional.empty
returns instead.I believe this behavior is expected because the
"id"
string is not the name of theUserScopePropertiesBroken
attribute mapped with@Id
annotation: theuserName
attribute.I've replaced the
where
method argument with"userName"
and then I could retrieve the persisted entity previously. Everything is okay until now. Then I tried to use"_id"
instead of the"userName"
string and I could retrieve the persisted entity also.It looks like we could perform a query using
"userName"
or"_id"
to reference the id of the entity.Is this behavior expected?
Shouldn't this query fail because the annotated field with
@Id
has a different name?JNoSQL Version
1.0.0-SNAPSHOT
Steps To Reproduce
Start a CouchDB conteiner by running the following docker command:
Perform the
App4
changing thewhere
method argument with"id"
string: an Optional.empty should returns;Delete the persisted data or re-create the CouchDB container by executing step 1.
Perform the
App4
changing thewhere
method argument with"userName"
string: the persisted data should returns;Delete the persisted data or re-create the CouchDB container by executing step 1.
Perform the
App4
changing thewhere
method argument with"_id"
string: the persisted data should returns;Expected Results
Only the query execution with the
where
method with "userName" as argument should retrieve the expected persisted data.Code example, screenshot, or link to a repository