Package org.hibernate

Examples of org.hibernate.WrongClassException


          final Object object,
          final LockMode lockMode,
          final SessionImplementor session)
  throws HibernateException, SQLException {
    if ( !persister.isInstance( object, session.getEntityMode() ) ) {
      throw new WrongClassException(
          "loaded object was of wrong class " + object.getClass(),
          key.getIdentifier(),
          persister.getEntityName()
        );
    }
View Full Code Here


      final String result = persister.getSubclassForDiscriminatorValue( discriminatorValue );

      if ( result == null ) {
        //woops we got an instance of another class hierarchy branch
        throw new WrongClassException(
            "Discriminator: " + discriminatorValue,
            id,
            persister.getEntityName()
          );
      }
View Full Code Here

    if (ex instanceof UnresolvableObjectException) {
      UnresolvableObjectException hibEx = (UnresolvableObjectException) ex;
      return new ObjectRetrievalFailureException(hibEx.getEntityName(), hibEx.getIdentifier(), ex.getMessage(), ex);
    }
    if (ex instanceof WrongClassException) {
      WrongClassException hibEx = (WrongClassException) ex;
      return new ObjectRetrievalFailureException(hibEx.getEntityName(), hibEx.getIdentifier(), ex.getMessage(), ex);
    }
    if (ex instanceof StaleObjectStateException) {
      StaleObjectStateException hibEx = (StaleObjectStateException) ex;
      return new ObjectOptimisticLockingFailureException(hibEx.getEntityName(), hibEx.getIdentifier(), ex);
    }
    if (ex instanceof StaleStateException) {
      return new ObjectOptimisticLockingFailureException(ex.getMessage(), ex);
    }
    if (optimisticLockExceptionClass.isInstance(ex)) {
View Full Code Here

      assertEquals(TestBean.class.getName(), ex.getPersistentClassName());
      assertEquals("id", ex.getIdentifier());
      assertEquals(onfe, ex.getCause());
    }

    final WrongClassException wcex = new WrongClassException("msg", "id", TestBean.class.getName());
    try {
      hibernateTemplate.execute(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session)  {
          throw wcex;
View Full Code Here

      assertEquals(TestBean.class.getName(), ex.getPersistentClassName());
      assertEquals("id", ex.getIdentifier());
      assertEquals(onfe, ex.getCause());
    }

    final WrongClassException wcex = new WrongClassException("msg", "id", TestBean.class.getName());
    try {
      hibernateTemplate.execute(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
          throw wcex;
View Full Code Here

      final Object object,
      final LockMode requestedLockMode,
      final SessionImplementor session)
      throws HibernateException, SQLException {
    if ( !persister.isInstance( object ) ) {
      throw new WrongClassException(
          "loaded object was of wrong class " + object.getClass(),
          key.getIdentifier(),
          persister.getEntityName()
        );
    }
View Full Code Here

      final String result = persister.getSubclassForDiscriminatorValue( discriminatorValue );

      if ( result == null ) {
        //woops we got an instance of another class hierarchy branch
        throw new WrongClassException(
            "Discriminator: " + discriminatorValue,
            id,
            persister.getEntityName()
          );
      }
View Full Code Here

          final Object object,
          final LockMode lockMode,
          final SessionImplementor session)
  throws HibernateException {
    if ( !persister.isInstance( object, session.getEntityMode() ) ) {
      throw new WrongClassException(
          "loaded object was of wrong class " + object.getClass(),
          key.getIdentifier(),
          persister.getEntityName()
        );
    }
View Full Code Here

      final Object target = source.getPersistenceContext().unproxy(result);
      if ( target == entity ) {
        throw new AssertionFailure("entity was not detached");
      }
      else if ( !source.getEntityName(target).equals(entityName) ) {
        throw new WrongClassException(
            "class of the given object did not match class of persistent copy",
            event.getRequestedId(),
            entityName
          );
      }
View Full Code Here

          final Object object,
          final LockMode lockMode,
          final SessionImplementor session)
  throws HibernateException, SQLException {
    if ( !persister.isInstance( object, session.getEntityMode() ) ) {
      throw new WrongClassException(
          "loaded object was of wrong class " + object.getClass(),
          key.getIdentifier(),
          persister.getEntityName()
        );
    }
View Full Code Here

TOP

Related Classes of org.hibernate.WrongClassException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.