Re: Comment on QuickStart in morphia

11 views
Skip to first unread message

mor...@googlecode.com

unread,
Jun 28, 2010, 2:59:20 PM6/28/10
to morphia...@googlegroups.com
Comment by scotthernandez:

That could be an option; file an issue and get some votes for it, or supply
a patch.

It shouldn't be too hard support, but I'm not sure about mapping between
the two annotation systems.


For more information:
http://code.google.com/p/morphia/wiki/QuickStart

mor...@googlecode.com

unread,
Aug 10, 2010, 11:58:44 AM8/10/10
to morphia...@googlegroups.com
Comment by carnatus:

Is it possible not to save the className into the object - it wrecks
obvious havock on refactoring? Apologies if the answer is already
documented somewhere - couldn't find it ...

mor...@googlecode.com

unread,
Aug 11, 2010, 2:05:53 AM8/11/10
to morphia...@googlegroups.com
Comment by scotthernandez:

carnatus, there is an attribute on the annotation to do that,
@Entity(noClassnameStored=True); It has to be explicit because the
className field is used for resolving collections that contain multiple
types.

mor...@googlecode.com

unread,
Aug 16, 2010, 10:04:05 PM8/16/10
to morphia...@googlegroups.com
Comment by carnatus:

Scott, thanks a million, my bad! Do you guys need help with the
documentation at all?

mor...@googlecode.com

unread,
Aug 16, 2010, 11:00:36 PM8/16/10
to morphia...@googlegroups.com
Comment by scotthernandez:

carnatus, we always need help on docs. Join the list
(http://groups.google.com/group/morphia) and ask again there. These
comments are not the best place to chat.

mor...@googlecode.com

unread,
Nov 27, 2010, 12:48:45 AM11/27/10
to morphia...@googlegroups.com
Comment by bowlingb:

In the persisting POJOs segment, how does Morphia know that 'address'
belongs to 'hotel'? Is there a hotel.setAddress(address); missing?

For more information:
https://code.google.com/p/morphia/wiki/QuickStart

mor...@googlecode.com

unread,
Nov 27, 2010, 1:15:00 AM11/27/10
to morphia...@googlegroups.com
Comment by scotthernandez:

Morphia looks at the fields and persists them. The Hotel class has a field
called address of type Address. Getters and Setters are not used for
persistence.

mor...@googlecode.com

unread,
Dec 2, 2010, 3:36:59 PM12/2/10
to morphia...@googlegroups.com
Comment by chsrinu:

I have the same requirement of saving these kind of objects in MongoDB. How
can I do this in C#?

mor...@googlecode.com

unread,
Dec 6, 2010, 2:16:11 PM12/6/10
to morphia...@googlegroups.com
Comment by scotthernandez:

chsrinu, the mongodb csharp driver should do this, most of it at least.

mor...@googlecode.com

unread,
Dec 8, 2010, 3:56:00 AM12/8/10
to morphia...@googlegroups.com
Comment by h...@caterva.com:

Can I get some fields in mongodb ? If yes, What will I use function?

mor...@googlecode.com

unread,
Jan 20, 2011, 1:52:59 AM1/20/11
to morphia...@googlegroups.com
Comment by hjp_0...@hotmail.com:

why I used mapPackage (code : morphia.mapPackage("domain");), the morphia
(code: datastore.ensureIndexes();) don't create index for mongo ? (unless I
use map(class))

mor...@googlecode.com

unread,
Mar 13, 2011, 3:55:14 PM3/13/11
to morphia...@googlegroups.com
Comment by mwaschko...@gmail.com:

"In the persisting POJOs segment, how does Morphia know that 'address'
belongs to 'hotel'? Is there a hotel.setAddress(address); missing?"

Scott, I don't understand your answer - from the code shown here, hotel
doesn't have any reference to the address! Address and hotel are just 2
separate objects that have been created... What if there were 2 addressed
defined, how would Morphia know which one to use?

ie.
Hotel hotel = new Hotel();
hotel.setName("My Hotel");

Address address = new Address();
address.setStreet("123 Some street");
Address address1 = new Address();
address1.setStreet("456 Some street");

Morphia morphia = ...;
Datastore ds = morphia.createDatastore("testDB");
// Save the POJO
ds.save(hotel);

Which address is hotel going to be associated with? There must be a
setAddress call somewhere no?

mor...@googlecode.com

unread,
Mar 13, 2011, 4:10:23 PM3/13/11
to morphia...@googlegroups.com
Comment by scotthernandez:

Yes, I have added the setAddress; sorry for the confusion and thanks for
catching that.

I missed the point of that question; we all have bad days and that was
clearly one of mine :(

mor...@googlecode.com

unread,
Mar 13, 2011, 5:22:02 PM3/13/11
to morphia...@googlegroups.com
Comment by stof...@gmail.com:

The 'Prepare the framework' section should be updated as the constructor
and method signatures do not match the .99 API and will not compile. Should
update to:
...
Morphia morphia = new Morphia( );
morphia.map(Hotel.class).map(Address.class);
Datastore ds = morphia.createDatastore( new Mongo(), "my_database" );
...

mor...@googlecode.com

unread,
Sep 15, 2011, 2:28:55 PM9/15/11
to morphia...@googlegroups.com
Comment by volkan.y...@gmail.com:

Typo: `import com.google.code.morphia.dao.DAO` should be replaced with
`import ...dao.BasicDAO` --- or vice, versa: `BasicDAO<Hotel, String>`
should be replaced with `DAO<Hotel, String>`.

mor...@googlecode.com

unread,
Nov 19, 2011, 1:25:16 AM11/19/11
to morphia...@googlegroups.com
Comment by chenjf2...@gmail.com:

"import com.google.code.morphia.annotations.CollectionName; " where
is "CollectionName" class?

mor...@googlecode.com

unread,
Dec 12, 2011, 5:34:36 PM12/12/11
to morphia...@googlegroups.com
Comment by viola.du...@gmail.com:

what about the performance? if I want load 1000 records and present in
front end, mapping to 1000 objects will slow. In this case I prefer to load
the record direct from mango and give them to front end.

mor...@googlecode.com

unread,
Dec 12, 2011, 5:38:38 PM12/12/11
to morphia...@googlegroups.com
Comment by wasserma...@gmail.com:

mor...@googlecode.com

unread,
Jul 26, 2012, 1:08:23 PM7/26/12
to morphia...@googlegroups.com
Comment by ben...@gmail.com:

Datastore ds = morphia.createDatastore("testDB");
//is deprecated. The documentation here is generally ambiguous and
unhelpful.

mor...@googlecode.com

unread,
Aug 19, 2012, 5:24:47 PM8/19/12
to morphia...@googlegroups.com
Comment by clementl...@gmail.com:

How can I query hotels on a property of their address? Thx!

mor...@googlecode.com

unread,
May 16, 2013, 5:27:57 AM5/16/13
to morphia...@googlegroups.com
Comment by Sirees...@vasudhaika.net:

Loading a Hotel from Mongo is also simple:

Morphia morphia = ...;
Datastore ds = morphia.createDatastore("testDB");

String hotelId = ...; // the ID of the hotel we want to load
//Use this line instead of String hotelId
ObjectId hotelId= new ObjectId("5194a4d1e4b0ffca8d927c93");


// and then map it to our Hotel object
Hotel hotel = ds.get(Hotel.class, hotelId);

mor...@googlecode.com

unread,
May 16, 2013, 5:29:38 AM5/16/13
to morphia...@googlegroups.com
Comment by Sirees...@vasudhaika.net:

ObjectId hotelId= new ObjectId("5194a4d1e4b0ffca8d927c93");
Use this line In : Loading a Hotel from Mongo is also simple:

Instead of String hotelId
Reply all
Reply to author
Forward
0 new messages