Announcement Announcement Module
No announcement yet.
Custom ID field in existing class for Mongo DB Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom ID field in existing class for Mongo DB

    I am stuck on a problem with defining custom ID field for Mongo entity. I cannot use the @Id annotation nor the id/_id field name since the class is not managed by me.

    Namely, I need to store nformation into Mongo DB and assume sessionId field as ID for MongoDB. Is there any way configure custom ID field by other means than modifying the document class itself?

    I am implementing Spring security SessionRegistry stored in Mongo DB (using spring-data-mongo).

    Thank you for any help.

  • #2
    You may be able to use aspectj to create an interTypeDeclaration like this:

    privileged aspect SessionIdAspect {
    declare @field: Session.sessionId: @Id;