-->
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.  [ 9 posts ] 
Author Message
 Post subject: No row with the given identifier
PostPosted: Fri Feb 25, 2005 9:42 am 
Newbie

Joined: Fri Feb 25, 2005 7:52 am
Posts: 5
Hibernate version:
Hibernate 2.1.7

Mapping documents:
UserComunity
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="it.kemen.standard.hibernate">

<class name="UserComunity" table="user_comunity">
<id name="idUser" column="id_user" type="java.lang.Integer">
<generator class="native"/>
</id>

<property name="nickName" column="nick_name" type="java.lang.String" not-null="true" />
<property name="pswd" column="pswd" type="java.lang.String" not-null="true" />
<property name="registrationDate" column="registration_date" type="java.util.Date" not-null="true" />
<property name="enable" column="enable" type="java.lang.Short" not-null="true" />
<property name="lastLogin" column="last_login" type="java.util.Date" />
<property name="lastIp" column="last_ip" type="java.lang.String" not-null="true" />

<many-to-one name="role" column="id_role_fk" class="Role" not-null="true" />
<one-to-one name="userProfile" class="UserProfile"/>
</class>

</hibernate-mapping>

UserProfile:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="it.kemen.standard.hibernate">

<class name="UserProfile" table="user_profile">
<!--
<id name="userComunity" column="id_user_fk" type="java.lang.Integer">
<generator class="native"/>
</id>
-->
<id name="userComunity" column="id_user_fk">
<generator class="foreign">
<param name="property">userComunity</param>
</generator>
</id>

<property name="fullName" column="full_name" type="java.lang.String" not-null="true" />
<property name="cfIvaVat" column="cf_iva_vat" type="java.lang.String" not-null="true" />
<property name="address" column="address" type="java.lang.String" not-null="true" />
<property name="postalCode" column="postal_code" type="java.lang.String" not-null="true" />
<property name="phoneNumber" column="phone_number" type="java.lang.String" not-null="true" />
<property name="faxNumber" column="fax_number" type="java.lang.String" not-null="true" />
<property name="email" column="email" type="java.lang.String" not-null="true" />
<property name="privacy" column="privacy" type="java.lang.Short" not-null="true" />
<property name="birthday" column="birthday" type="java.util.Date" />
<property name="city" column="city" type="java.lang.String" not-null="true" />
<property name="sexFk" column="sex_fk" type="java.lang.Short" not-null="true" />
<property name="nwlComunity" column="nwl_comunity" type="java.lang.Short" not-null="true" />
<property name="nwlFormat" column="nwl_format" type="java.lang.Short" not-null="true" />

<many-to-one name="country" column="country_fk" class="Country" not-null="true" />
<many-to-one name="language" column="language_fk" class="Language" not-null="true" />
<one-to-one name="userComunity" class="UserComunity" constrained="true" foreign-key="id_user_fk"/>

</class>

</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():
hSession = SessionFactory.currentSession();
UserComunity usr = (UserComunity) hSession.load(UserComunity.class,userComunityForm.getId_user());
UserProfile profile = (UserProfile) hSession.load(UserProfile.class,usr);
/*
profile.setAddress(userComunityForm.getAdress());
*/
hSession.flush();
SessionFactory.closeSession();

Full stack trace of any exception that occurs:
- Proxool 0.8.3 (14-Dec-2003 16:06)
net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exists: it.kemen.standard.hibernate.UserComunity@295, of class: it.kemen.standard.hibernate.UserProfile
at net.sf.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:24)
at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1930)
at com.croxit.struts.action.UserComunityAction.execute(UserComunityAction.java:170)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:249)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
at jrun.servlet.http.WebService.invokeRunnable(WebService.java:168)
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:349)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:457)
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:295)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

Name and version of the database you are using:
mysql 4.0
[b]sql[b]
Hibernate: select usercomuni0_.id_user as id_user1_, usercomuni0_.nick_name as nick_name1_, usercomuni0_.pswd as pswd1_, usercomuni0_.registration_date as registra4_1_, usercomuni0_.enable as enable1_, usercomuni0_.last_login as last_login1_, usercomuni0_.last_ip as last_ip1_, usercomuni0_.id_role_fk as id_role_fk1_, role1_.id_role as id_role0_, role1_.name as name0_ from user_comunity usercomuni0_ left outer join role role1_ on usercomuni0_.id_role_fk=role1_.id_role where usercomuni0_.id_user=?

Hibernate: select userprofil0_.id_user_fk as id_user_fk5_, userprofil0_.full_name as full_name5_, userprofil0_.cf_iva_vat as cf_iva_vat5_, userprofil0_.address as address5_, userprofil0_.postal_code as postal_c5_5_, userprofil0_.phone_number as phone_nu6_5_, userprofil0_.fax_number as fax_number5_, userprofil0_.email as email5_, userprofil0_.privacy as privacy5_, userprofil0_.birthday as birthday5_, userprofil0_.city as city5_, userprofil0_.sex_fk as sex_fk5_, userprofil0_.nwl_comunity as nwl_com13_5_, userprofil0_.nwl_format as nwl_format5_, userprofil0_.country_fk as country_fk5_, userprofil0_.language_fk as languag16_5_, country1_.id_country as id_country0_, country1_.country as country0_, country1_.id_language_fk as id_langu3_0_, language2_.id_language as id_langu1_1_, language2_.name as name1_, language2_.code as code1_, language3_.id_language as id_langu1_2_, language3_.name as name2_, language3_.code as code2_, usercomuni4_.id_user as id_user3_, usercomuni4_.nick_name as nick_name3_, usercomuni4_.pswd as pswd3_, usercomuni4_.registration_date as registra4_3_, usercomuni4_.enable as enable3_, usercomuni4_.last_login as last_login3_, usercomuni4_.last_ip as last_ip3_, usercomuni4_.id_role_fk as id_role_fk3_, role5_.id_role as id_role4_, role5_.name as name4_ from user_profile userprofil0_ left outer join country country1_ on userprofil0_.country_fk=country1_.id_country left outer join language language2_ on country1_.id_language_fk=language2_.id_language left outer join language language3_ on userprofil0_.language_fk=language3_.id_language left outer join user_comunity usercomuni4_ on userprofil0_.id_user_fk=usercomuni4_.id_user left outer join role role5_ on usercomuni4_.id_role_fk=role5_.id_role where userprofil0_.id_user_fk=?

[b]my DDL[b]
--
-- Table structure for table `user_comunity`
--

CREATE TABLE `user_comunity` (
`id_user` int(4) unsigned NOT NULL auto_increment,
`nick_name` varchar(20) binary NOT NULL default '',
`pswd` varchar(40) NOT NULL default '',
`registration_date` datetime NOT NULL default '0000-00-00 00:00:00',
`enable` tinyint(2) NOT NULL default '0',
`id_role_fk` int(11) unsigned NOT NULL default '0',
`last_login` datetime default NULL,
`last_ip` varchar(12) NOT NULL default '',
PRIMARY KEY (`id_user`),
UNIQUE KEY `nick_name` (`nick_name`),
KEY `id_role_fk` (`id_role_fk`)
) TYPE=InnoDB;

-- --------------------------------------------------------

--
-- Table structure for table `user_profile`
--

CREATE TABLE `user_profile` (
`id_user_fk` int(11) unsigned NOT NULL default '0',
`full_name` varchar(100) NOT NULL default '',
`cf_iva_vat` varchar(50) NOT NULL default '',
`address` varchar(250) NOT NULL default '',
`postal_code` varchar(10) NOT NULL default '',
`phone_number` varchar(25) NOT NULL default '',
`fax_number` varchar(25) NOT NULL default '',
`email` varchar(50) NOT NULL default '',
`privacy` tinyint(1) NOT NULL default '0',
`birthday` date default NULL,
`country_fk` int(11) unsigned NOT NULL default '0',
`language_fk` int(11) unsigned NOT NULL default '0',
`city` varchar(50) NOT NULL default '',
`sex_fk` tinyint(1) NOT NULL default '0',
`nwl_comunity` tinyint(1) NOT NULL default '0',
`nwl_format` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`id_user_fk`),
KEY `country_fk` (`country_fk`),
KEY `sex_fk` (`sex_fk`),
KEY `language_fk` (`language_fk`)
) TYPE=InnoDB;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `user_comunity`
--
ALTER TABLE `user_comunity`
ADD CONSTRAINT `0_764` FOREIGN KEY (`id_role_fk`) REFERENCES `role` (`id_role`);

--
-- Constraints for table `user_profile`
--
ALTER TABLE `user_profile`
ADD CONSTRAINT `user_profile_ibfk_5` FOREIGN KEY (`language_fk`) REFERENCES `language` (`id_language`),
ADD CONSTRAINT `user_profile_ibfk_3` FOREIGN KEY (`id_user_fk`) REFERENCES `user_comunity` (`id_user`),
ADD CONSTRAINT `user_profile_ibfk_4` FOREIGN KEY (`country_fk`) REFERENCES `country` (`id_country`);

I know the tables structure it's a bit strange but I have other application that use it.
I try sql in mysql and both return a resultset
Some one can me explain the error in my Hibernarte xml

Many Thanks in advance for any idea

Lorenzo


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 25, 2005 9:49 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Do you get a result when you execute the following:
Code:
select * from user_comunity where id_user = 295


.. because hibernate is trying to tell you that there isn't a matching row


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 25, 2005 11:06 am 
Newbie

Joined: Fri Feb 25, 2005 7:52 am
Posts: 5
No I didin't get any rows because id_row 295 it doesn't exist
But where you get this number? :)

regards Lorenzo


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 25, 2005 11:12 am 
Newbie

Joined: Fri Feb 25, 2005 7:52 am
Posts: 5
otherwise if I try this sql:
SELECT * FROM user_comunity WHERE id_user =33
I get a fine resultset.

When I load UserProfile Class here:
UserComunity usr = (UserComunity) hSession.load(UserComunity.class,userComunityForm.getId_user());
UserProfile profile = (UserProfile) hSession.load(UserProfile.class,usr);

my getId_user it's 33
I hope this info help you to understand better.

regards Lorenzo


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 25, 2005 12:11 pm 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Ok so the row is not there. That figures.
What about
Code:
select * from user_profile where id_user_fk = 295


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 25, 2005 12:47 pm 
Newbie

Joined: Fri Feb 25, 2005 7:52 am
Posts: 5
I tried on my db with:
Code:
select * from user_profile where id_user_fk = 33


I get the row :/

May be there are some problem in my Hibernate xml

regards lo


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 25, 2005 1:37 pm 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
The answer is in your mapping. You have a one-to-one relationship defined from UserProfile to UserCommunity.

You have a row in user_profile that points to a row in user_comunity that does not exist.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 27, 2005 6:54 am 
Newbie

Joined: Fri Feb 25, 2005 7:52 am
Posts: 5
No, I am sure. In my tables all relation they are right.

my dump with test user:
INSERT INTO `user_comunity` VALUES (32, 0x6d406d2e6974, 'cecec3ec436bf58a4ecce3e179835e25ff691f3e', '2005-01-16 18:46:05', 1, 2, '2005-01-19 16:52:15', '127.0.0.2'),
(33, 0x61646d696e4063726f7869742e636f6d, 'd033e22ae348aeb5660fc2140aec35850c4da997', '2005-01-19 17:17:16', 1, 2, '2005-02-20 22:49:03', '127.0.0.1');

--
-- Dumping data for table `user_profile`
--

INSERT INTO `user_profile` VALUES (32, 'Max Mazzieri', 'MZZMSMXXXXXXXXXXX', 'p.za Irnerio 8', '20146', '02460750', '', '', 1, '0000-00-00', 120, 1, 'Milano', 0, 0, 0),
(33, 'Lorenzo Sicilia', 'MZZMSMXXXXXXXXXXX', 'p.za Irnerio 8', '20146', '02460750', '', '', 1, '0000-00-00', 120, 1, 'Milano', 0, 0, 0);

Anyway, yesterday I bought Hibernate in action. I hope to find some answer inside the book ;)

regards Lorenzo


Top
 Profile  
 
 Post subject: Re: No row with the given identifier
PostPosted: Tue Jun 08, 2010 1:40 am 
Newbie

Joined: Tue Jun 08, 2010 1:32 am
Posts: 1
Hi,

Even I have the same problem. Don't know why hibernate tries to fetch an item that doesn't exist at all. Please share if you have an answer.


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