• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring data mongoDB - Unable to use @DBRef with spring-data-mongodb-1.7.0.RELEASE.jar

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I'm new to Spring data momgoDB. I'm trying to use @DBRef to refer a Document(Comments) from another Document(News) with spring-data-mongodb-1.7.0.RELEASE.jar. To make things easy, I'm not passing anything as parameters for the rest call. The Comments collection exist in the database. I'm getting the following exception

SEVERE: Servlet.service() for servlet [appServlet] in context with path [/news] threw exception [Handler processing failed; nested exception is java.lang.NoSuchMethodError: com.mongodb.DBRef.<init>(Ljava/lang/String;Ljava/lang/Object;)V] with root cause java.lang.NoSuchMethodError: com.mongodb.DBRef.<init>(Ljava/lang/String;Ljava/lang/Object;)V

I'm looking for advice from the experts. Thanks in advance.



import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

@Document
public class Comments{
@Id
private String id;
private String Comment;

public Comments(String comment){
this.id = UUID.randomUUID().toString();
this.comment = comment
}
//getters & setters
}


import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;

@Document
public class News{

@Id
private String id;
private String Title;
private String summary;
@DBRef
private List<Comments> comments;

public News(){
}

public News(String title, String summary){
this.id = UUID.randomUUID().toString();
this.title = title;
this.summary = summary;

}

//getters and setters
}



@RestController
@RequestMapping(value = "/rest/test")
public class HomeController {

private static final Logger logger = LoggerFactory.getLogger(HomeController.class);

@RequestMapping(value = "/createnews", method = RequestMethod.POST)
public void createNews() {
logger.info("createNews method started");
News news = new News("News Title", "News summary");
List<Comments> commentList = new ArrayList<Comments>();
Comments comments = new Comments("News Comments");
commentList.add( comments );
news.setComments( commentList );

logger.info("createNews method ended");

}
}
 
Oncha mikav
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exeprt , please advise.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic