0

So i wan to add some data but it

{
    "_id" : ObjectId("5a0c6748fb3aac66aafe26d7"),
    "picture" : "http://placehold.it/150x150",
    "name" : "Cablam",
    "email" : "leilaware@cablam.com",
    "city" : "Rabat",
    "location" : {
            "type" : "Point",
            "coordinates" : [
                    -6.75778,
                    33.97468
            ]
    }
}

now when i try to inset just normale obejct it works but when i try object that contain an other object to have embedded docuement for the ONE-to-One relations it s not working i find the collection empty

for the spring configuraiton it s XML

<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
    <!-- <constructor-arg name="mongoDbFactory" ref="mongoDbFactory" /> -->
    <constructor-arg name="mongo" ref="mongo"/>
    <constructor-arg name="databaseName" value="yourdb"/>
</bean>

<!-- Factory bean that creates the Mongo instance -->
<bean id="mongo" class="org.springframework.data.mongodb.core.MongoFactoryBean">
  <property name="host" value="localhost"/>
</bean>

class where i want to save the data

@Repository
public class CustomerDAOImpl implements CustomerDAO {

@Autowired
private MongoTemplate mongoTemp ;

@Override
public List<Customer> getCustomers() {


     MongoOperations mongoOperation ; //= (MongoOperations) appContext.getBean("mongoTemplate");


    Location location = new Location(
            "point", 
            new ArrayList<Double>( Arrays.asList(11111111.1, 00000000.0))
            );

    Shop shop = new Shop("pic link", "superName","superEmail","supercity",location,true );

    // save
    mongoOperation = (MongoOperations) mongoTemp;

    mongoOperation.save(shop);

    //shopRepository.insert(shop);
    // now user object got the created id.
    System.out.println(">>>>>>>> >>> >> 1. use1r : " + shop);
  ....

the Model / entity

@Document(collection="shops")
public class Shop {

@Id
private String id;
private String picture;
private String name;
private String email;
private String city;

//@GeoSpatialIndexed(type=GeoSpatialIndexType.GEO_2DSPHERE)
private Location location;

private Boolean isLiked;

/*private Date shownAfter;*/


public Shop(String picture, String name, String email, String city, Location location, Boolean isLiked/*, Date shownAfter*/) {
    super();
    this.picture = picture;
    this.name = name;
    this.email = email;
    this.city = city;
    this.location = location;
    this.isLiked = isLiked;
    //this.shownAfter = shownAfter;
}
...
}

can anyonw help me on that

mr scams
  • 1
  • 2
  • Instead of attempting to embed a "screenshot" of your data ( which you might note you were blocked from doing ), you really are expected to take the hint of that "block" and instead "copy the text" and insert that into your question instead. Doing so it more useful to readers of your question and most importantly allows them to take a copy and see if they can reproduce your problem. You cannot copy data from a "screenshot". It would be good if your could learn that lesson quickly and [edit your question](https://stackoverflow.com/posts/50283399/edit) – Neil Lunn May 11 '18 at 01:44
  • thank you neil i will edite it u r right – mr scams May 11 '18 at 11:12

0 Answers0