[hibernate-dev] Help with Hibernate OGM-401

Ajay Bhat a.ajay.bhat at gmail.com
Wed Dec 17 07:37:58 EST 2014


I worked on the issue a bit and while doing tests I get this error in
BuiltInTypeTest. I can't trace the source of the error. Could you pls help
me out and point out where I'm going wrong here? I've linked relevant files
in my forked repo.

https://github.com/ajaybhat/hibernate-ogm/blob/testOGM-401/core/src/main/java/org/hibernate/ogm/type/impl/TypeTranslatorImpl.java
https://github.com/ajaybhat/hibernate-ogm/blob/testOGM-401/core/src/test/java/org/hibernate/ogm/backendtck/type/BuiltInTypeTest.java
https://github.com/ajaybhat/hibernate-ogm/blob/testOGM-401/core/src/test/java/org/hibernate/ogm/backendtck/type/Bookmark.java


Error
=====
Running org.hibernate.ogm.backendtck.type.BuiltInTypeTest
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 1.802 sec
<<< FAILURE!
testTypesSupport(org.hibernate.ogm.backendtck.type.BuiltInTypeTest)  Time
elapsed: 1.533 sec  <<< ERROR!
org.hibernate.PropertySetterAccessException: IllegalArgumentException
occurred while calling setter for property
[org.hibernate.ogm.backendtck.type.Bookmark.url
Port (expected type = java.lang.Short)]; target =
[org.hibernate.ogm.backendtck.type.Bookmark at 14590fe2], property value =
[80] setter of org.hibernate.ogm.backe
ndtck.type.Bookmark.urlPort
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at
org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:68)
        at
org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:713)
        at
org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:362)
        at
org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:4718)
        at
org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:188)
        at
org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:144)
        at
org.hibernate.ogm.loader.impl.OgmLoader.initializeEntitiesAndCollections(OgmLoader.java:712)
        at
org.hibernate.ogm.loader.impl.OgmLoader.doQuery(OgmLoader.java:358)
        at
org.hibernate.ogm.loader.impl.OgmLoader.doQueryAndInitializeNonLazyCollections(OgmLoader.java:267)
        at
org.hibernate.ogm.loader.impl.OgmLoader.loadEntity(OgmLoader.java:186)
        at org.hibernate.ogm.loader.impl.OgmLoader.load(OgmLoader.java:142)
        at
org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4126)
        at
org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:503)
        at
org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:468)
        at
org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:213)
        at
org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:275)
        at
org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:151)
        at
org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1070)
        at
org.hibernate.internal.SessionImpl.access$2000(SessionImpl.java:176)
        at
org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2551)
        at org.hibernate.internal.SessionImpl.get(SessionImpl.java:955)
        at
org.hibernate.engine.spi.SessionDelegatorBaseImpl.get(SessionDelegatorBaseImpl.java:661)
        at
org.hibernate.ogm.backendtck.type.BuiltInTypeTest.testTypesSupport(BuiltInTypeTest.java:108)

testStringMappedTypeSerialisation(org.hibernate.ogm.backendtck.type.BuiltInTypeTest)
 Time elapsed: 0.008 sec  <<< ERROR!
org.hibernate.ogm.exception.EntityAlreadyExistsException: OGM000067: Trying
to insert an already existing entity: null
        at
com.mongodb.CommandResult.getWriteException(CommandResult.java:88)
        at com.mongodb.CommandResult.getException(CommandResult.java:79)
        at
com.mongodb.DBCollectionImpl.translateBulkWriteException(DBCollectionImpl.java:314)
        at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:189)
        at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:165)
        at com.mongodb.DBCollection.insert(DBCollection.java:161)
        at
org.hibernate.ogm.datastore.mongodb.MongoDBDialect.flushInserts(MongoDBDialect.java:940)
        at
org.hibernate.ogm.datastore.mongodb.MongoDBDialect.executeBatch(MongoDBDialect.java:841)
        at
org.hibernate.ogm.dialect.impl.ForwardingGridDialect.executeBatch(ForwardingGridDialect.java:172)
        at
org.hibernate.ogm.dialect.impl.BatchOperationsDelegator.executeBatch(BatchOperationsDelegator.java:73)
        at
org.hibernate.ogm.service.impl.BatchManagerEventListener.onEvent(BatchManagerEventListener.java:42)
        at
org.hibernate.ogm.service.impl.FlushBatchManagerEventListener.onFlush(FlushBatchManagerEventListener.java:29)
        at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1222)
        at
org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:425)
        at
org.hibernate.ogm.transaction.impl.JTATransactionManagerTransaction.beforeTransactionCommit(JTATransactionManagerTransaction.java:94)
        at
org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177)
        at
org.hibernate.ogm.backendtck.type.BuiltInTypeTest.testStringMappedTypeSerialisation(BuiltInTypeTest.java:188)


On Tue Dec 16 2014 at 7:31:25 PM Emmanuel Bernard <emmanuel at hibernate.org>
wrote:

> Hello,
>
> Look at BuiltInTypeTest and Bookmark. Bookmark hosts all of our built-in
> types.
> We usually don’t do unit tests in the strictest sense. We prefer to run
> the chain from top to bottom in what people call integration tests.
>
> About
> org.hibernate.ogm.test.type.CustomDateType
> org.hibernate.ogm.test.type.ExplodingType
> org.hibernate.ogm.test.type.OverridingTypeDialect
> org.hibernate.ogm.test.type.Poem
>
> They are testing that a dialect can override types. It is indeed a test
> and not part of the core engine.
>
> Emmanuel
>
> On 16 Dec 2014, at 13:22, Ajay Bhat <a.ajay.bhat at gmail.com> wrote:
>
> Hi Emmanuel,
>
> I was working on supporting Short and Float datatypes for Hibernate OGM
> (issue 401) and I noticed that there are no unit tests for
> TypeTranslatorImpl [1]. Where should I look for it, if a test does exist?
> Shall I add a unit test for that?
>
> Also I noticed that some classes are present in the "test" package, rather
> than "main".[2] Could you pls explain why this was done?
> [1] org/hibernate/ogm/type/impl/TypeTranslatorImpl.java
> [2]
> org.hibernate.ogm.test.type.CustomDateType
> org.hibernate.ogm.test.type.ExplodingType
> org.hibernate.ogm.test.type.OverridingTypeDialect
> org.hibernate.ogm.test.type.Poem
>
> https://hibernate.atlassian.net/browse/OGM-401
>
> Thanks,
> Ajay
>
>
>


More information about the hibernate-dev mailing list