Not actually a newbie, but never posted to the forum before, so I rate as a newbie here, I guess.
With Hibernate 3.1.2GA and Oracle 10g as the back-end. Also, with Spring as an IOC container, I am using HibernateDaoSupport as the main Hibernate interface.
I have an entity whose PK is a CHAR(64) in Oracle.
The ID column in the HBM.xml file is mapped as follows:
Code:
<id
name="id"
type="string"
column="PK_COLUMN_NAME"
>
<generator class="assigned"/>
</id>
I found that mapping the ID property using the "string" hibernate type requires me to pad the query parameter with trailing spaces so the query sends a 64-length String as part of the query.
For example:
Code:
Object[] params = { "Test" };
String hqlString = "from ParentObject where childObject.id = ?";
List<ParentObject> found = getHibernateTemplate().findByQuery(hqlString, params);
// returns an empty list
However:
Code:
Object[] params = { "Test[padded with 60 spaces]" };
String hqlString = "from ParentObject where childObject.id = ?";
List<ParentObject> found = getHibernateTemplate().findByQuery(hqlString, params);
// returns a list populated with one row
Is there a different datatype mapping I could use so the padding is done automatically, or will I need to abstract the padding, or even possibly create a custom type?