/* (non-Javadoc)
   * @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 CtxAssociationIdentifier id = (CtxAssociationIdentifier) value;

    Hibernate.STRING.nullSafeSet(st, id.getOwnerId(), index);
    Hibernate.STRING.nullSafeSet(st, id.getType(), index + 1);
    Hibernate.LONG.nullSafeSet(st, id.getObjectNumber(), index + 2);
  }
  /*
   * @see org.hibernate.usertype.CompositeUserType#nullSafeGet(java.sql.ResultSet, java.lang.String[], org.hibernate.engine.SessionImplementor, java.lang.Object)
   */
  @Override
  public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
      throws HibernateException, SQLException {

    final String ownerId = (String) Hibernate.STRING.nullSafeGet(rs, names[0]);
    final String type = (String) Hibernate.STRING.nullSafeGet(rs, names[1]);
    final Long objectNumber = (Long) Hibernate.LONG.nullSafeGet(rs, names[2]);

    if (ownerId == null || type == null || objectNumber == null) return null;

    return new CtxAssociationIdentifier(ownerId, type, objectNumber);
  }
Exemplo n.º 3
0
 public Object get(ResultSet rs, String name) throws HibernateException, SQLException {
   String str = (String) Hibernate.STRING.get(rs, name);
   if (str == null) {
     return null;
   } else {
     try {
       return ReflectHelper.classForName(str);
     } catch (ClassNotFoundException cnfe) {
       throw new HibernateException("Class not found: " + str);
     }
   }
 }
Exemplo n.º 4
0
 public int sqlType() {
   return Hibernate.STRING.sqlType();
 }
Exemplo n.º 5
0
 public void set(PreparedStatement st, Object value, int index)
     throws HibernateException, SQLException {
   // TODO: would be nice to handle proxy classes elegantly!
   Hibernate.STRING.set(st, ((Class) value).getName(), index);
 }