Skip to content

SpEL Expressions in @Document annotations are not re-evaluated for query executions [DATAMONGO-1043] #1965

Closed
@spring-projects-issues

Description

@spring-projects-issues

Jordi Llach Fernandez opened DATAMONGO-1043 and commented

Based on the idea of Oliver Gierke in https://jira.spring.io/browse/DATAMONGO-525 I followed some post like the ones below

http://stackoverflow.com/questions/18129291/mongodb-and-spel-expressions-in-document-annotations
and
http://stackoverflow.com/questions/19807733/mongodb-multi-tenacy-spel-with-document?rq=1

but in the end I realized that the problem is that AbstractMongoQuery is cached between requests(maybe a problem in my config?), and its query-method object of type MongoQueryMethod, which holds the metadata, MongoEntityMetadata. And thus make this approach (use SpEL in @Document annotation) not fully working.

AbstractMongoQuery deals with different kind of executions. All of them but SingleEntityExecution suffers from this problem, and it's because in SingleEntityExecution mongoOperations is called without passing collectionName and thus letting, in the end, BasicMongoPersistentEntity.getCollection apply SpEL over entity class to obtain the runtime collection name.


Affects: 1.5.2 (Dijkstra SR2)

Reference URL: https://jira.spring.io/browse/DATAMONGO-525

Issue Links:

  • DATAMONGO-1320 Support dynamic collection with property
    ("is duplicated by")

Referenced from: pull request #238, and commits 8483f36, cbbafce, b5f7444

Backported to: 1.6.2 (Evans SR2), 1.5.5 (Dijkstra SR5)

1 votes, 4 watchers

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions