Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: MongoDB: Repository delete() not working

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

    Default

    Of course, because this is the one of latest milestone release.

  2. #12

    Default

    I switched to the github mongo schema and i currently use spring-data-mongodb-1.0.0.BUILD-20110404.083159-213.jar

    Can you give me a little example using the xml Konfiguration?

    My current context.xml is at the bottom, but with this some of my tests fail.

    I couldn't pass the converter to the mongotemplate as constructor argumennt, but as simple property.

    I assumed that the base package of converter should be the one of my domain classes,
    not of the repositories. I couldn't find any Documentation for that.

    Thank you very much

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"
    	xmlns:sec="http://www.springframework.org/schema/security" xmlns:cxf="http://cxf.apache.org/core" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
    	xmlns:mongo="http://www.springframework.org/schema/data/mongo"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
    	 http://www.springframework.org/schema/beans/spring-beans.xsd
    	 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    	 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
    	 http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd
    	 http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
         http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
         http://www.springframework.org/schema/data/mongo https://github.com/SpringSource/spring-data-document/raw/master/spring-data-mongodb/src/main/resources/org/springframework/data/document/mongodb/config/spring-mongo-1.0.xsd">
    
    <!-- 
    http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
     -->
    
    	<context:annotation-config />
    
    	<context:component-scan base-package="com...." />
    
    	<mongo:mongo id="mongo" host="${mongo.host}" port="27017">
    		<mongo:options autoConnectRetry="true" connectionsPerHost="10" threadsAllowedToBlockForConnectionMultiplier="5" maxWaitTime="12000" />
    	</mongo:mongo>
    
    	<mongo:repositories base-package="com.....repositories" mongo-template-ref="mongoTemplate" />
    
    	<bean id="mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate">
    		<constructor-arg name="mongo" ref="mongo" />
    		<constructor-arg name="databaseName" value="${mongo.database}" />
    		<constructor-arg name="defaultCollectionName" value="${mongo.collection}" />
    		<property name="converter" ref="converter" />
    	</bean>
    	
    	<mongo:mapping-converter 
    		id="converter" mongo-ref="mongo" 
    		mongo-template-ref="mongoTemplate" base-package="com.....domain"
    	/>
    	
    	<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
    
    </beans>

  3. #13

    Default

    delete() doesn't work again using the repositories in the current snapshot.

    The object is still in the database and no exception is thrown.

    if i use mongotemplate

    Code:
            mongoTemplate.findAndRemove("foo", new Query(Criteria.where("id").is(resource.getId())), Foo.class);
    it works

  4. #14
    Join Date
    Aug 2004
    Location
    New York, NY
    Posts
    74

    Default

    Hi,
    I realize the thread has been going on a while. We just released M2 and I believe this issue is fixed, if not we'll get on it ASAP.
    Mark

  5. #15

    Default

    it's fixed

  6. #16
    Join Date
    Apr 2011
    Posts
    2

    Default

    Funny enough, this bug still bites me. Downloaded 1.0.0M2 binaries and replaced data-commons with the nightly build directly from bamboo.

    Based on this release i was able to create and query documents. But removing or findAndRemoving still failed for me.

    All jar artifacts have been created around Sat Apr 09 18:57.

    Probably i should decide to finally switch to maven for dependency management. Any recommendation on a Maven plugin for Eclipse?

  7. #17

    Default

    Hi,

    i'm using "spring-data-mongodb" version "1.0.0.RC1".
    I discovered, deleting with "mongoTemplate.remove(Object object)" doesnt delete the object from the DB, but "mongoTemplate.remove(Object object, String collectionName)" does.

    Can anyone confirm this? I would say that this is a bug, isn't it?

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

    Default

    Would you mind trying 1.0.1.RELEASE?

  9. #19

    Default

    Thank you very much, Oliver.

    I didn't notice that there is a release version. I only grabbed the maven dependency snippet on the SpringData MongoDB website which still references spring-data-mongodb version 1.0.0.RC1. I expected the site to be up to date. :-)

    <dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-mongodb</artifactId>
    <version>1.0.0.RC1</version>
    </dependency>

  10. #20

    Default

    I'm having the same problem. I've upgraded to spring-data-mongodb 1.0.1.RELEASE. I can't get it to remove an object from the collection. I've tried both mongoTemplate.findAndRemove() methods. They are returning the right object, but the object is still in the collection. I've also tried all 4 mongoTemplate.remove() methods, but the object is still in the collection. Any ideas? Thanks!

Tags for this Thread

Posting Permissions

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