java.lang.IllegalArgumentException: can't serialize class org.hibernate.ogm.datastore.mongodb.test.id.GuitarPlayer$Skill

Hibernate JIRA | Gunnar Morling | 2 years ago
  1. 0

    Queries using enums as parameters fail to translate them into the corresponding grid representation for MongoDB. Instead the enum type is passed through as is, raising an error in the datastore layer. Example query: {code} session.createQuery( "select g from GuitarPlayer g where g.skill = :skill") .setParameter( "skill", Skill.HIGH ) .list(); {code} Exception: {code} java.lang.IllegalArgumentException: can't serialize class org.hibernate.ogm.datastore.mongodb.test.id.GuitarPlayer$Skill at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:270) at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:174) at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:120) at com.mongodb.DefaultDBEncoder.writeObject(DefaultDBEncoder.java:27) at com.mongodb.OutMessage.putObject(OutMessage.java:289) at com.mongodb.OutMessage.writeQuery(OutMessage.java:211) at com.mongodb.OutMessage.query(OutMessage.java:84) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:307) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:295) at com.mongodb.DBCursor._check(DBCursor.java:368) at com.mongodb.DBCursor._hasNext(DBCursor.java:459) at com.mongodb.DBCursor.hasNext(DBCursor.java:484) at org.hibernate.ogm.datastore.mongodb.MongoDBDialect$MongoDBResultsCursor.hasNext(MongoDBDialect.java:860) at org.hibernate.ogm.query.impl.OgmQueryLoader.listOfEntities(OgmQueryLoader.java:88) at org.hibernate.ogm.query.impl.OgmQueryLoader.list(OgmQueryLoader.java:76) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:496) at org.hibernate.ogm.query.impl.OgmQueryTranslator.list(OgmQueryTranslator.java:126) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:231) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1264) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103) {code} Apparently we're missing the type translation in this case.

    Hibernate JIRA | 2 years ago | Gunnar Morling
    java.lang.IllegalArgumentException: can't serialize class org.hibernate.ogm.datastore.mongodb.test.id.GuitarPlayer$Skill
  2. 0

    Queries using enums as parameters fail to translate them into the corresponding grid representation for MongoDB. Instead the enum type is passed through as is, raising an error in the datastore layer. Example query: {code} session.createQuery( "select g from GuitarPlayer g where g.skill = :skill") .setParameter( "skill", Skill.HIGH ) .list(); {code} Exception: {code} java.lang.IllegalArgumentException: can't serialize class org.hibernate.ogm.datastore.mongodb.test.id.GuitarPlayer$Skill at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:270) at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:174) at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:120) at com.mongodb.DefaultDBEncoder.writeObject(DefaultDBEncoder.java:27) at com.mongodb.OutMessage.putObject(OutMessage.java:289) at com.mongodb.OutMessage.writeQuery(OutMessage.java:211) at com.mongodb.OutMessage.query(OutMessage.java:84) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:307) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:295) at com.mongodb.DBCursor._check(DBCursor.java:368) at com.mongodb.DBCursor._hasNext(DBCursor.java:459) at com.mongodb.DBCursor.hasNext(DBCursor.java:484) at org.hibernate.ogm.datastore.mongodb.MongoDBDialect$MongoDBResultsCursor.hasNext(MongoDBDialect.java:860) at org.hibernate.ogm.query.impl.OgmQueryLoader.listOfEntities(OgmQueryLoader.java:88) at org.hibernate.ogm.query.impl.OgmQueryLoader.list(OgmQueryLoader.java:76) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:496) at org.hibernate.ogm.query.impl.OgmQueryTranslator.list(OgmQueryTranslator.java:126) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:231) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1264) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103) {code} Apparently we're missing the type translation in this case.

    Hibernate JIRA | 2 years ago | Gunnar Morling
    java.lang.IllegalArgumentException: can't serialize class org.hibernate.ogm.datastore.mongodb.test.id.GuitarPlayer$Skill
  3. 0

    response too long: 572544067

    GitHub | 3 years ago | yegor256
    java.lang.IllegalArgumentException: response too long: 572544067
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Query with Key-List results in: java.lang.IllegalArgumentException: can't serialize class com.google.code.morphia.Key

    GitHub | 3 years ago | michelvocks
    java.lang.IllegalArgumentException: can't serialize class com.google.code.morphia.Key
  6. 0

    What does "response too long" means in MongoDB Java driver?

    Stack Overflow | 3 years ago | yegor256
    java.lang.IllegalArgumentException: response too long: 1912733750 at com.mongodb.Response.<init>(Response.java:47)

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      can't serialize class org.hibernate.ogm.datastore.mongodb.test.id.GuitarPlayer$Skill

      at org.bson.BasicBSONEncoder._putObjectField()
    2. MongoDB Java Driver
      DBCursor.hasNext
      1. org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:270)
      2. org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:174)
      3. org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:120)
      4. com.mongodb.DefaultDBEncoder.writeObject(DefaultDBEncoder.java:27)
      5. com.mongodb.OutMessage.putObject(OutMessage.java:289)
      6. com.mongodb.OutMessage.writeQuery(OutMessage.java:211)
      7. com.mongodb.OutMessage.query(OutMessage.java:84)
      8. com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:307)
      9. com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:295)
      10. com.mongodb.DBCursor._check(DBCursor.java:368)
      11. com.mongodb.DBCursor._hasNext(DBCursor.java:459)
      12. com.mongodb.DBCursor.hasNext(DBCursor.java:484)
      12 frames
    3. org.hibernate.ogm
      MongoDBDialect$MongoDBResultsCursor.hasNext
      1. org.hibernate.ogm.datastore.mongodb.MongoDBDialect$MongoDBResultsCursor.hasNext(MongoDBDialect.java:860)
      1 frame
    4. Hibernate Object Grid Mapper
      OgmQueryLoader.list
      1. org.hibernate.ogm.query.impl.OgmQueryLoader.listOfEntities(OgmQueryLoader.java:88)
      2. org.hibernate.ogm.query.impl.OgmQueryLoader.list(OgmQueryLoader.java:76)
      2 frames
    5. Hibernate
      QueryLoader.list
      1. org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:496)
      1 frame
    6. Hibernate Object Grid Mapper
      OgmQueryTranslator.list
      1. org.hibernate.ogm.query.impl.OgmQueryTranslator.list(OgmQueryTranslator.java:126)
      1 frame
    7. Hibernate
      QueryImpl.list
      1. org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:231)
      2. org.hibernate.internal.SessionImpl.list(SessionImpl.java:1264)
      3. org.hibernate.internal.QueryImpl.list(QueryImpl.java:103)
      3 frames