Under some conditions, a stack overflow does not ishow a stackstrace.
We are in this case.
My code is just simply :
Code:
Collection c = session
.getHbSession()
.createCriteria(MyClass.class)
.list();
I suspect this happens every time you nest a CompositeUserType in a composite-id.
In case of, here is my composite user type (which works when I do not have the mentioned nesting):
Code:
import net.sf.jtemporal.Period;
/**
* Knows how to serialize and deserialize a Period to JDBC for Hibernate
*/
public class PeriodType implements CompositeUserType, Serializable
{
/**
*
*/
public PeriodType() {
super();
// TODO Auto-generated constructor stub
}
/* (non-Javadoc)
* @see org.hibernate.usertype.CompositeUserType#getPropertyNames()
*/
public String[] getPropertyNames() {
// TODO Auto-generated method stub
return new String[] {"start","end"};
}
/* (non-Javadoc)
* @see org.hibernate.usertype.CompositeUserType#getPropertyTypes()
*/
public Type[] getPropertyTypes() {
// TODO Auto-generated method stub
return new Type[] {Hibernate.STRING, Hibernate.STRING};
}
/* (non-Javadoc)
* @see org.hibernate.usertype.CompositeUserType#getPropertyValue(java.lang.Object, int)
*/
public Object getPropertyValue(Object component, int property)
throws HibernateException {
Period period = (Period) component;
switch (property) {
case 0: return period.getStart();
case 1: return period.getEnd();
default: throw new HibernateException("property = "+ property);
}
}
/* (non-Javadoc)
* @see org.hibernate.usertype.CompositeUserType#setPropertyValue(java.lang.Object, int, java.lang.Object)
*/
public void setPropertyValue(Object component, int property, Object value)
throws HibernateException {
throw new UnsupportedOperationException("Immutable!");
}
/* (non-Javadoc)
* @see org.hibernate.usertype.CompositeUserType#returnedClass()
*/
public Class returnedClass() {
return Period.class;
}
/* (non-Javadoc)
* @see org.hibernate.usertype.CompositeUserType#nullSafeGet(java.sql.ResultSet, java.lang.String[], org.hibernate.engine.SessionImplementor, java.lang.Object)
*/
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session,
Object owner) throws HibernateException, SQLException {
String startString = rs.getString(names[0]);
if (startString == null || rs.wasNull()) return null;
BusinessDate startDate = BusinessDateFactory.fromString(startString);
String endString = rs.getString(names[1]);
BusinessDate endDate = BusinessDateFactory.fromEndDate(endString);
assert endDate != null;
return new Period(startDate, endDate);
}
/* (non-Javadoc)
* @see org.hibernate.usertype.CompositeUserType#nullSafeSet(java.sql.PreparedStatement, java.lang.Object, int, org.hibernate.engine.SessionImplementor)
*/
public void nullSafeSet(PreparedStatement st, Object value, int index,
SessionImplementor session) throws HibernateException, SQLException {
// TODO Auto-generated method stub
throw new UnsupportedOperationException(
"Not implemented yet, 'cause tables are read-only");
}
/* (non-Javadoc)
* @see org.hibernate.usertype.CompositeUserType#deepCopy(java.lang.Object)
*/
public Object deepCopy(Object value) throws HibernateException {
// since a Period is immutable, return the same instance
return value;
}
/* (non-Javadoc)
* @see org.hibernate.usertype.CompositeUserType#isMutable()
*/
public boolean isMutable() {
return false;
}
/* (non-Javadoc)
* @see org.hibernate.usertype.CompositeUserType#disassemble(java.lang.Object, org.hibernate.engine.SessionImplementor)
*/
public Serializable disassemble(Object value, SessionImplementor session)
throws HibernateException {
// TODO good enough ???
return (Serializable) value;
}
/* (non-Javadoc)
* @see org.hibernate.usertype.CompositeUserType#assemble(java.io.Serializable, org.hibernate.engine.SessionImplementor, java.lang.Object)
*/
public Object assemble(Serializable cached, SessionImplementor session, Object owner)
throws HibernateException {
// TODO good enough ???
return cached;
}
/* (non-Javadoc)
* @see org.hibernate.usertype.CompositeUserType#replace(java.lang.Object, java.lang.Object, org.hibernate.engine.SessionImplementor, java.lang.Object)
*/
public Object replace(Object original, Object target, SessionImplementor session,
Object owner) throws HibernateException {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Not implemented yet");
}
/* (non-Javadoc)
* @see org.hibernate.usertype.CompositeUserType#equals(java.lang.Object, java.lang.Object)
*/
public boolean equals(Object x, Object y) throws HibernateException {
if (x == y) return true;
if (x == null || y == null) return false;
return x.equals(y);
}
/* (non-Javadoc)
* @see org.hibernate.usertype.CompositeUserType#hashCode(java.lang.Object)
*/
public int hashCode(Object x) throws HibernateException {
return hashCode(x);
}
}