-
Type:
Improvement
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
A JDBC parameter renders as BSON undefined and carries no identity into the emitted command. MongoPreparedStatement recovers the parameter positions by walking the parsed command depth-first, and Hibernate binds the i-th JdbcParameterBinder into the i-th of those positions. The binder list is built separately, in the order visitParameter runs. The two orders are equal only by convention, and nothing compares them.
Anything that happens between visiting a node and rendering it can break the pairing: permuting translated expressions, using one translated node in two positions, or collecting named arguments into a sorted map. Two of the three fail silently and return wrong results rather than an error. A test whose arguments are all literals cannot detect any of them.
Make the pairing hold by construction. AstParameterMarker carries its own JdbcParameterBinder, AstNode.render takes a Consumer<JdbcParameterBinder>, and the marker appends its binder in the same statement that writes the undefined, so the binder list is produced by the rendering itself. Reordering, dropping and duplicating translated nodes then all behave correctly, and the translator stops imposing an ordering rule on the code that builds the AST.