/*
   * @see org.hibernate.usertype.CompositeUserType#getPropertyValue(java.lang.Object, int)
   */
  @Override
  public Object getPropertyValue(Object component, int property) throws HibernateException {

    final Object result;
    final CtxEntityIdentifier id = (CtxEntityIdentifier) component;

    switch (property) {
      case 0:
        result = id.getOwnerId();
        break;

      case 1:
        result = id.getType();
        break;

      case 2:
        result = id.getObjectNumber();
        break;

      default:
        throw new IllegalArgumentException("Unknown property: " + property);
    }

    return result;
  }
  /*
   * @see org.hibernate.usertype.CompositeUserType#nullSafeSet(java.sql.PreparedStatement, java.lang.Object, int, org.hibernate.engine.SessionImplementor)
   */
  @Override
  public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
      throws HibernateException, SQLException {

    final CtxEntityIdentifier id = (CtxEntityIdentifier) value;

    Hibernate.STRING.nullSafeSet(st, id.getOwnerId(), index);
    Hibernate.STRING.nullSafeSet(st, id.getType(), index + 1);
    Hibernate.LONG.nullSafeSet(st, id.getObjectNumber(), index + 2);
  }