Hi,
in my application i am using Hibernate3 and Spring3.1.1. My DAO is extending HibernateDAOSupport class. below is my get method in my DAO class which is returning me the object.
public class TestDAO extends HibernateDaoSupport { public Test getTest(String id){ return (Test) getHibernateTemplate().get(Test.class, id); } }
My HBM file configuration
<hibernate-mapping> <class name="......Test" table="TEST"> <id name="id" type="java.lang.String"> <column name="ID" /> </id> <property name="type" type="java.lang.String"> <column name="TYPE" length="10" not-null="true" /> </property> </class> </hibernate-mapping>
My table definition is
create table TEST ( id char(4), type varchar(10));
Data in TEST table ID TYPE 1111 TEST
Below is my test code and i am expecting my test to pass, but it is failing.
public void testGetTest() { TestDAO testDAO = (TestDAO) ApplicationInitializer.getBean("TestDAO"); Test test = testDAO.getTest("11111"); assertNull(test); }
If you observe, in my Test code i am passing id as 11111 - Which is 5 characters length my table is defined with a maximum length of 4 for ID field ( you can find this above ).
I am expecting that getHibernateTemplate().get(Test.class, id) to return null when i pass id value as 11111. But it is returning me Test object which contains ID value as 1111.
Any help is much appreciated.
regards Suneel
|