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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate fails to fetch the record in the Database
PostPosted: Wed Feb 13, 2008 5:05 am 
Newbie

Joined: Tue Feb 12, 2008 9:52 am
Posts: 9
Hi ,

My problem is this :
***************

We are developing a J2EE based server application which has to cater to different types of mobile clients.

The clients will be pinging the server at a rate of 4-5 requests per sec.

I use HibernateUtil.getSession().load(PK) and it returns null..but the record is very much there in the DB..i have not inserted that record using JDBC.

This happens at times..not always..

Exception : No row with the given identifier exists in the session..

If i destroy and recreate the session factory, it works fine..but it is an expensive operation.

DB : Mysql 5

Hibernate version 3

My mapping file :

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC

"-//Hibernate/Hibernate Mapping DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">



<hibernate-mapping>

<class name="client.Contacts" table="contacts">

<id name="cId" column="c_Id" unsaved-value="null">
<generator class="identity" />
</id>




<property name="ContactID">
<column name="ContactID" />
</property>

<property name="firstName">
<column name="FirstName" />
</property>

<property name="lastName">
<column name="LastName" />
</property>

<property name="address">
<column name="address" />
</property>

<property name="email">
<column name="Email" />
</property>

<property name="url">
<column name="url" />
</property>

<property name="birthday">
<column name="birthday" />
</property>

<property name="note">
<column name="note" />
</property>

<property name="telephone">
<column name="telephone" />
</property>

<property name="telephoneFax">
<column name="telephoneFax" />
</property>

<property name="telephoneHome">
<column name="telephoneHome" />
</property>

<property name="telephoneWork">
<column name="telephoneWork" />
</property>

<property name="telephoneCell">
<column name="telephoneCell" />
</property>

<property name="nickName">
<column name="nickName" />
</property>

<property name="version">
<column name="version" />
</property>

<property name="userPhoneFK">
<column name="userPhoneFK" />
</property>


<property name="isDeleted">
<column name="isDeleted"/>
</property>

<property name="userModifiedFlag">
<column name="isModifiedbyUser"/>
</property>

<property name="isRestored">
<column name="isRestored"/>
</property>

<property name="lastBackUpTime">
<column name="lastBackUpTime" />
</property>

<property name="isAddedOnServer">
<column name="isAddedOnServer" />
</property>

</class>

</hibernate-mapping>

Java code :
*********

String sortContactsQuery = " from Contacts c where c.isRestored= 'false' and isDeleted='false' and c.userPhoneFK="+msisdnID+" order by c.ContactID ASC ";

contactList= getSession().createQuery(sortContactsQuery).list();

contactList = criteria.list();

This list is empty even though there are records.

Thanks in advance.

Ven


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 13, 2008 11:24 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
Quote:
contactList= getSession().createQuery(sortContactsQuery).list();

contactList = criteria.list();



you're executing two queries and overriding the results from the first with the results from the second

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject: list
PostPosted: Thu Feb 14, 2008 12:14 am 
Newbie

Joined: Tue Feb 12, 2008 9:52 am
Posts: 9
I used both the queries to fetch the records..none of them wr\ork..i dont use them simultaneously..i must have given that info tooo..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.