How to fetch data from database using beans in springframework

N

Navneet Mathpal

I am trying to fetch the data which is in the mongodb and i am using spring framework so i have created a bean for it,
here is my config file:-

<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:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<mongo:mongo host="11.756.56.26" port="27017" />
<mongo:db-factory dbname="yourdb" />
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
</bean>
<bean id="TestSet" class="com.wipro.model">
</bean</beans>



and my bean class is :-


package com.wipro.model;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
@Document(collection = "TestSetTable")
public class TestSet{

@Id
String _id;
String Platform;
String Environment;
String TestSetName;
String Date;
String Relevancy;
String Recall;
String Precision;
public String get_id() {

System.out.println("came");
return _id;
}

public void set_id(String _id) {
this._id = _id;
}

public String getPlatform() {
System.out.println("came");
return Platform;
}

public void setPlatform(String platform) {
Platform = platform;
}

public String getEnvironment() {
return Environment;
}

public void setEnvironment(String environment) {
Environment = environment;
}

public String getTestSetName() {
return TestSetName;
}

public void setTestSetName(String testSetName) {
TestSetName = testSetName;
}

public String getDate() {
return Date;
}

public void setDate(String date) {
Date = date;
}

public String getRelevancy() {
return Relevancy;
}

public void setRelevancy(String relevancy) {
Relevancy = relevancy;
}

public String getRecall() {
return Recall;
}

public void setRecall(String recall) {
Recall = recall;
}

public String getPrecision() {
return Precision;
}

public void setPrecision(String precision) {
Precision = precision;
}

}



control is not cming in bean and not fetching anything explain.

Thanks & Regards
Navneet Mathapal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top