-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: get is returning object which does not exist
PostPosted: Fri Jul 13, 2012 12:12 pm 
Newbie

Joined: Fri Jul 13, 2012 11:59 am
Posts: 2
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


Top
 Profile  
 
 Post subject: Re: get is returning object which does not exist
PostPosted: Mon Jul 16, 2012 9:34 am 
Newbie

Joined: Fri Jul 13, 2012 11:59 am
Posts: 2
Please let me know how to tackle this issue.

This is critical for my code release and any help on this is appreciated.

Let me know if more details are required.

regards
Suneel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.