Results 1 to 5 of 5

Thread: Error with 'MongoRepository.exists', returns false while entity exists

  1. #1
    Join Date
    Jun 2011
    Posts
    11

    Default 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. #2
    Join Date
    Apr 2006
    Location
    Dresden, Germany
    Posts
    483

    Default

    What does your entity class look like?

  3. #3
    Join Date
    Jun 2011
    Posts
    11

    Default

    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.

  4. #4
    Join Date
    Apr 2006
    Location
    Dresden, Germany
    Posts
    483

    Default

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

  5. #5
    Join Date
    Jun 2011
    Posts
    11

    Default

    Thank you. I'll wait for RC1.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •