public BasicTypeRegistration(CompositeUserType type, String[] keys) { this( new CompositeCustomType( type, keys ), keys ); }
@Override public boolean[] toColumnNullness(Object value, Mapping mapping) { boolean[] result = new boolean[getColumnSpan( mapping )]; if ( value == null ) { return result; } Object[] values = getPropertyValues( value, EntityMode.POJO ); //TODO!!!!!!! int loc = 0; Type[] propertyTypes = getSubtypes(); for ( int i = 0; i < propertyTypes.length; i++ ) { boolean[] propertyNullness = propertyTypes[i].toColumnNullness( values[i], mapping ); System.arraycopy( propertyNullness, 0, result, loc, propertyNullness.length ); loc += propertyNullness.length; } return result; }
@Override public Object[] getPropertyValues(Object component, EntityMode entityMode) throws HibernateException { int len = getSubtypes().length; Object[] result = new Object[len]; for ( int i = 0; i < len; i++ ) { result[i] = getPropertyValue( component, i ); } return result; }
@Override public int getPropertyIndex(String name) { String[] names = getPropertyNames(); for ( int i = 0, max = names.length; i < max; i++ ) { if ( names[i].equals( name ) ) { return i; } } throw new PropertyNotFoundException( "Unable to locate property named " + name + " on " + getReturnedClass().getName() ); }
@Override public Size[] dictatedSizes(Mapping mapping) throws MappingException { //Not called at runtime so doesn't matter if its slow :) final Size[] sizes = new Size[getColumnSpan( mapping )]; int soFar = 0; for ( Type propertyType : userType.getPropertyTypes() ) { final Size[] propertySizes = propertyType.dictatedSizes( mapping ); System.arraycopy( propertySizes, 0, sizes, soFar, propertySizes.length ); soFar += propertySizes.length; } return sizes; }
@Override public Object getPropertyValue(Object component, int i, SharedSessionContractImplementor session) throws HibernateException { return getPropertyValue( component, i ); }
@Override public Object[] getPropertyValues(Object component, SharedSessionContractImplementor session) throws HibernateException { return getPropertyValues( component, EntityMode.POJO ); }
@Override public boolean isDirty(Object old, Object current, boolean[] checkable, SharedSessionContractImplementor session) throws HibernateException { return isDirty( old, current, session ); }
public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory) throws HibernateException { replaceNode( node, (Element) value ); }
private void bindProperty(final NakedObjectField field, final Element classElement, final boolean valueFieldAccess) { LOG.debug("Binding persistent property [" + field.getId() + "]"); final Element property = classElement.addElement("property"); setType(field, property, "type", true, valueFieldAccess); final Attribute access = property.attribute("access"); final boolean fieldAccess = access != null && access.getStringValue().equals("field"); property.addAttribute("name", getPropertyName(field, fieldAccess)); final org.hibernate.type.Type type = TypeFactory.heuristicType(property.attribute("type").getValue(), null); if (type instanceof CompositeCustomType) { final String[] names = ((CompositeCustomType) type).getPropertyNames(); for (int i = 0; i < names.length; i++) { final String compositeColumnName = deconflictColumnName(columnName(field.getId()) + "_" + names[i]); property.addElement("column").addAttribute("name", compositeColumnName); } } else { addColumnAttribute(property, columnName(field.getId())); } }
@Override public Size[] defaultSizes(Mapping mapping) throws MappingException { //Not called at runtime so doesn't matter if its slow :) final Size[] sizes = new Size[getColumnSpan( mapping )]; int soFar = 0; for ( Type propertyType : userType.getPropertyTypes() ) { final Size[] propertySizes = propertyType.defaultSizes( mapping ); System.arraycopy( propertySizes, 0, sizes, soFar, propertySizes.length ); soFar += propertySizes.length; } return sizes; }
public Object getPropertyValue(Object component, int i, SessionImplementor session) throws HibernateException { return getPropertyValue(component, i); }
public Object[] getPropertyValues(Object component, SessionImplementor session) throws HibernateException { return getPropertyValues( component, EntityMode.POJO ); }
public boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session) throws HibernateException { return isDirty(old, current, session); }
public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory) throws HibernateException { replaceNode( node, (Element) value ); }
public boolean[] toColumnNullness(Object value, Mapping mapping) { boolean[] result = new boolean[ getColumnSpan(mapping) ]; if (value==null) return result; Object[] values = getPropertyValues(value, EntityMode.POJO); //TODO!!!!!!! int loc = 0; Type[] propertyTypes = getSubtypes(); for ( int i=0; i<propertyTypes.length; i++ ) { boolean[] propertyNullness = propertyTypes[i].toColumnNullness( values[i], mapping ); System.arraycopy(propertyNullness, 0, result, loc, propertyNullness.length); loc += propertyNullness.length; } return result; }
public Object[] getPropertyValues(Object component, EntityMode entityMode) throws HibernateException { int len = getSubtypes().length; Object[] result = new Object[len]; for ( int i=0; i<len; i++ ) { result[i] = getPropertyValue(component, i); } return result; }
public Configuration registerTypeOverride(CompositeUserType type, String[] keys) { basicTypes.add( new CompositeCustomType( type, keys ) ); return this; }
@Override public int[] sqlTypes(Mapping mapping) throws MappingException { int[] result = new int[getColumnSpan( mapping )]; int n = 0; for ( Type type : userType.getPropertyTypes() ) { for ( int sqlType : type.sqlTypes( mapping ) ) { result[n++] = sqlType; } } return result; }
public Object getPropertyValue(Object component, int i, SessionImplementor session) throws HibernateException { return getPropertyValue(component, i); }