net.sf.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.abc.model.MyTable2

java2s.com | 7 days ago
  1. 0

    object « Exception « JPA Q&A

    java2s.com | 7 days ago
    net.sf.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.abc.model.MyTable2
  2. 0

    Could not read the data

    Coderanch | 8 years ago | Gundeti Reddy
    java.lang.ClassCastException: java.lang.Long incompatible with java.lang.Short
  3. 0

    I am triggered an ArrayIndexOutOfBound Exception in the hibernate code. This happens when I try to bind a positional parameter of type object. For instance: List finds = session.find("from package.MyClass as myclass where myclass.myAttrib=?", subobject, Hibernate.OBJECT); where myclass.myAttrib is a many-to-one relationship to subobject. The stacktrace is: java.lang.ArrayIndexOutOfBoundsException: 1 at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:2005) at com.mysql.jdbc.PreparedStatement.setBytes(PreparedStatement.java:493) at net.sf.hibernate.type.BinaryType.set(BinaryType.java:28) at net.sf.hibernate.type.SerializableType.set(SerializableType.java:28) at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48) at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35) at net.sf.hibernate.type.ObjectType.nullSafeSet(ObjectType.java:144) at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:674) at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:713) at net.sf.hibernate.loader.Loader.doQuery(Loader.java:185) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133) at net.sf.hibernate.loader.Loader.doList(Loader.java:950) at net.sf.hibernate.loader.Loader.list(Loader.java:941) at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1487) Using a debugger I have found that the index is 2 instead of 1 in PreparedStatement.setByte Of course this cannot work and should come from hibernate mapping. Debugging a little further I have found that in ObjectType.nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) I think that there is an error: metaType.nullSafeSet(st, clazz, index, session); identifierType.nullSafeSet(st, id, index+1, session); // metaType must be single-column type ^^^^^^^^^^^^^ ^^^^^^ The index+1 is wrong it should be index. I am not sure but I think the other types does not have such +1...

    Hibernate JIRA | 1 decade ago | jerome bonnet
    java.lang.ArrayIndexOutOfBoundsException: 1
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    I am triggered an ArrayIndexOutOfBound Exception in the hibernate code. This happens when I try to bind a positional parameter of type object. For instance: List finds = session.find("from package.MyClass as myclass where myclass.myAttrib=?", subobject, Hibernate.OBJECT); where myclass.myAttrib is a many-to-one relationship to subobject. The stacktrace is: java.lang.ArrayIndexOutOfBoundsException: 1 at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:2005) at com.mysql.jdbc.PreparedStatement.setBytes(PreparedStatement.java:493) at net.sf.hibernate.type.BinaryType.set(BinaryType.java:28) at net.sf.hibernate.type.SerializableType.set(SerializableType.java:28) at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48) at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35) at net.sf.hibernate.type.ObjectType.nullSafeSet(ObjectType.java:144) at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:674) at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:713) at net.sf.hibernate.loader.Loader.doQuery(Loader.java:185) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133) at net.sf.hibernate.loader.Loader.doList(Loader.java:950) at net.sf.hibernate.loader.Loader.list(Loader.java:941) at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1487) Using a debugger I have found that the index is 2 instead of 1 in PreparedStatement.setByte Of course this cannot work and should come from hibernate mapping. Debugging a little further I have found that in ObjectType.nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) I think that there is an error: metaType.nullSafeSet(st, clazz, index, session); identifierType.nullSafeSet(st, id, index+1, session); // metaType must be single-column type ^^^^^^^^^^^^^ ^^^^^^ The index+1 is wrong it should be index. I am not sure but I think the other types does not have such +1...

    Hibernate JIRA | 1 decade ago | jerome bonnet
    java.lang.ArrayIndexOutOfBoundsException: 1
  6. 0

    The get method of CharacterType is calling java.lang.String.charAt(0) on a String instance that has zero length This resulted rom trying to load a mapped object from a Mysql 4.0.13 record that has a blank column Sep 4, 2003 8:55:27 AM net.sf.hibernate.impl.IteratorImpl next SEVERE: could not get next result java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(Unknown Source) at net.sf.hibernate.type.CharacterType.get(CharacterType.java:19) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:59) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:51) at net.sf.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:139) at net.sf.hibernate.collection.CollectionPersister.readElement(CollectionPersister.java:377) at net.sf.hibernate.collection.Set.readFrom(Set.java:242) at net.sf.hibernate.loader.Loader.doFind(Loader.java:175) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:602) at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:82) at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2897) at net.sf.hibernate.collection.PersistentCollection.getInitialValue(PersistentCollection.java:128) at net.sf.hibernate.type.PersistentCollectionType.getCollection(PersistentCollectionType.java:74) at net.sf.hibernate.type.PersistentCollectionType.resolveIdentifier(PersistentCollectionType.java:177) at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1959) at net.sf.hibernate.loader.Loader.doFind(Loader.java:196) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:587) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:42) at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:396) at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1889) at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1757) at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1716) at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:62) at net.sf.hibernate.type.EntityType.nullSafeGet(EntityType.java:109) at net.sf.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:57) at net.sf.hibernate.impl.IteratorImpl.next(IteratorImpl.java:70) at test.TestHibernate.main(TestHibernate.java:94) java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(Unknown Source) at net.sf.hibernate.type.CharacterType.get(CharacterType.java:19) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:59) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:51) at net.sf.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:139) at net.sf.hibernate.collection.CollectionPersister.readElement(CollectionPersister.java:377) at net.sf.hibernate.collection.Set.readFrom(Set.java:242) at net.sf.hibernate.loader.Loader.doFind(Loader.java:175) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:602) at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:82) at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2897) at net.sf.hibernate.collection.PersistentCollection.getInitialValue(PersistentCollection.java:128) at net.sf.hibernate.type.PersistentCollectionType.getCollection(PersistentCollectionType.java:74) at net.sf.hibernate.type.PersistentCollectionType.resolveIdentifier(PersistentCollectionType.java:177) at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1959) at net.sf.hibernate.loader.Loader.doFind(Loader.java:196) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:587) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:42) at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:396) at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1889) at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1757) at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1716) at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:62) at net.sf.hibernate.type.EntityType.nullSafeGet(EntityType.java:109) at net.sf.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:57) at net.sf.hibernate.impl.IteratorImpl.next(IteratorImpl.java:70) at test.TestHibernate.main(TestHibernate.java:94) rethrown as net.sf.hibernate.LazyInitializationException: Hibernate lazy instantiation problem: String index out of range: 0 at net.sf.hibernate.impl.IteratorImpl.next(IteratorImpl.java:81) at test.TestHibernate.main(TestHibernate.java:94) Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(Unknown Source) at net.sf.hibernate.type.CharacterType.get(CharacterType.java:19) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:59) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:51) at net.sf.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:139) at net.sf.hibernate.collection.CollectionPersister.readElement(CollectionPersister.java:377) at net.sf.hibernate.collection.Set.readFrom(Set.java:242) at net.sf.hibernate.loader.Loader.doFind(Loader.java:175) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:602) at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:82) at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2897) at net.sf.hibernate.collection.PersistentCollection.getInitialValue(PersistentCollection.java:128) at net.sf.hibernate.type.PersistentCollectionType.getCollection(PersistentCollectionType.java:74) at net.sf.hibernate.type.PersistentCollectionType.resolveIdentifier(PersistentCollectionType.java:177) at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1959) at net.sf.hibernate.loader.Loader.doFind(Loader.java:196) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:587) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:42) at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:396) at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1889) at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1757) at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1716) at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:62) at net.sf.hibernate.type.EntityType.nullSafeGet(EntityType.java:109) at net.sf.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:57) at net.sf.hibernate.impl.IteratorImpl.next(IteratorImpl.java:70) ... 1 more

    Hibernate JIRA | 1 decade ago | Tim Schafer
    net.sf.hibernate.LazyInitializationException: Hibernate lazy instantiation problem: String index out of range: 0

    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. net.sf.hibernate.TransientObjectException

      object references an unsaved transient instance - save the transient instance before flushing: com.abc.model.MyTable2

      at net.sf.hibernate.impl.SessionImpl.throwTransientObjectException()
    2. net.sf.hibernate
      EntityLoader.load
      1. net.sf.hibernate.impl.SessionImpl.throwTransientObjectException(SessionImpl.java:2652)
      2. net.sf.hibernate.impl.SessionImpl.getEntityIdentifierIfNotUnsaved(SessionImpl.java:2644)
      3. net.sf.hibernate.type.EntityType.getIdentifier(EntityType.java:66)
      4. net.sf.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:46)
      5. net.sf.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:154)
      6. net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:673)
      7. net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:712)
      8. net.sf.hibernate.loader.Loader.doQuery(Loader.java:184)
      9. net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132)
      10. net.sf.hibernate.loader.Loader.loadEntity(Loader.java:830)
      11. net.sf.hibernate.loader.Loader.loadEntity(Loader.java:850)
      12. net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:57)
      12 frames