Methods Summary |
---|
public java.lang.Object | assemble(java.io.Serializable cached, net.sf.hibernate.engine.SessionImplementor session, java.lang.Object owner)Reconstitute a working instance of the managed class from the cache.
// Our value type happens to be serializable, so we have an easy out.
return deepCopy(cached);
|
public java.lang.Object | deepCopy(java.lang.Object value)Return a deep copy of the persistent state, stopping at
entities and collections.
if (value == null) return null;
StereoVolume volume = (StereoVolume)value;
return new StereoVolume(volume.getLeft(), volume.getRight());
|
public java.io.Serializable | disassemble(java.lang.Object value, net.sf.hibernate.engine.SessionImplementor session)Translate an instance of the managed class into a serializable form to
be stored in the cache.
return (Serializable) deepCopy(value);
|
public boolean | equals(java.lang.Object x, java.lang.Object y)Compare two instances of the class mapped by this type for persistence
"equality".
if (x == y) { // This is a trivial success
return true;
}
if (x == null || y == null) { // Don't blow up if either is null!
return false;
}
// Now it's safe to delegate to the class' own sense of equality
return ((StereoVolume)x).equals(y);
|
public java.lang.String[] | getPropertyNames()Get the names of the properties that make up this composite type,
and that may be used in a query involving it.
// Allocate a new response each time, because arrays are mutable
return new String[] { "left", "right" };
|
public net.sf.hibernate.type.Type[] | getPropertyTypes()Get the types associated with the properties that make up this
composite type.
return new Type[] { Hibernate.SHORT, Hibernate.SHORT };
|
public java.lang.Object | getPropertyValue(java.lang.Object component, int property)Look up the value of one of the properties making up this composite
type.
StereoVolume volume = (StereoVolume)component;
short result;
switch (property) {
case 0:
result = volume.getLeft();
break;
case 1:
result = volume.getRight();
break;
default:
throw new IllegalArgumentException("unknown property: " +
property);
}
return new Short(result);
|
public boolean | isMutable()Indicates whether objects managed by this type are mutable.
return true;
|
public java.lang.Object | nullSafeGet(java.sql.ResultSet rs, java.lang.String[] names, net.sf.hibernate.engine.SessionImplementor session, java.lang.Object owner)Retrieve an instance of the mapped class from a JDBC {@link ResultSet}.
Short left = (Short) Hibernate.SHORT.nullSafeGet(rs, names[0]);
Short right = (Short) Hibernate.SHORT.nullSafeGet(rs, names[1]);
if (left == null || right == null) {
return null; // We don't have a specified volume for the channels
}
return new StereoVolume(left.shortValue(), right.shortValue());
|
public void | nullSafeSet(java.sql.PreparedStatement st, java.lang.Object value, int index, net.sf.hibernate.engine.SessionImplementor session)Write an instance of the mapped class to a {@link PreparedStatement},
handling null values.
if (value == null) {
Hibernate.SHORT.nullSafeSet(st, null, index);
Hibernate.SHORT.nullSafeSet(st, null, index + 1);
}
else {
StereoVolume vol = (StereoVolume)value;
Hibernate.SHORT.nullSafeSet(st, new Short(vol.getLeft()), index);
Hibernate.SHORT.nullSafeSet(st, new Short(vol.getRight()),
index + 1);
}
|
public java.lang.Class | returnedClass()Determine the class that is returned by {@link #nullSafeGet}.
return StereoVolume.class;
|
public void | setPropertyValue(java.lang.Object component, int property, java.lang.Object value)Set the value of one of the properties making up this composite
type.
StereoVolume volume = (StereoVolume)component;
short newLevel = ((Short)value).shortValue();
switch (property) {
case 0:
volume.setLeft(newLevel);
break;
case 1:
volume.setRight(newLevel);
break;
default:
throw new IllegalArgumentException("unknown property: " +
property);
}
|