- This topic has 13 replies, 3 voices, and was last updated 19 years, 9 months ago by arnor.
-
AuthorPosts
-
arnorMemberHi forum,
Hi have some problem with hibernate.
I use MyEclipse 3.8.4 on linux gentoo with sun jdk 1.4.2When I try to load my class I get a castClassException:
02/21 11:13:15 error
[1]java.lang.ClassCastException
at net.sf.hibernate.type.IntegerType.set(IntegerType.java:34)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48)
…
…I have two table:
UserComunity
UserProfileWith a one-to-one relation
I think there are some problem in hbm.xml generate by MyEclipse but I don’t uderstand what.my xml:
<?xml version=”1.0″?>
<!DOCTYPE hibernate-mapping PUBLIC
“-//Hibernate/Hibernate Mapping DTD 2.0//EN”
“http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd” ><!– DO NOT EDIT: This is a generated file that is synchronized –>
<!– by MyEclipse Hibernate tool integration. –>
<!– Created Wed Jan 19 16:56:07 CET 2005 –>
<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” />
</class></hibernate-mapping>
and
<?xml version=”1.0″?>
<!DOCTYPE hibernate-mapping PUBLIC
“-//Hibernate/Hibernate Mapping DTD 2.0//EN”
“http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd” ><!– DO NOT EDIT: This is a generated file that is synchronized –>
<!– by MyEclipse Hibernate tool integration. –>
<!– Created Sun Feb 20 15:27:14 CET 2005 –>
<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><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”/>
</class></hibernate-mapping>
<?xml version=”1.0″?>
<!DOCTYPE hibernate-mapping PUBLIC
“-//Hibernate/Hibernate Mapping DTD 2.0//EN”
“http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd” ><!– DO NOT EDIT: This is a generated file that is synchronized –>
<!– by MyEclipse Hibernate tool integration. –>
<!– Created Sun Feb 20 15:27:14 CET 2005 –>
<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><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” />
<!–
a test but it doesn’t works
<one-to-one name=”userComunity” class=”UserComunity”/>
–>
</class></hibernate-mapping>
any idea?
if you need more info about my config ask me.Thanks in advance
Lorenzo
Riyad KallaMemberLorenzo,
Do all the “type” fields that MyEclipse generated match up to the Java Types you have defined for the methods in your classes?Also, what is the entire exception? What line does it point to in YOUR code?
arnorMemberthe code line problem is:
UserProfile profile = (UserProfile) hSession.load(UserProfile.class,usr);When Hibernate load UserProfile I get cast exception.
May be some problem about UserComunity id and foreign key of UserProfile.I chech UserProfile and UserComunity class and all type match.
Many thanks in advanceregards Lorenzo
my snippets:
try {
hSession = SessionFactory.currentSession();
UserComunity usr = (UserComunity) hSession.load(UserComunity.class,userComunityForm.getId_user());
UserProfile profile = (UserProfile) hSession.load(UserProfile.class,usr);
/*logger.info(new Date()+ userComunityForm.getAdress() );
profile.setAddress(userComunityForm.getAdress());
*/
pack.addParam(“update”,”1″);
hSession.flush();
SessionFactory.closeSession();} catch (HibernateException e) {
e.printStackTrace();
}my exeception:
02/22 11:17:08 error
[1]java.lang.ClassCastException
at net.sf.hibernate.type.IntegerType.set(IntegerType.java:34)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35)
at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:749)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:788)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:265)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:911)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:931)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:415)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2130)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:2000)
at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1929)
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)
[0]javax.servlet.ServletException
at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
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)
Riyad KallaMemberUserComunity usr = (UserComunity) hSession.load(UserComunity.class,userComunityForm.getId_user());
UserProfile profile = (UserProfile) hSession.load(UserProfile.class,usr);You don’t want to pass ‘usr’ to the load method, you need to pass the PK of UserProfile so Hibernate can load it… how is it suppose to know which method on UserCommunity will return the PK?
Try this:
UserComunity usr = (UserComunity) hSession.load(UserComunity.class,userComunityForm.getId_user()); UserProfile profile = (UserProfile) hSession.load(UserProfile.class,usr.getProfileID());
Where “getProfileID()” is whatever method you wrote to get the UserProfile ID from the UserCommunity object.
arnorMembermumble, mumble I had do a test similar but I get this exeception:
– expected type: it.kemen.standard.hibernate.UserComunity, actual value: java.lang.Integer
net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of it.kemen.standard.hibernate.AbstractUserProfile.userComunity
at net.sf.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:68)
at net.sf.hibernate.persister.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:338)
at net.sf.hibernate.persister.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:368)
at net.sf.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1793)
at net.sf.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1785)
at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:577)
at net.sf.hibernate.loader.Loader.getRow(Loader.java:501)
at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:213)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:911)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:931)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:415)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2130)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:2000)
at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1929)
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)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at net.sf.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:38)
… 33 moreMay be there are some problem in my db structure and Hibernate.
my table:UserComunity:
-id_user
-email
-pswd
-…UserProfile
-id_user_fk -> UserComunity.id_user
-fullname
-adress
-city
-….from Hibernare log I get:
expected type: it.kemen.standard.hibernate.UserComunity, actual value: java.lang.Integerregards Lorenzo
support-jeffMemberPlease post information on what database you are using (version too), and also supply the DDL for the UserCommunity and UserProfile tables.
support-jeffMemberNevermind. This is a bug, or at least a rare edge-case not accounted for in the current implementation. Basically, you have a one-to-one relationship here. However, it is the “primary key” variety of 1:1, i.e. each class has its own PK, but there is a FK constraint defined on one of the PKs that refers to the PK of the other table. I recommend you check out “Hibernate In Action” by Christian Bauer and Gavin King – it has a great section on this stuff. Also, look at http://www.hibernate.org/hib_docs/reference/en/html/mapping.html#mapping-declaration-onetoone for more.
Do you have any control over the table definitions in your database? If so, I think the FK style 1:1 would work for you. Basically, add another column to UserProfile that is a *unique* FK to UserComunity (and drop the FK on the id_user_fk PK). If you do not have this kind of power, you need to alter the mapping file definition as discussed at the above url (basically, add one-to-ones in both mappings plus a param element to the id).
arnorMemberfirst, tks for the answer.
I can modify my table but I prefer to keep my DDL because other application use it.
Anyway I try to add one-to-one relation in UserProfile xml like this:
<one-to-one name=”userComunity” class=”UserComunity” constrained=”true”/>I get the same exception:
– Unhandled Exception thrown: class java.lang.ClassCastException
02/23 12:12:55 error
[1]java.lang.ClassCastException
at net.sf.hibernate.type.IntegerType.set(IntegerType.java:34)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35)
at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:749)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:788)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:265)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:911)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:931)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:415)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2130)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:2000)
at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1929)
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)
[0]javax.servlet.ServletException
at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
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)my DDL. I use hibernate with Mysql 4.0
—
— 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 don’t understand if it’s a bug of Hibernate or of MyEclipse wizard. In the first case I send a message to Hibernate Forum.
Many thanks for the suggestione about “Hibernate in Action”. It’s planned. 😉
regards Lorenzo
support-jeffMemberDid you also add the 1:1 in UserComunity:
<one-to-one name=”userProfile” class=”UserProfile=”/>
as well as the special id generator and param in UserProfile:
<id name=”idUser” column=”id_user_fk”>
<generator class=”foreign”>
<param name=”property”>userComunity</param>
</generator>
</id>
…
<one-to-one name=”userComunity”
class=”UserComunity”
constrained=”true”/>Note that the generator ‘foreign’ is special and important in your scenario, and that the param element with attribute value ‘property’ and body userComunity is also very significant.
This is not a bug in Hibernate; Hibernate will handle your DDL. The problem is that this is a use case not covered in the MyEclipse tool. But you should be able to tweak the generated mapping to get it to work…it might just take a lot of playing around.
arnorMemberI changed my Hibernage xml with your suggestion but I get a new exception:
– Mapping resource: it/kemen/standard/hibernate/UserComunity.hbm.xml
– Mapping class: it.kemen.standard.hibernate.UserComunity -> user_comunity
– Could not compile the mapping document
net.sf.hibernate.MappingException: Could not find class: UserProfile=
at net.sf.hibernate.cfg.Binder.bindOneToOne(Binder.java:707)
at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:1043)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:363)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1257)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:288)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1018)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:974)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:902)
at it.kemen.standard.hibernate.SessionFactory.currentSession(SessionFactory.java:87)
at com.croxit.struts.action.UserComunityAction.execute(UserComunityAction.java:168)
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)
%%%% Error Creating SessionFactory %%%%
net.sf.hibernate.MappingException: Error reading resource: it/kemen/standard/hibernate/UserComunity.hbm.xml
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:339)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1018)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:974)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:902)
at it.kemen.standard.hibernate.SessionFactory.currentSession(SessionFactory.java:87)
at com.croxit.struts.action.UserComunityAction.execute(UserComunityAction.java:168)
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)
Caused by: net.sf.hibernate.MappingException: Could not find class: UserProfile=
at net.sf.hibernate.cfg.Binder.bindOneToOne(Binder.java:707)
at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:1043)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:363)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1257)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:288)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
… 20 more
– Proxool 0.8.3 (14-Dec-2003 16:06)
– Unhandled Exception thrown: class java.lang.NullPointerException
02/24 12:49:32 error
[1]java.lang.NullPointerException
at it.kemen.standard.hibernate.SessionFactory.currentSession(SessionFactory.java:132)
at com.croxit.struts.action.UserComunityAction.execute(UserComunityAction.java:168)
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)
[0]javax.servlet.ServletException
at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
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)my xml:
<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=”idUser” 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>
and
<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>
I think that the problem is <one-to-one name=”userProfile” class=”UserProfile=”/> because in UserComunity I don’t have userProfile reference.
Anyway if I remove one-to-one relation in UserComunity I get another exception:
– Mapping class: it.kemen.standard.hibernate.UserProfile -> user_profile
– Could not compile the mapping document
net.sf.hibernate.MappingException: Problem trying to set property type by reflection
at net.sf.hibernate.mapping.SimpleValue.setTypeByReflection(SimpleValue.java:183)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:267)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1257)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:288)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1018)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:974)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:902)
at it.kemen.standard.hibernate.SessionFactory.currentSession(SessionFactory.java:87)
at com.croxit.struts.action.UserComunityAction.execute(UserComunityAction.java:168)
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)
Caused by: net.sf.hibernate.PropertyNotFoundException: field not found: idUser
at net.sf.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:74)
at net.sf.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:80)
at net.sf.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:80)
at net.sf.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:88)
at net.sf.hibernate.util.ReflectHelper.getter(ReflectHelper.java:81)
at net.sf.hibernate.util.ReflectHelper.reflectedPropertyType(ReflectHelper.java:86)
at net.sf.hibernate.mapping.SimpleValue.setTypeByReflection(SimpleValue.java:172)
… 25 more
%%%% Error Creating SessionFactory %%%%
net.sf.hibernate.MappingException: Error reading resource: it/kemen/standard/hibernate/UserProfile.hbm.xml
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:339)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1018)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:974)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:902)
at it.kemen.standard.hibernate.SessionFactory.currentSession(SessionFactory.java:87)
at com.croxit.struts.action.UserComunityAction.execute(UserComunityAction.java:168)
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)
Caused by: net.sf.hibernate.MappingException: Problem trying to set property type by reflection
at net.sf.hibernate.mapping.SimpleValue.setTypeByReflection(SimpleValue.java:183)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:267)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1257)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:288)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
… 20 more
Caused by: net.sf.hibernate.PropertyNotFoundException: field not found: idUser
at net.sf.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:74)
at net.sf.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:80)
at net.sf.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:80)
at net.sf.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:88)
at net.sf.hibernate.util.ReflectHelper.getter(ReflectHelper.java:81)
at net.sf.hibernate.util.ReflectHelper.reflectedPropertyType(ReflectHelper.java:86)
at net.sf.hibernate.mapping.SimpleValue.setTypeByReflection(SimpleValue.java:172)
… 25 more
– Proxool 0.8.3 (14-Dec-2003 16:06)
– Unhandled Exception thrown: class java.lang.NullPointerException
02/24 12:56:46 error
[1]java.lang.NullPointerException
at it.kemen.standard.hibernate.SessionFactory.currentSession(SessionFactory.java:132)
at com.croxit.struts.action.UserComunityAction.execute(UserComunityAction.java:168)
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)
[0]javax.servlet.ServletException
at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
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)I hope this info add you to understand more.
Regards Lorenzo
support-jeffMemberUm, I think it is just a typo, Lorenzo:
– Mapping resource: it/kemen/standard/hibernate/UserComunity.hbm.xml
– Mapping class: it.kemen.standard.hibernate.UserComunity -> user_comunity
– Could not compile the mapping document
net.sf.hibernate.MappingException: Could not find class: UserProfile=and
<one-to-one name=”userProfile” class=”UserProfile=”/>
Note the equals sign at the end of UserProfile? Drop that.
I think that the problem is <one-to-one name=”userProfile” class=”UserProfile=”/> because in UserComunity I don’t have userProfile reference.
But you do; it is the one-to-one. Not sure what you are saying there.
arnorMemberI fix the typo and I add one-to-one relation in UserComunity:
I get a new exception:
– building session factory
%%%% Error Creating SessionFactory %%%%
net.sf.hibernate.PropertyNotFoundException: Could not find a getter for userProfile in class it.kemen.standard.hibernate.UserComunity
at net.sf.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:182)
at net.sf.hibernate.mapping.Property.getGetter(Property.java:175)
at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:750)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:692)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:137)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:796)
at it.kemen.standard.hibernate.SessionFactory.currentSession(SessionFactory.java:88)
at com.croxit.struts.action.UserComunityAction.execute(UserComunityAction.java:168)
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)
– Proxool 0.8.3 (14-Dec-2003 16:06)
– Unhandled Exception thrown: class java.lang.NullPointerException
02/24 15:17:13 error
[1]java.lang.NullPointerException
at it.kemen.standard.hibernate.SessionFactory.currentSession(SessionFactory.java:132)
at com.croxit.struts.action.UserComunityAction.execute(UserComunityAction.java:168)
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)
[0]javax.servlet.ServletException
at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
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)I remove one-to-one relation in UserComunity. I get this exception
– Mapping class: it.kemen.standard.hibernate.UserProfile -> user_profile
– Could not compile the mapping document
net.sf.hibernate.MappingException: Problem trying to set property type by reflection
at net.sf.hibernate.mapping.SimpleValue.setTypeByReflection(SimpleValue.java:183)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:267)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1257)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:288)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1018)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:974)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:902)
at it.kemen.standard.hibernate.SessionFactory.currentSession(SessionFactory.java:87)
at com.croxit.struts.action.UserComunityAction.execute(UserComunityAction.java:168)
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)
Caused by: net.sf.hibernate.PropertyNotFoundException: field not found: idUser
at net.sf.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:74)
at net.sf.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:80)
at net.sf.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:80)
at net.sf.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:88)
at net.sf.hibernate.util.ReflectHelper.getter(ReflectHelper.java:81)
at net.sf.hibernate.util.ReflectHelper.reflectedPropertyType(ReflectHelper.java:86)
at net.sf.hibernate.mapping.SimpleValue.setTypeByReflection(SimpleValue.java:172)
… 25 more
%%%% Error Creating SessionFactory %%%%
net.sf.hibernate.MappingException: Error reading resource: it/kemen/standard/hibernate/UserProfile.hbm.xml
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:339)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1018)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:974)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:902)
at it.kemen.standard.hibernate.SessionFactory.currentSession(SessionFactory.java:87)
at com.croxit.struts.action.UserComunityAction.execute(UserComunityAction.java:168)
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)
Caused by: net.sf.hibernate.MappingException: Problem trying to set property type by reflection
at net.sf.hibernate.mapping.SimpleValue.setTypeByReflection(SimpleValue.java:183)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:267)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1257)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:288)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
… 20 more
Caused by: net.sf.hibernate.PropertyNotFoundException: field not found: idUser
at net.sf.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:74)
at net.sf.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:80)
at net.sf.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:80)
at net.sf.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:88)
at net.sf.hibernate.util.ReflectHelper.getter(ReflectHelper.java:81)
at net.sf.hibernate.util.ReflectHelper.reflectedPropertyType(ReflectHelper.java:86)
at net.sf.hibernate.mapping.SimpleValue.setTypeByReflection(SimpleValue.java:172)
… 25 more
– Proxool 0.8.3 (14-Dec-2003 16:06)
– Unhandled Exception thrown: class java.lang.NullPointerException
02/24 14:34:18 error
[1]java.lang.NullPointerException
at it.kemen.standard.hibernate.SessionFactory.currentSession(SessionFactory.java:132)
at com.croxit.struts.action.UserComunityAction.execute(UserComunityAction.java:168)
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)
[0]javax.servlet.ServletException
at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
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)then I had try to change idUser to userComunity and remove <one-to-one name=”userProfile” class=”UserProfile”/> to UserComunity xml.
I get this exception:
– Not binding factory to JNDI, no JNDI name configured
– 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)the last attempt it’s near to the result but it doesn’t works 🙂
Many thanks for any suggestion.
regards Lorenzo
support-jeffMemberLorenzo –
You gotta read the exception starting from the top!
net.sf.hibernate.PropertyNotFoundException: Could not find a getter for userProfile in class it.kemen.standard.hibernate.UserComunity
So, do you have get/setUserProfile accessors on your UserComunity class?
arnorMemberin my UserComunity class I don’t have get/set UserProfile because in my table I don’t have any foreign key to UserProfile table.
In my UserProfile table I have a foreign key to UserComunity.id_user
In my post there are more test if you check.
I change UserComunity xml to fit the DDLAnyway I post my ddl and xml to Hibernate forum may be some one can help me to fix my Hibertate xml.
many thanks
Lorenzo
-
AuthorPosts