I've taken the HiA-SE code, just the persistence stuff, and put it
into a little 'sandbox' project I'm using to get familiar with a
variety of technologies that I'm a bit behind in. I'm wanting to get
familiar with Hibernate, specifically, the Hibernate Annotations, for
the persistence layer.
I changed the code to reflect the changes to the latest EJB3 draft. So
it all compiles fine with Hibernate Annotations beta 8 and Hibernate
3.1.1. I've been careful to only change the annotations as per the Hibernate Annotation notes, and IDEA did an excellent job of identifying the inconsistencies.
When I run my app (a web application) the Hibernate initialization
fails while mapping the Category class. The log output at the point of
failure is as follows:
INFO: Mapping collection: com.sandbox.vo.Category.children -> CATEGORY
01-Feb-2006 10:15:11 org.hibernate.cfg.annotations.CollectionBinder
bindOneToManySecondPass
INFO: Mapping collection: com.sandbox.vo.Category.categorizedItems ->
CATEGORIZED_ITEM
01-Feb-2006 10:15:11 com.sandbox.persistence.HibernateUtil <clinit>
SEVERE: Building SessionFactory failed.
And the stack trace is as follows:
org.hibernate.MappingException: Could not determine type for:
com.sandbox.vo.Node, for columns:
[org.hibernate.mapping.Column(parent)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
at org.hibernate.mapping.Property.getType(Property.java:49)
at org.hibernate.mapping.Component.getType(Component.java:153)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.Property.isValid(Property.java:184)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:395)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:983)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1157)
at com.sandbox.persistence.HibernateUtil.<clinit>(HibernateUtil.java:80)
at com.sandbox.servlet.HibernateListener.contextInitialized(HibernateListener.java:21)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3692)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4127)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:603)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:535)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1118)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
at org.apache.catalina.startup.Catalina.start(Catalina.java:536)
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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:275)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
As you can see I'm using Tomcat5.5 as my app server.
I've been trying for quite a while to figure this out, even asked on #hibernate on freenode, but nobody seems to have a clue. So I'm going to 'the horses mouth' so to speak.
Somebody did indicate it might have to do with the getParent() call in Category, but that annotation correctly identifies Category.class as the targetEntity. What am I doing wrong? Any clues, feedback would be appreciated.
thanks in advance,
Darryl Pentz
|