-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Embedded documents don't work with the new ObjectId-datatype
PostPosted: Wed Oct 01, 2014 4:58 pm 
Newbie

Joined: Wed Oct 01, 2014 4:39 pm
Posts: 1
If I use the new ID-feature with MongoDB (ObjectId) like this
Code:
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private ObjectId id;

    @Embedded
    private SomeEmbeddable details;


a storing of the entity causes the following exception:

Code:
java.lang.IllegalArgumentException: Document field names can't have a . in them. (Bad Key: 'details.endDate')
   at com.mongodb.DBCollection.validateKey(DBCollection.java:1843)
   at com.mongodb.DBCollection._checkKeys(DBCollection.java:1803)
   at com.mongodb.DBCollection._checkObject(DBCollection.java:1790)
   at com.mongodb.DBCollectionImpl.applyRulesForInsert(DBCollectionImpl.java:392)
   at com.mongodb.DBCollectionImpl.insertWithCommandProtocol(DBCollectionImpl.java:381)
   at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:186)
   at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:165)
   at com.mongodb.DBCollection.insert(DBCollection.java:161)
   at com.mongodb.DBCollection.insert(DBCollection.java:107)
   at org.hibernate.ogm.datastore.mongodb.MongoDBDialect.insertTuple(MongoDBDialect.java:306)
   at org.hibernate.ogm.dialect.impl.ForwardingGridDialect.insertTuple(ForwardingGridDialect.java:201)
   at org.hibernate.ogm.persister.impl.OgmEntityPersister.insert(OgmEntityPersister.java:1054)
   at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:98)
   at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:490)
   at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:195)
   at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:179)
   at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:214)
   at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:324)
   at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:288)
   at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:194)
   at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:125)
   at org.hibernate.jpa.event.internal.core.JpaMergeEventListener.saveWithGeneratedId(JpaMergeEventListener.java:73)
   at org.hibernate.event.internal.DefaultMergeEventListener.saveTransientEntity(DefaultMergeEventListener.java:271)
   at org.hibernate.event.internal.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:251)
   at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:189)
   at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:85)
   at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:876)
   at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:858)
   at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:863)
   at org.hibernate.jpa.spi.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:1196)
   at org.hibernate.ogm.jpa.impl.OgmEntityManager.merge(OgmEntityManager.java:84)


If I use the old way of the ID
Code:
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;

no exception is thrown and the embedded document is correctly stored.


Top
 Profile  
 
 Post subject: Re: Embedded documents don't work with the new ObjectId-datatype
PostPosted: Thu Oct 02, 2014 6:43 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
Thanks,
I've created an issue for it: https://hibernate.atlassian.net/browse/OGM-612

I'm looking into it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.