org.springframework.data.mapping.model.MappingException: Unknown persistent entity java.lang.String

StackOverflow https://stackoverflow.com/questions/23171050

  •  06-07-2023
  •  | 
  •  

Question

I've upgraded from Spring-data-Neo4j 3.0.0 to 3.0.1 to use the new Label feature. The derived finders (working with previous versions) are giving this exception :

org.springframework.data.mapping.model.MappingException: Unknown persistent entity java.lang.String

I can't find why does this happen :(

I've tried to add @Query("MATCH (e:Event) WHERE e.title = {0} RETURN e") over my repository finder but I'm getting the same exception

I think it's a Mongodb-Neo4j conflict because when I debug I see that in the invoke method of the JdkDynamicAopProxy, the proxy parameter is org.springframework.data.mongodb.repository.support.SimpleMongoRepository@3c8f3375 while My my entity is annotated with @NodeEntity and in the context configuration I have this :

<context:annotation-config/>
    <context:spring-configured/>
    <context:component-scan base-package="com.xxx"/>

    <!-- Neo4J -->

    <neo4j:config storeDirectory="D:/neo4j-enterprise-2.0.1/data/mydb" base-package="com.xxx.domain.graph" />
    <neo4j:repositories base-package="com.xxx.repository.graph" />


    <!-- MongoDB -->

    <!-- Factory bean that creates the Mongo instance --> 
    <mongo:mongo host="localhost" port="27017"> 
        <mongo:options
             connections-per-host="5"            
             connect-timeout="30000"
             max-wait-time="10000"           
             write-number="1"
             write-timeout="0"
             write-fsync="true"/>
    </mongo:mongo>

    <mongo:db-factory dbname="test" mongo-ref="mongo"/>

    <!-- MongoTemplate for connecting and quering the documents in the database -->  
    <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
        <constructor-arg ref="mongo"/>
        <constructor-arg name="databaseName" value="xxxx"/>
     </bean>
    <mongo:repositories base-package="com.xxx.repository.document" />

    <tx:annotation-driven mode="proxy"/>
Was it helpful?

Solution

In case it helps, I had to upgrade spring-data-commons to 1.7.1

It works fine now!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top