java - Spring Hibernate Mapping Issue -


since new hibernate , mapping. unable find exact issue cause. update question heading when find out issue. getting following error when running spring project. hbm.xml generated jboss hibernate tools. (i will)

stack trace given below

    mar 10, 2014 4:28:05 pm org.springframework.context.support.abstractapplicationcontext preparerefresh     info: refreshing org.springframework.context.support.classpathxmlapplicationcontext@a4c4a0d: display name [org.springframework.context.support.classpathxmlapplicationcontext@a4c4a0d]; startup date [mon mar 10 16:28:05 ist 2014]; root of context hierarchy     mar 10, 2014 4:28:05 pm org.springframework.beans.factory.xml.xmlbeandefinitionreader loadbeandefinitions     info: loading xml bean definitions class path resource [config/beanlocations.xml]     mar 10, 2014 4:28:05 pm org.springframework.beans.factory.xml.xmlbeandefinitionreader loadbeandefinitions     info: loading xml bean definitions class path resource [database/datasource.xml]     mar 10, 2014 4:28:05 pm org.springframework.beans.factory.xml.xmlbeandefinitionreader loadbeandefinitions     info: loading xml bean definitions class path resource [database/hibernate.xml]     mar 10, 2014 4:28:21 pm org.springframework.context.support.abstractapplicationcontext obtainfreshbeanfactory     info: bean factory application context [org.springframework.context.support.classpathxmlapplicationcontext@a4c4a0d]: org.springframework.beans.factory.support.defaultlistablebeanfactory@5152a09f     mar 10, 2014 4:28:21 pm org.springframework.core.io.support.propertiesloadersupport loadproperties     info: loading properties file class path resource [properties/hibernate.properties]     mar 10, 2014 4:28:21 pm org.springframework.beans.factory.support.defaultlistablebeanfactory preinstantiatesingletons     info: pre-instantiating singletons in org.springframework.beans.factory.support.defaultlistablebeanfactory@5152a09f: defining beans [org.springframework.beans.factory.config.propertyplaceholderconfigurer#0,datasource,sessionfactory,transactionmanager,org.springframework.context.annotation.internalpersistenceannotationprocessor,org.springframework.context.annotation.internalcommonannotationprocessor,org.springframework.context.annotation.internalautowiredannotationprocessor,org.springframework.context.annotation.internalrequiredannotationprocessor,aneurismlocationdao,annotationdao,appuserdao,devicedao,devicemanufacturerdao,jobdao,patientdao,resourcedao,roledao,strategydao,surgerydao,surgerydevicedao,userroledao]; root of factory hierarchy     mar 10, 2014 4:28:21 pm org.springframework.jdbc.datasource.drivermanagerdatasource setdriverclassname     info: loaded jdbc driver: com.mysql.jdbc.driver     37 [main] info org.hibernate.cfg.environment - hibernate 3.5.5-final     39 [main] info org.hibernate.cfg.environment - hibernate.properties not found     43 [main] info org.hibernate.cfg.environment - bytecode provider name : javassist     47 [main] info org.hibernate.cfg.environment - using jdk 1.4 java.sql.timestamp handling     17632 [main] info org.hibernate.cfg.hbmbinder - mapping class: org.e.models.resource -> resource     28298 [main] info org.hibernate.cfg.hbmbinder - mapping class: org.e.models.device -> device     40931 [main] info org.hibernate.cfg.hbmbinder - mapping class: org.e.models.aneurismlocation -> aneurism_location     43487 [main] info org.hibernate.cfg.hbmbinder - mapping class: org.e.models.strategy -> strategy     46348 [main] info org.hibernate.cfg.hbmbinder - mapping class: org.e.models.job -> job     48916 [main] info org.hibernate.cfg.hbmbinder - mapping class: org.e.models.surgerydevice -> surgery_device     51356 [main] info org.hibernate.cfg.hbmbinder - mapping class: org.e.models.userrole -> user_role     54070 [main] info org.hibernate.cfg.hbmbinder - mapping class: org.e.models.surgery -> surgery     56434 [main] info org.hibernate.cfg.hbmbinder - mapping class: org.e.models.annotation1 -> annotation     58732 [main] info org.hibernate.cfg.hbmbinder - mapping class: org.e.models.patient -> patient     61120 [main] info org.hibernate.cfg.hbmbinder - mapping class: org.e.models.role -> role     63747 [main] info org.hibernate.cfg.hbmbinder - mapping class: org.e.models.devicemanufacturer -> device_manufacturer     66318 [main] info org.hibernate.cfg.hbmbinder - mapping class: org.e.models.appuser -> app_user     mar 10, 2014 4:29:28 pm org.springframework.beans.factory.support.defaultsingletonbeanregistry destroysingletons     info: destroying singletons in org.springframework.beans.factory.support.defaultlistablebeanfactory@5152a09f: defining beans [org.springframework.beans.factory.config.propertyplaceholderconfigurer#0,datasource,sessionfactory,transactionmanager,org.springframework.context.annotation.internalpersistenceannotationprocessor,org.springframework.context.annotation.internalcommonannotationprocessor,org.springframework.context.annotation.internalautowiredannotationprocessor,org.springframework.context.annotation.internalrequiredannotationprocessor,aneurismlocationdao,annotationdao,appuserdao,devicedao,devicemanufacturerdao,jobdao,patientdao,resourcedao,roledao,strategydao,surgerydao,surgerydevicedao,userroledao]; root of factory hierarchy     exception in thread "main" org.springframework.beans.factory.beancreationexception: error creating bean name 'sessionfactory' defined in class path resource [database/hibernate.xml]: invocation of init method failed; nested exception org.hibernate.mappingexception: association references unmapped class: org.e.models.annotation         @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1338)         @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:473)         @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory$1.run(abstractautowirecapablebeanfactory.java:409)         @ java.security.accesscontroller.doprivileged(native method)         @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:380)         @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:264)         @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:222)         @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:261)         @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:185)         @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:164)         @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:423)         @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:728)         @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:380)         @ org.springframework.context.support.classpathxmlapplicationcontext.<init>(classpathxmlapplicationcontext.java:139)         @ org.springframework.context.support.classpathxmlapplicationcontext.<init>(classpathxmlapplicationcontext.java:83)         @ application.main(application.java:23)     caused by: org.hibernate.mappingexception: association references unmapped class: org.endovantage.models.annotation         @ org.hibernate.cfg.hbmbinder.bindcollectionsecondpass(hbmbinder.java:2473)         @ org.hibernate.cfg.hbmbinder$collectionsecondpass.secondpass(hbmbinder.java:2752)         @ org.hibernate.cfg.collectionsecondpass.dosecondpass(collectionsecondpass.java:66)         @ org.hibernate.cfg.configuration.secondpasscompile(configuration.java:1221)         @ org.hibernate.cfg.configuration.buildmappings(configuration.java:1206)         @ org.springframework.orm.hibernate3.localsessionfactorybean.buildsessionfactory(localsessionfactorybean.java:673)         @ org.springframework.orm.hibernate3.abstractsessionfactorybean.afterpropertiesset(abstractsessionfactorybean.java:211)         @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.invokeinitmethods(abstractautowirecapablebeanfactory.java:1369)         @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1335)         ... 15 more 

my models reside in maven module.

this annotation hbm.xml

<?xml version="1.0"?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd 3.0//en" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <!-- generated mar 5, 2014 5:28:21 pm hibernate tools 4.0.0 --> <hibernate-mapping>     <class name="org.e.models.annotation1" table="annotation" catalog="endo">         <id name="id" type="java.lang.long">             <column name="id" />             <generator class="identity" />         </id>         <many-to-one name="resource" class="org.e.models.resource" fetch="select">             <column name="resource_id" not-null="true" />         </many-to-one>         <property name="xpoint" type="java.lang.integer">             <column name="x_point" />         </property>         <property name="ypoint" type="java.lang.integer">             <column name="y_point" />         </property>         <property name="zpoint" type="java.lang.integer">             <column name="z_point" />         </property>         <property name="comment" type="string">             <column name="comment" length="65535" />         </property>     </class> </hibernate-mapping> 

this model annotation1 (i changed annotation annotation1 check weather problem.)

   package org.e.models;  public class annotation1 implements java.io.serializable {      private static final long serialversionuid = 2037771233820433553l;     private long id;     private resource resource;     private integer xpoint;     private integer ypoint;     private integer zpoint;     private string comment;      public annotation1() {     }      public annotation1(resource resource) {         this.resource = resource;     }      public annotation1(resource resource, integer xpoint, integer ypoint,             integer zpoint, string comment) {         this.resource = resource;         this.xpoint = xpoint;         this.ypoint = ypoint;         this.zpoint = zpoint;         this.comment = comment;     }      public long getid() {         return this.id;     }      public void setid(long id) {         this.id = id;     }      public resource getresource() {         return this.resource;     }      public void setresource(resource resource) {         this.resource = resource;     }      public integer getxpoint() {         return this.xpoint;     }      public void setxpoint(integer xpoint) {         this.xpoint = xpoint;     }      public integer getypoint() {         return this.ypoint;     }      public void setypoint(integer ypoint) {         this.ypoint = ypoint;     }      public integer getzpoint() {         return this.zpoint;     }      public void setzpoint(integer zpoint) {         this.zpoint = zpoint;     }      public string getcomment() {         return this.comment;     }      public void setcomment(string comment) {         this.comment = comment;     }  } 

this dao implementation

    package org.e.persistance.dao.impli;  import org.apache.commons.logging.log; import org.apache.commons.logging.logfactory; import org.e.models.annotation1; import org.e.persistance.dao.annotation1dao; import org.hibernate.sessionfactory; import org.springframework.beans.factory.annotation.autowired; import org.springframework.stereotype.repository;  @repository("annotation1dao") public class annotation1daoimpli implements annotation1dao {      private static final log log = logfactory.getlog(annotation1daoimpli.class);      @autowired     private sessionfactory sessionfactory;      public void persist(annotation1 transientinstance) {         log.debug("persisting annotation1 instance");         try {             sessionfactory.getcurrentsession().persist(transientinstance);             log.debug("persist successful");         } catch (runtimeexception re) {             log.error("persist failed", re);             throw re;         }     }       public void delete(annotation1 persistentinstance) {         log.debug("deleting annotation1 instance");         try {             sessionfactory.getcurrentsession().delete(persistentinstance);             log.debug("delete successful");         } catch (runtimeexception re) {             log.error("delete failed", re);             throw re;         }     }      public annotation1 merge(annotation1 detachedinstance) {         log.debug("merging annotation1 instance");         try {             annotation1 result = (annotation1) sessionfactory.getcurrentsession()                     .merge(detachedinstance);             log.debug("merge successful");             return result;         } catch (runtimeexception re) {             log.error("merge failed", re);             throw re;         }     }      public annotation1 findbyid(java.lang.long id) {         log.debug("getting annotation1 instance id: " + id);         try {             annotation1 instance = (annotation1) sessionfactory                     .getcurrentsession().get("annotation1", id);             if (instance == null) {                 log.debug("get successful, no instance found");             } else {                 log.debug("get successful, instance found");             }             return instance;         } catch (runtimeexception re) {             log.error("get failed", re);             throw re;         }     }   } 

sorry long content. appreciate on this.

edit:

hibernate configuration file

    <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:context="http://www.springframework.org/schema/context"     xsi:schemalocation="       http://www.springframework.org/schema/beans        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd       http://www.springframework.org/schema/context        http://www.springframework.org/schema/context/spring-context-3.2.xsd">      <!-- hibernate session factory -->     <bean id="sessionfactory"         class="org.springframework.orm.hibernate3.localsessionfactorybean">          <property name="datasource">             <ref bean="datasource" />         </property>          <property name="hibernateproperties">             <props>                 <prop key="hibernate.dialect">org.hibernate.dialect.mysqldialect</prop>                 <prop key="hibernate.show_sql">true</prop>             </props>         </property>          <property name="mappingresources">             <list>                 <value>/hibernate/resource.hbm.xml</value>                 <value>/hibernate/device.hbm.xml</value>                 <value>/hibernate/aneurismlocation.hbm.xml</value>                 <value>/hibernate/strategy.hbm.xml</value>                 <value>/hibernate/job.hbm.xml</value>                 <value>/hibernate/surgerydevice.hbm.xml</value>                 <value>/hibernate/userrole.hbm.xml</value>                 <value>/hibernate/surgery.hbm.xml</value>                 <value>/hibernate/annotation1.hbm.xml</value>                 <value>/hibernate/patient.hbm.xml</value>                 <value>/hibernate/role.hbm.xml</value>                 <value>/hibernate/devicemanufacturer.hbm.xml</value>                 <value>/hibernate/appuser.hbm.xml</value>             </list>         </property>      </bean>     <bean id="transactionmanager"         class="org.springframework.orm.hibernate3.hibernatetransactionmanager">         <property name="sessionfactory" ref="sessionfactory" />     </bean> </beans> 

enter image description here

this data source configuration

    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">  <bean  class="org.springframework.beans.factory.config.propertyplaceholderconfigurer">     <property name="location">         <value>properties/hibernate.properties</value>     </property> </bean>  <bean id="datasource"           class="org.springframework.jdbc.datasource.drivermanagerdatasource">     <property name="driverclassname" value="${jdbc.driverclassname}" />     <property name="url" value="${jdbc.url}" />     <property name="username" value="${jdbc.username}" />     <property name="password" value="${jdbc.password}" /> </bean>  </beans> 

this bean location configuration

    <beans xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:context="http://www.springframework.org/schema/context"     xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">      <!-- database configuration -->     <import resource="../database/datasource.xml" />     <import resource="../database/hibernate.xml" />     <context:annotation-config />     <context:component-scan base-package="org.endovantage" /> </beans> 

thanks

you need add reference mapping file maps org.e.models.annotation1 hibernate.xmllike

<session-factory>     <mapping resource="org/e/models/annotation1.hbm.xml" /> </session-factory> 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -