-->
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: joined-subclass and PropertyNotFoundException
PostPosted: Fri Jun 17, 2005 3:52 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
Hibernate version: 3.0.5

I have two classes - School and Site. Site is a joined-subclass of School. School has a String ID, called 'school_uuid'. So Site inherits 'school_uuid' as its ID from School. But creating the SessionFactory is failing saying it can't find a getter for 'SiteId' in the Site POJO. My Site POJO doesn't have a getter for 'SiteId' (I don't know where that's even coming from), and the getter for 'school_uuid' is in the parent School class.

Any ideas what I'm doing wrong with my mapping files?

Mapping documents:

School:

Code:
<hibernate-mapping
   package="com.something.user.entity"
   schema="lms"
        default-lazy="false">

   
   <class name="School"
          table="schools">
      <id name="schoolUuid"
          column="school_uuid"
          type="java.lang.String"
          length="36">
         <generator class="com.something.spring.HibernateUuidGenerator"/>
      </id>
...


Site:

Code:
<hibernate-mapping package="org.something.data.db.hibernate">
   <joined-subclass
      name="Site"
      table="site"
      schema="sm"
      extends="com.something.user.entity.School">

      <key column="school_uuid" />
...



Full stack trace of any exception that occurs:

Quote:
Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for SiteId in class org.something.data.db.hibernate.Site
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:281)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:274)
at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:160)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:42)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:108)
at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:212)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:981)
at
...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2005 5:26 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
The above posted exception is what I got when trying to run unit tests. Interestingly, if I use the eclipse plugin Hibernate Console Configuration and try to create a session factory, I get the following exception:

Quote:
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.something.user.entity.User.userUuid
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:119)
at org.hibernate.engine.UnsavedValueFactory.getUnsavedIdentifierValue(UnsavedValueFactory.java:44)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:42)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:108)
at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400)
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:87)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:58)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:211)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
at org.hibernate.console.ConsoleConfiguration$1.execute(ConsoleConfiguration.java:222)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:77)
at org.hibernate.console.ConsoleConfiguration.initSessionFactory(ConsoleConfiguration.java:220)
at org.hibernate.eclipse.console.actions.BuildSessionFactoryAction.doRun(BuildSessionFactoryAction.java:51)
at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:47)
at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:167)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:538)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:400)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:844)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3058)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2691)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1716)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1680)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:365)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
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:585)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
at org.eclipse.core.launcher.Main.run(Main.java:973)
at org.eclipse.core.launcher.Main.main(Main.java:948)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
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:585)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:105)
at org.hibernate.engine.UnsavedValueFactory.getUnsavedIdentifierValue(UnsavedValueFactory.java:44)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:42)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:108)
at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400)
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:87)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:58)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:211)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
at org.hibernate.console.ConsoleConfiguration$1.execute(ConsoleConfiguration.java:222)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:77)
at org.hibernate.console.ConsoleConfiguration.initSessionFactory(ConsoleConfiguration.java:220)
at org.hibernate.eclipse.console.actions.BuildSessionFactoryAction.doRun(BuildSessionFactoryAction.java:51)
at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:47)
at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:167)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:538)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:400)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:844)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3058)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2691)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1716)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1680)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:365)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
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:585)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
at org.eclipse.core.launcher.Main.run(Main.java:973)
at org.eclipse.core.launcher.Main.main(Main.java:948)


Notice that this exception goes through org.hibernate.persister.entity.JoinedSubclassEntityPersister. This makes me think that it might be caused by the same problem as the exception I posted previously. Something must be wrong with the way I am doing joined-subclass, but I'm following the docs!

One thing to note is that I'm joining across java packages, and db schemas. Maybe that is confusing Hibernate?? I am able to generate POJOs and DDL using the Hibernate Tools without any complaints, and it all seems to be generated correctly.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 21, 2005 10:55 am 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
OK, just to be complete I thought I'd post that I figured out my problems, and they were just dumb mistakes. I forgot that I had removed the hbm2java task from my build file, so my POJOs were out of date.


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.