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
|