Hi
I'm getting an error trying to use the java.util.UUID class within my @Document entity. I have read this post http://forum.springsource.org/showth...ngoDB-1.0.0.M2, which seems to solve the issue, but I cannot seem to get it implemented. I have the following settings:
The xml setup of the mongo stuff:
I have a @Document entity like thisCode:<?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:p="http://www.springframework.org/schema/p" 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-3.0.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd"> <bean id="mongo" class="org.springframework.data.mongodb.core.MongoFactoryBean"> <property name="host" value="${env.E2_MONGODB_HOST}" /> <property name="port" value="${env.E2_MONGODB_PORT}" /> </bean> <mongo:db-factory id="mongoDbFactory" dbname="${env.E2_MONGODB_METADATA_DATABASENAME}" username="${env.E2_MONGODB_METADATA_USERNAME}" password="${env.E2_MONGODB_METADATA_PASSWORD}" mongo-ref="mongo" /> <bean id="mappingContext" class="org.springframework.data.mongodb.core.mapping.MongoMappingContext" /> <bean id="mappingMongoConverter" class="org.springframework.data.mongodb.core.convert.MappingMongoConverter"> <constructor-arg ref="mongoDbFactory" /> <constructor-arg ref="mappingContext" /> </bean> <bean id="metadataMongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> <constructor-arg name="mongoDbFactory" ref="mongoDbFactory" /> <constructor-arg name="mongoConverter" ref="mappingMongoConverter" /> </bean> <mongo:repositories base-package="com.esoftsystems.e2.metadata.business.internal.mongo" mongo-template-ref="metadataMongoTemplate" /> </beans>
But when starting the application I get the following error:Code:@Document public class Metadata { @Id private String id; @Transient private UUID uuid = UUID.randomUUID(); private String name; @PersistenceConstructor public Metadata(String name) { this.name = name; } public String getId() { return id; } public String getName() { return name; } }
If I remove the UUID I can start the application fine. Does anybody have a hint to what I'm doing wrong ?Code:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'metadataMongoRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Multiple constructors with arguments found in class java.util.UUID! Annotate one with @PersistenceConstructor explicitly to select it to be used in persistence operations.
Thanks
Christoffer


Reply With Quote
