changing the private property to a long and setting the access to "field" did the trick, thanks! Although, I would still prefer to use a custom UserType as that creates a better abstraction layer.
Here's the stack trace:
Code:
Caused by: net.sf.hibernate.MappingException: property mapping has wrong number of columns: edu.ucsd.som.business.tracker.RoutingTracker.itemId type: edu.ucsd.som.hibernate.NumericString
at net.sf.hibernate.mapping.PersistentClass.validate(PersistentClass.java:269)
at net.sf.hibernate.mapping.RootClass.validate(RootClass.java:199)
at net.sf.hibernate.cfg.Configuration.validate(Configuration.java:576)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:733)
at edu.ucsd.som.hibernate.AbstractHibernateDataStore.initFactory(AbstractHibernateDataStore.java:324)
at edu.ucsd.som.hibernate.AbstractHibernateDataStore.getFactory(AbstractHibernateDataStore.java:296)
... 63 more
and the mapping:
Code:
<hibernate-mapping>
<class name="edu.ucsd.som.business.tracker.RoutingTracker" table="routing_tracker">
<id name="id" column="routing_tracker_id" type="long" access="field">
<generator class="native"/>
</id>
<property name="name" column="name" not-null="false" type="string" />
<property name="groupName" column="group_name" not-null="false" type="string" />
<property name="itemId" column="item_id" not-null="true" type="edu.ucsd.som.hibernate.NumericString" />
<property name="status" column="status" type="int"/>
<list name="stages" lazy="false" table="routing_stage" cascade="all">
<key column="routing_tracker_id"/>
<index column="stage_num" type="int" />
<one-to-many class="edu.ucsd.som.business.tracker.RoutingStage"/>
</list>
<property name="currentStageNum" column="current_stage_num" type="int"/>
</class>
</hibernate-mapping>
and finally my initFactory() function:
Code:
private void initFactory() throws HibernateException
{
Configuration config = new Configuration();
Class[] classes = getPersistentClasses();
for( int i=0; i<classes.length; i++ )
config.addClass(classes[i]);
Properties props = getProperties();
props.put(Environment.DBCP_VALIDATION_QUERY, "select 1 from reclass_request");
props.put(Environment.DBCP_VALIDATION_ONBORROW, Boolean.TRUE);
props.put(Environment.DBCP_VALIDATION_ONRETURN, Boolean.FALSE);
config.addProperties(props);
this.factory = config.buildSessionFactory();
}
thanks
-D.