morphia

DAO and dependency injection, advice?

吃可爱长大的小学妹 提交于 2019-12-01 06:06:03
This is the first time im using the DAO pattern. From what I've read so far, implementing this pattern will help me seperate my calling code (controller) from any persistence implementation - exactly what I want; that is, I don't want to be restrcited to the use of any particular database or 3rd party libraries. I'm creating some test code (in TDD fashion) using MongoDB and morphia (as an example), with morphia's provided BasicDAO class. As far as I can tell, extending BasicDAO<T, V> requires a constructor that accepts Morphia and Mongo objects; these are very specific (3rd party) types that I

DAO and dependency injection, advice?

≡放荡痞女 提交于 2019-12-01 03:07:16
问题 This is the first time im using the DAO pattern. From what I've read so far, implementing this pattern will help me seperate my calling code (controller) from any persistence implementation - exactly what I want; that is, I don't want to be restrcited to the use of any particular database or 3rd party libraries. I'm creating some test code (in TDD fashion) using MongoDB and morphia (as an example), with morphia's provided BasicDAO class. As far as I can tell, extending BasicDAO<T, V> requires

How do Morphia, Mongo4j and Spring data for MongoDB compare? [closed]

大兔子大兔子 提交于 2019-11-29 01:33:35
I'm interested in how to they compare to each other, what's more mature, has more features, better for some use cases. My own use case is to create a real-time monitoring service (think Chartbeat) but if you can talk about other use cases please do it - after all this Q&A might be of interest for others. Morphia may be the most stable of the three. I have not heard much of Mongo4j lately- probably abandoned. I personally like spring-data because of the hades project... You don't need to implement the DAOs. You just write the interface and spring data automatically provides it to you. However

Unit testing with MongoDB

流过昼夜 提交于 2019-11-28 03:46:46
My database of choice is MongoDB. I'm writing a data-layer API to abstract implementation details from client applications - that is, I'm essentially providing a single public interface (an object which acts as an IDL). I'm testing my logic as I go in a TDD manner. Before each unit test, an @Before method is called to create a database singleton, after which, when the test completes, an @After method is called to drop the database. This helps to promote independence among unit tests. Nearly all unit tests, i.e. performing a contextual query , require some kind of insertion logic to occur

a field name “ClassName” is being inserted into mongodb by morphia

自闭症网瘾萝莉.ら 提交于 2019-11-28 00:10:43
问题 I'm pretty new to mongodb and morphia, after starting using it, I realize that there is a extra part in mongodb document, the record contains a filed name "ClassName" with value of the class that morphia mapped. { "_id" : ObjectId("51e7a85e300441e5885316c0"), "className" : "models.User", "imgurl" : "", "uname" : "alex"} is this normal? i feel it is violating the integrity of the data in the db, is there anyway to get around it? 回答1: You can explicitly disable the className attribute: @Entity

How do Morphia, Mongo4j and Spring data for MongoDB compare? [closed]

情到浓时终转凉″ 提交于 2019-11-27 21:44:21
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . I'm interested in how to they compare to each other, what's more mature, has more features, better for some use cases. My own use case is to create a real-time monitoring service (think Chartbeat) but if you can talk about other use cases please do it - after all this Q&A

Unit testing with MongoDB

自闭症网瘾萝莉.ら 提交于 2019-11-27 05:12:48
问题 My database of choice is MongoDB. I'm writing a data-layer API to abstract implementation details from client applications - that is, I'm essentially providing a single public interface (an object which acts as an IDL). I'm testing my logic as I go in a TDD manner. Before each unit test, an @Before method is called to create a database singleton, after which, when the test completes, an @After method is called to drop the database. This helps to promote independence among unit tests. Nearly

MongoDB Composite Key

二次信任 提交于 2019-11-26 15:56:22
问题 I'm just getting started with MongoDb and I've noticed that I get a lot of duplicate records for entries that I meant to be unique. I would like to know how to use a composite key for my data and I'm looking for information on how to create them. Lastly, I am using Java to access mongo and morphia as my ORM layer so including those in your answers would be awesome. Morphia: http://code.google.com/p/morphia/ 回答1: You can use objects for the _id field as well. The _id field is always unique.