Announcement Announcement Module
Collapse
No announcement yet.
Error with 'MongoRepository.exists', returns false while entity exists Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error with 'MongoRepository.exists', returns false while entity exists

    In a service class where I am checking for user existence I have the next problem. When I call userRepository.exists it returns false while the user realy exists. Trying to debug this:

    Code:
    User user = userRepository.findOne( userId );
    Assert.isTrue( userRepository.exists( userId ), "User must exist." );
    I can see that 'user' with 'userId' is retrieved from database while the assert throws an exception.

    What can be the problem?

    P.D.- I am building my app. with spring-data 1.0.0.M3.

  • #2
    What does your entity class look like?

    Comment


    • #3
      It is very simple:

      Code:
      @Document
      public class User extends AuditedBean
      {
      	@Id
      	private String id;
      	@Indexed( unique = true )
      	private String email;
      	private String password;
      	@Indexed
      	private String name;
      	@Indexed
      	private String surname;
      	private State state;
      
      
      	// Getters and setters
      	// ...
      }
      Where State is an enum and AuditedBean is:

      Code:
      public abstract class AuditedBean implements Serializable
      {
      	private Date creationDate;
      	private String creationUserId;
      	
      	private Date modifiedDate;
      	private String modifiedUserId;
      
      	// Getters and setters
      	// ...
      }
      Thank you.

      Comment


      • #4
        Thanks, I just wanted to confirm my assumption. Here's the ticket: https://jira.springsource.org/browse/DATADOC-190

        Comment


        • #5
          Thank you. I'll wait for RC1.

          Comment

          Working...
          X